📄 gaseditor.java
字号:
}); GasEditorMain.add(GasNewVendor); GasNewVendor.setBounds(350, 70, 85, 25); GasLabelDate.setFont(new java.awt.Font("Dialog", 1, 14)); GasLabelDate.setText("Date"); GasEditorMain.add(GasLabelDate); GasLabelDate.setBounds(10, 40, 50, 17); GasButtonDate.setFont(new java.awt.Font("Dialog", 0, 14)); GasButtonDate.setMargin(new java.awt.Insets(2, 2, 2, 2)); GasButtonDate.setMaximumSize(new java.awt.Dimension(100, 20)); GasButtonDate.setMinimumSize(new java.awt.Dimension(100, 20)); GasButtonDate.setPreferredSize(new java.awt.Dimension(100, 20)); GasButtonDate.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { GasButtonDateActionPerformed(evt); } }); GasEditorMain.add(GasButtonDate); GasButtonDate.setBounds(60, 40, 100, 20); getContentPane().add(GasEditorMain); pack(); }//GEN-END:initComponents private void GasButtonDateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GasButtonDateActionPerformed CalForm = new Cal(); CalForm.activate(GasButtonDate.getText().toString()); CalForm.addWindowFocusListener(new java.awt.event.WindowFocusListener() { public void windowGainedFocus(java.awt.event.WindowEvent evt) { } public void windowLostFocus(java.awt.event.WindowEvent evt) { if (CalForm.CalDate != null) GasButtonDate.setText(CalForm.CalDate); } }); }//GEN-LAST:event_GasButtonDateActionPerformed private void GasNewVendorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GasNewVendorActionPerformed this.setEnabled(false); VendorForm = new VendorEditor(); if (NewVen.length > 0) { UsedNames.removeElementAt(UsedNames.size()-1); NewVen = new String[0]; } VendorForm.newEntry(UsedNames); VendorForm.addWindowFocusListener(new WindowFocusListener() { public void windowGainedFocus(WindowEvent evt) { } public void windowLostFocus(WindowEvent evt) { if (!VendorForm.isShowing()) { if (VendorForm.AllInfo.length > 0) NewVen = VendorForm.AllInfo; reEnable(); } } }); }//GEN-LAST:event_GasNewVendorActionPerformed private void GasCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GasCancelActionPerformed exitingEvents(); }//GEN-LAST:event_GasCancelActionPerformed private void GasSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GasSaveActionPerformed if (GasTextOdo.getText().equals("") || GasTextAmount.getText().equals("") || GasTextCost.getText().equals("")) JOptionPane.showMessageDialog(null,"You must enter a value for the Odometer Reading, Amount of Fuel, and Fuel Cost.","Missing Required Fields",JOptionPane.ERROR_MESSAGE); else { String tank = "T"; String est = "F"; if (RadioParTank.isSelected()) tank = "F"; if (CheckEstEntry.isSelected()) est = "T"; AllInfo = new String[9]; AllInfo[0] = GasButtonDate.getText().toString(); AllInfo[1] = GasTextOdo.getText().toString(); AllInfo[2] = GasTextAmount.getText().toString(); AllInfo[3] = GasTextCost.getText().toString(); if (GasTextOctane.getText().toString().trim().equalsIgnoreCase("")) AllInfo[4] = "0"; else AllInfo[4] = GasTextOctane.getText().toString(); AllInfo[5] = GasComboVendor.getSelectedItem().toString(); AllInfo[6] = GasTextComments.getText().toString(); AllInfo[7] = tank; AllInfo[8] = est; exitingEvents(); } }//GEN-LAST:event_GasSaveActionPerformed private void GasTextCostFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_GasTextCostFocusLost if (!GasTextCost.getText().equalsIgnoreCase("") && !GasTextAmount.getText().equalsIgnoreCase("")) total(); }//GEN-LAST:event_GasTextCostFocusLost private void GasTextAmountFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_GasTextAmountFocusLost if (!GasTextCost.getText().equalsIgnoreCase("") && !GasTextAmount.getText().equalsIgnoreCase("")) total(); }//GEN-LAST:event_GasTextAmountFocusLost private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened this.setSize(450,275); }//GEN-LAST:event_formWindowOpened private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm exitingEvents(); }//GEN-LAST:event_exitForm public static void main(String[] args) { new GasEditor().show(); } public void newEntry(Vector v,String dat) { this.show(); UsedNames = v; GasTextOdo.setText(null); GasButtonDate.setText(dat); GasTextOctane.setText(null); GasTextAmount.setText(null); GasTextCost.setText(null); GasTextTotal.setText(null); GasTextComments.setText(null); RadioFullTank.setSelected(true); CheckEstEntry.setSelected(false); GasComboVendor.setModel(new javax.swing.DefaultComboBoxModel(v)); GasComboVendor.setSelectedIndex(0); } public void editEntry(Vector v,String odo,String oct,String amt,String cos,String com,boolean tan,boolean est,int ven,String dat) { this.show(); UsedNames = v; GasTextOdo.setText(odo); GasButtonDate.setText(dat); GasTextOctane.setText(oct); GasTextAmount.setText(amt); GasTextCost.setText(cos); GasTextComments.setText(com); RadioFullTank.setSelected(tan); CheckEstEntry.setSelected(est); GasComboVendor.setModel(new javax.swing.DefaultComboBoxModel(v)); GasComboVendor.setSelectedIndex(ven); total(); } public void reEnable() { this.setEnabled(true); if ((NewVen.length > 0) && (!UsedNames.contains(NewVen[0]))) { UsedNames.addElement(new String(NewVen[0])); GasComboVendor.setModel(new javax.swing.DefaultComboBoxModel(UsedNames)); GasComboVendor.setSelectedIndex(UsedNames.size()-1); } } public void total() { GasTextTotal.setText(new RoundDecimalPlaces().RoundDecimalPlaces(Float.parseFloat(GasTextCost.getText()) * Float.parseFloat(GasTextAmount.getText()))); } public void exitingEvents() { CalForm.dispose(); this.dispose(); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JCheckBox CheckEstEntry; private javax.swing.JButton GasButtonDate; private javax.swing.JButton GasCancel; private javax.swing.JComboBox GasComboVendor; private javax.swing.JPanel GasEditorMain; private javax.swing.JLabel GasLabelAmount; private javax.swing.JLabel GasLabelComments; private javax.swing.JLabel GasLabelCost; private javax.swing.JLabel GasLabelDate; private javax.swing.JLabel GasLabelOctane; private javax.swing.JLabel GasLabelOdo; private javax.swing.JLabel GasLabelTotal; private javax.swing.JLabel GasLabelVendor; private javax.swing.JButton GasNewVendor; private javax.swing.JButton GasSave; private javax.swing.JTextField GasTextAmount; private javax.swing.JTextField GasTextComments; private javax.swing.JTextField GasTextCost; private javax.swing.JTextField GasTextOctane; private javax.swing.JTextField GasTextOdo; private javax.swing.JTextField GasTextTotal; private javax.swing.ButtonGroup GroupTank; private javax.swing.JRadioButton RadioFullTank; private javax.swing.JRadioButton RadioParTank; // End of variables declaration//GEN-END:variables}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -