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.
8 import java
.text
.DateFormat
;
9 import java
.text
.SimpleDateFormat
;
10 import java
.util
.Date
;
11 import javax
.swing
.JOptionPane
;
17 public class DescriptionDialog
extends javax
.swing
.JDialog
{
19 private int selectednotice_id
;
22 * Creates new form DescriptionDialog
24 public DescriptionDialog(java
.awt
.Frame parent
, boolean modal
) {
29 public void setFields (int selid
, String reference
,
30 String description
, Date entrustmentdate
) {
31 selectednotice_id
= selid
;
32 textDescription
.setText(description
);
33 DateFormat datfmt
= new SimpleDateFormat ("dd/MM/yyyy");
34 textEntrustmentDate
.setText (datfmt
.format(entrustmentdate
));
35 textReferenceNumber
.setText(reference
);
39 * This method is called from within the constructor to initialize the form.
40 * WARNING: Do NOT modify this code. The content of this method is always
41 * regenerated by the Form Editor.
43 @SuppressWarnings("unchecked")
44 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
45 private void initComponents() {
47 jLabel1
= new javax
.swing
.JLabel();
48 textReferenceNumber
= new javax
.swing
.JTextField();
49 jLabel2
= new javax
.swing
.JLabel();
50 textEntrustmentDate
= new javax
.swing
.JTextField();
51 jLabel3
= new javax
.swing
.JLabel();
52 jScrollPane1
= new javax
.swing
.JScrollPane();
53 textDescription
= new javax
.swing
.JTextArea();
54 buttonUpdate
= new javax
.swing
.JButton();
55 buttonCancel
= new javax
.swing
.JButton();
57 setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
58 setTitle("Description");
59 setLocationByPlatform(true);
61 jLabel1
.setText("Reference Number");
63 textReferenceNumber
.setEditable(false);
65 jLabel2
.setText("Entrustment Date");
67 textEntrustmentDate
.setEditable(false);
69 jLabel3
.setText("Description");
71 textDescription
.setColumns(20);
72 textDescription
.setRows(5);
73 jScrollPane1
.setViewportView(textDescription
);
75 buttonUpdate
.setMnemonic('U');
76 buttonUpdate
.setText("Update");
77 buttonUpdate
.addActionListener(new java
.awt
.event
.ActionListener() {
78 public void actionPerformed(java
.awt
.event
.ActionEvent evt
) {
79 buttonUpdateActionPerformed(evt
);
83 buttonCancel
.setMnemonic('C');
84 buttonCancel
.setText("Cancel");
85 buttonCancel
.addActionListener(new java
.awt
.event
.ActionListener() {
86 public void actionPerformed(java
.awt
.event
.ActionEvent evt
) {
87 buttonCancelActionPerformed(evt
);
91 javax
.swing
.GroupLayout layout
= new javax
.swing
.GroupLayout(getContentPane());
92 getContentPane().setLayout(layout
);
93 layout
.setHorizontalGroup(
94 layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
95 .addGroup(layout
.createSequentialGroup()
97 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
98 .addGroup(layout
.createSequentialGroup()
99 .addComponent(jLabel1
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, 167, javax
.swing
.GroupLayout
.PREFERRED_SIZE
)
100 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.RELATED
)
101 .addComponent(textReferenceNumber
))
102 .addGroup(layout
.createSequentialGroup()
103 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.TRAILING
, false)
104 .addComponent(jLabel3
, javax
.swing
.GroupLayout
.Alignment
.LEADING
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, Short
.MAX_VALUE
)
105 .addComponent(jLabel2
, javax
.swing
.GroupLayout
.Alignment
.LEADING
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, 167, Short
.MAX_VALUE
))
106 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.RELATED
)
107 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
108 .addComponent(textEntrustmentDate
)
109 .addComponent(jScrollPane1
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, 315, Short
.MAX_VALUE
)))
110 .addGroup(javax
.swing
.GroupLayout
.Alignment
.TRAILING
, layout
.createSequentialGroup()
111 .addGap(0, 0, Short
.MAX_VALUE
)
112 .addComponent(buttonUpdate
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, 100, javax
.swing
.GroupLayout
.PREFERRED_SIZE
)
113 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.RELATED
)
114 .addComponent(buttonCancel
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, 97, javax
.swing
.GroupLayout
.PREFERRED_SIZE
)))
117 layout
.setVerticalGroup(
118 layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
119 .addGroup(layout
.createSequentialGroup()
121 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.BASELINE
)
122 .addComponent(jLabel1
)
123 .addComponent(textReferenceNumber
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
))
124 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.RELATED
)
125 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.BASELINE
)
126 .addComponent(textEntrustmentDate
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
)
127 .addComponent(jLabel2
))
128 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.UNRELATED
)
129 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
130 .addGroup(layout
.createSequentialGroup()
131 .addComponent(jLabel3
)
132 .addGap(0, 52, Short
.MAX_VALUE
))
133 .addComponent(jScrollPane1
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, 0, Short
.MAX_VALUE
))
135 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.BASELINE
)
136 .addComponent(buttonUpdate
)
137 .addComponent(buttonCancel
))
142 }// </editor-fold>//GEN-END:initComponents
144 private void buttonCancelActionPerformed(java
.awt
.event
.ActionEvent evt
) {//GEN-FIRST:event_buttonCancelActionPerformed
145 // TODO add your handling code here:
147 }//GEN-LAST:event_buttonCancelActionPerformed
149 private void buttonUpdateActionPerformed(java
.awt
.event
.ActionEvent evt
) {//GEN-FIRST:event_buttonUpdateActionPerformed
150 // TODO add your handling code here:
151 boolean rt
= Utility
.updateNoticeDescription (selectednotice_id
,
152 textDescription
.getText());
154 JOptionPane
.showMessageDialog(this, ERROR_UPDATING
);
157 }//GEN-LAST:event_buttonUpdateActionPerformed
158 private static final String ERROR_UPDATING
= "Error in updating";
161 * @param args the command line arguments
163 public static void main(String args
[]) {
164 /* Set the Nimbus look and feel */
165 //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
166 /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
167 * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
170 for (javax
.swing
.UIManager
.LookAndFeelInfo info
: javax
.swing
.UIManager
.getInstalledLookAndFeels()) {
171 if ("Nimbus".equals(info
.getName())) {
172 javax
.swing
.UIManager
.setLookAndFeel(info
.getClassName());
176 } catch (ClassNotFoundException ex
) {
177 java
.util
.logging
.Logger
.getLogger(DescriptionDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
178 } catch (InstantiationException ex
) {
179 java
.util
.logging
.Logger
.getLogger(DescriptionDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
180 } catch (IllegalAccessException ex
) {
181 java
.util
.logging
.Logger
.getLogger(DescriptionDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
182 } catch (javax
.swing
.UnsupportedLookAndFeelException ex
) {
183 java
.util
.logging
.Logger
.getLogger(DescriptionDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
187 /* Create and display the dialog */
188 java
.awt
.EventQueue
.invokeLater(new Runnable() {
190 DescriptionDialog dialog
= new DescriptionDialog(new javax
.swing
.JFrame(), true);
191 dialog
.addWindowListener(new java
.awt
.event
.WindowAdapter() {
193 public void windowClosing(java
.awt
.event
.WindowEvent e
) {
197 dialog
.setVisible(true);
202 // Variables declaration - do not modify//GEN-BEGIN:variables
203 private javax
.swing
.JButton buttonCancel
;
204 private javax
.swing
.JButton buttonUpdate
;
205 private javax
.swing
.JLabel jLabel1
;
206 private javax
.swing
.JLabel jLabel2
;
207 private javax
.swing
.JLabel jLabel3
;
208 private javax
.swing
.JScrollPane jScrollPane1
;
209 private javax
.swing
.JTextArea textDescription
;
210 private javax
.swing
.JTextField textEntrustmentDate
;
211 private javax
.swing
.JTextField textReferenceNumber
;
212 // End of variables declaration//GEN-END:variables