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