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 javax
.swing
.JOptionPane
;
14 public class DraftStatusDialog
extends javax
.swing
.JDialog
{
16 private int selectednotice_id
;
19 * Creates new form DraftStatusDialog
22 public DraftStatusDialog(java
.awt
.Frame parent
, boolean modal
) {
27 public void setFields (int selid
, boolean created
, boolean approved
) {
28 selectednotice_id
= selid
;
29 checkDraftCreated
.setSelected(created
);
30 checkDraftApproved
.setSelected(approved
);
34 * This method is called from within the constructor to initialize the form.
35 * WARNING: Do NOT modify this code. The content of this method is always
36 * regenerated by the Form Editor.
38 @SuppressWarnings("unchecked")
39 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
40 private void initComponents() {
42 checkDraftCreated
= new javax
.swing
.JCheckBox();
43 checkDraftApproved
= new javax
.swing
.JCheckBox();
44 buttonUpdate
= new javax
.swing
.JButton();
45 buttonCancel
= new javax
.swing
.JButton();
47 setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
48 setTitle("Draft Status");
49 setLocationByPlatform(true);
51 checkDraftCreated
.setText("Draft Created");
53 checkDraftApproved
.setText("Draft Approved");
55 buttonUpdate
.setMnemonic('U');
56 buttonUpdate
.setText("Update");
57 buttonUpdate
.addActionListener(new java
.awt
.event
.ActionListener() {
58 public void actionPerformed(java
.awt
.event
.ActionEvent evt
) {
59 buttonUpdateActionPerformed(evt
);
63 buttonCancel
.setMnemonic('c');
64 buttonCancel
.setText("Cancel");
65 buttonCancel
.addActionListener(new java
.awt
.event
.ActionListener() {
66 public void actionPerformed(java
.awt
.event
.ActionEvent evt
) {
67 buttonCancelActionPerformed(evt
);
71 javax
.swing
.GroupLayout layout
= new javax
.swing
.GroupLayout(getContentPane());
72 getContentPane().setLayout(layout
);
73 layout
.setHorizontalGroup(
74 layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
75 .addGroup(layout
.createSequentialGroup()
77 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
, false)
78 .addComponent(checkDraftCreated
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, Short
.MAX_VALUE
)
79 .addComponent(checkDraftApproved
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, 224, Short
.MAX_VALUE
))
80 .addContainerGap(javax
.swing
.GroupLayout
.DEFAULT_SIZE
, Short
.MAX_VALUE
))
81 .addGroup(javax
.swing
.GroupLayout
.Alignment
.TRAILING
, layout
.createSequentialGroup()
82 .addContainerGap(195, Short
.MAX_VALUE
)
83 .addComponent(buttonUpdate
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, 92, javax
.swing
.GroupLayout
.PREFERRED_SIZE
)
84 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.RELATED
)
85 .addComponent(buttonCancel
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, 80, javax
.swing
.GroupLayout
.PREFERRED_SIZE
)
88 layout
.setVerticalGroup(
89 layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
90 .addGroup(layout
.createSequentialGroup()
92 .addComponent(checkDraftCreated
)
93 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.UNRELATED
)
94 .addComponent(checkDraftApproved
)
95 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.RELATED
, 22, Short
.MAX_VALUE
)
96 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.BASELINE
)
97 .addComponent(buttonUpdate
)
98 .addComponent(buttonCancel
))
103 }// </editor-fold>//GEN-END:initComponents
105 private void buttonCancelActionPerformed(java
.awt
.event
.ActionEvent evt
) {//GEN-FIRST:event_buttonCancelActionPerformed
106 // TODO add your handling code here:
108 }//GEN-LAST:event_buttonCancelActionPerformed
110 private void buttonUpdateActionPerformed(java
.awt
.event
.ActionEvent evt
) {//GEN-FIRST:event_buttonUpdateActionPerformed
111 // TODO add your handling code here:
112 boolean rt
= Utility
.updateNoticeDraftStatus (selectednotice_id
,
113 checkDraftCreated
.isSelected(), checkDraftApproved
.isSelected());
116 JOptionPane
.showMessageDialog(this, ERROR_UPDATING
);
119 }//GEN-LAST:event_buttonUpdateActionPerformed
120 private static final String ERROR_UPDATING
= "Error updating";
123 * @param args the command line arguments
125 public static void main(String args
[]) {
126 /* Set the Nimbus look and feel */
127 //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
128 /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
129 * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
132 for (javax
.swing
.UIManager
.LookAndFeelInfo info
: javax
.swing
.UIManager
.getInstalledLookAndFeels()) {
133 if ("Nimbus".equals(info
.getName())) {
134 javax
.swing
.UIManager
.setLookAndFeel(info
.getClassName());
138 } catch (ClassNotFoundException ex
) {
139 java
.util
.logging
.Logger
.getLogger(DraftStatusDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
140 } catch (InstantiationException ex
) {
141 java
.util
.logging
.Logger
.getLogger(DraftStatusDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
142 } catch (IllegalAccessException ex
) {
143 java
.util
.logging
.Logger
.getLogger(DraftStatusDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
144 } catch (javax
.swing
.UnsupportedLookAndFeelException ex
) {
145 java
.util
.logging
.Logger
.getLogger(DraftStatusDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
149 /* Create and display the dialog */
150 java
.awt
.EventQueue
.invokeLater(new Runnable() {
152 DraftStatusDialog dialog
= new DraftStatusDialog(new javax
.swing
.JFrame(), true);
153 dialog
.addWindowListener(new java
.awt
.event
.WindowAdapter() {
155 public void windowClosing(java
.awt
.event
.WindowEvent e
) {
159 dialog
.setVisible(true);
164 // Variables declaration - do not modify//GEN-BEGIN:variables
165 private javax
.swing
.JButton buttonCancel
;
166 private javax
.swing
.JButton buttonUpdate
;
167 private javax
.swing
.JCheckBox checkDraftApproved
;
168 private javax
.swing
.JCheckBox checkDraftCreated
;
169 // End of variables declaration//GEN-END:variables