2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
9 import javax
.swing
.JOptionPane
;
15 public class BillDetailsDialog
extends javax
.swing
.JDialog
{
17 private int selected_id
;
20 * Creates new form BillDetailsDialog
22 public BillDetailsDialog(java
.awt
.Frame parent
, boolean modal
) {
28 * This method is called from within the constructor to initialize the form.
29 * WARNING: Do NOT modify this code. The content of this method is always
30 * regenerated by the Form Editor.
32 @SuppressWarnings("unchecked")
33 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
34 private void initComponents() {
36 jLabel1
= new javax
.swing
.JLabel();
37 comboBillStatus
= new javax
.swing
.JComboBox
<>();
38 jLabel2
= new javax
.swing
.JLabel();
39 jLabel3
= new javax
.swing
.JLabel();
40 dateBill
= new org
.jdesktop
.swingx
.JXDatePicker();
41 valBillAmount
= new javax
.swing
.JFormattedTextField();
42 buttonApply
= new javax
.swing
.JButton();
43 buttonCancel
= new javax
.swing
.JButton();
45 setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
46 setTitle("Bill Details");
47 setLocationByPlatform(true);
49 jLabel1
.setText("Bill Status");
51 comboBillStatus
.setEditable(true);
52 comboBillStatus
.setModel(new javax
.swing
.DefaultComboBoxModel
<>(new String
[] { "PENDING", "RAISED", "AWAITING PAYMENT", "PAID" }));
54 jLabel2
.setText("Bill Date");
56 jLabel3
.setText("Bill Amount");
58 valBillAmount
.setFormatterFactory(new javax
.swing
.text
.DefaultFormatterFactory(new javax
.swing
.text
.NumberFormatter(java
.text
.NumberFormat
.getIntegerInstance())));
60 buttonApply
.setMnemonic('A');
61 buttonApply
.setText("Apply");
62 buttonApply
.addActionListener(new java
.awt
.event
.ActionListener() {
63 public void actionPerformed(java
.awt
.event
.ActionEvent evt
) {
64 buttonApplyActionPerformed(evt
);
68 buttonCancel
.setMnemonic('C');
69 buttonCancel
.setText("Cancel");
70 buttonCancel
.addActionListener(new java
.awt
.event
.ActionListener() {
71 public void actionPerformed(java
.awt
.event
.ActionEvent evt
) {
72 buttonCancelActionPerformed(evt
);
76 javax
.swing
.GroupLayout layout
= new javax
.swing
.GroupLayout(getContentPane());
77 getContentPane().setLayout(layout
);
78 layout
.setHorizontalGroup(
79 layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
80 .addGroup(layout
.createSequentialGroup()
82 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
83 .addGroup(layout
.createSequentialGroup()
84 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.TRAILING
, false)
85 .addComponent(jLabel3
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, 136, Short
.MAX_VALUE
)
86 .addComponent(jLabel2
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, Short
.MAX_VALUE
)
87 .addComponent(jLabel1
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, Short
.MAX_VALUE
))
89 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
90 .addComponent(comboBillStatus
, 0, 301, Short
.MAX_VALUE
)
91 .addComponent(dateBill
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, Short
.MAX_VALUE
)
92 .addComponent(valBillAmount
)))
93 .addGroup(javax
.swing
.GroupLayout
.Alignment
.TRAILING
, layout
.createSequentialGroup()
94 .addGap(0, 0, Short
.MAX_VALUE
)
95 .addComponent(buttonApply
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, 104, javax
.swing
.GroupLayout
.PREFERRED_SIZE
)
96 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.RELATED
)
97 .addComponent(buttonCancel
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, 105, javax
.swing
.GroupLayout
.PREFERRED_SIZE
)))
100 layout
.setVerticalGroup(
101 layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
102 .addGroup(layout
.createSequentialGroup()
104 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.BASELINE
)
105 .addComponent(jLabel1
)
106 .addComponent(comboBillStatus
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
))
107 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.UNRELATED
)
108 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.BASELINE
)
109 .addComponent(jLabel2
)
110 .addComponent(dateBill
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
))
111 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.UNRELATED
)
112 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.BASELINE
)
113 .addComponent(jLabel3
)
114 .addComponent(valBillAmount
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
))
115 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.RELATED
, 19, Short
.MAX_VALUE
)
116 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.BASELINE
)
117 .addComponent(buttonApply
)
118 .addComponent(buttonCancel
))
123 }// </editor-fold>//GEN-END:initComponents
125 private void buttonCancelActionPerformed(java
.awt
.event
.ActionEvent evt
) {//GEN-FIRST:event_buttonCancelActionPerformed
126 // TODO add your handling code here:
128 }//GEN-LAST:event_buttonCancelActionPerformed
130 private void buttonApplyActionPerformed(java
.awt
.event
.ActionEvent evt
) {//GEN-FIRST:event_buttonApplyActionPerformed
131 // TODO add your handling code here:
132 String bill_status
= (String
)comboBillStatus
.getSelectedItem();
133 if (! "PENDING".equals(bill_status
) && (dateBill
.getDate() == null ||
134 valBillAmount
.getValue() == null)) {
135 JOptionPane
.showMessageDialog(this, MANDATORY_FIELDS_MISSING
);
139 boolean rt
= Utility
.updateNoticeBillDetails (selected_id
, bill_status
,
140 dateBill
.getDate(), (int)valBillAmount
.getValue());
142 JOptionPane
.showMessageDialog(this, ERROR_UPDATING
);
145 }//GEN-LAST:event_buttonApplyActionPerformed
146 private static final String MANDATORY_FIELDS_MISSING
= "Mandatory fields missing";
147 private static final String ERROR_UPDATING
= "Error in updating";
150 * @param args the command line arguments
152 public static void main(String args
[]) {
153 /* Set the Nimbus look and feel */
154 //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
155 /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
156 * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
159 for (javax
.swing
.UIManager
.LookAndFeelInfo info
: javax
.swing
.UIManager
.getInstalledLookAndFeels()) {
160 if ("Nimbus".equals(info
.getName())) {
161 javax
.swing
.UIManager
.setLookAndFeel(info
.getClassName());
165 } catch (ClassNotFoundException ex
) {
166 java
.util
.logging
.Logger
.getLogger(BillDetailsDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
167 } catch (InstantiationException ex
) {
168 java
.util
.logging
.Logger
.getLogger(BillDetailsDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
169 } catch (IllegalAccessException ex
) {
170 java
.util
.logging
.Logger
.getLogger(BillDetailsDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
171 } catch (javax
.swing
.UnsupportedLookAndFeelException ex
) {
172 java
.util
.logging
.Logger
.getLogger(BillDetailsDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
176 /* Create and display the dialog */
177 java
.awt
.EventQueue
.invokeLater(new Runnable() {
179 BillDetailsDialog dialog
= new BillDetailsDialog(new javax
.swing
.JFrame(), true);
180 dialog
.addWindowListener(new java
.awt
.event
.WindowAdapter() {
182 public void windowClosing(java
.awt
.event
.WindowEvent e
) {
186 dialog
.setVisible(true);
191 // Variables declaration - do not modify//GEN-BEGIN:variables
192 private javax
.swing
.JButton buttonApply
;
193 private javax
.swing
.JButton buttonCancel
;
194 private javax
.swing
.JComboBox
<String
> comboBillStatus
;
195 private org
.jdesktop
.swingx
.JXDatePicker dateBill
;
196 private javax
.swing
.JLabel jLabel1
;
197 private javax
.swing
.JLabel jLabel2
;
198 private javax
.swing
.JLabel jLabel3
;
199 private javax
.swing
.JFormattedTextField valBillAmount
;
200 // End of variables declaration//GEN-END:variables
202 void setFields(int selid
, String bill_status
, int bill_amount
, Date bill_date
) {
204 comboBillStatus
.setSelectedItem(bill_status
);
205 dateBill
.setDate(bill_date
);
206 valBillAmount
.setValue(bill_amount
);