Stationery Settings and Template for Bill
[habeas.git] / src / habeas / StationerySettingsDialog.java
1 /*
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.
5 */
6 package habeas;
7
8 /**
9 *
10 * @author hari
11 */
12 public class StationerySettingsDialog extends javax.swing.JDialog {
13
14 /**
15 * Creates new form StationerySettingsDialog
16 */
17 public StationerySettingsDialog(java.awt.Frame parent, boolean modal) {
18 super(parent, modal);
19 initComponents();
20 textLeftHeader.setText(Utility.leftLetterHeader);
21 textRightHeader.setText(Utility.rightLetterHeader);
22 textSignatory.setText(Utility.signatoryName);
23 }
24
25 /**
26 * This method is called from within the constructor to initialize the form.
27 * WARNING: Do NOT modify this code. The content of this method is always
28 * regenerated by the Form Editor.
29 */
30 @SuppressWarnings("unchecked")
31 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
32 private void initComponents() {
33
34 jLabel1 = new javax.swing.JLabel();
35 jScrollPane2 = new javax.swing.JScrollPane();
36 textLeftHeader = new javax.swing.JTextArea();
37 jLabel2 = new javax.swing.JLabel();
38 jScrollPane1 = new javax.swing.JScrollPane();
39 textRightHeader = new javax.swing.JTextArea();
40 jLabel3 = new javax.swing.JLabel();
41 textSignatory = new javax.swing.JTextField();
42 buttonApply = new javax.swing.JButton();
43 buttonClose = new javax.swing.JButton();
44
45 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
46 setTitle("Stationery Settings");
47 setLocationByPlatform(true);
48
49 jLabel1.setText("Letter Left Header");
50
51 textLeftHeader.setColumns(20);
52 textLeftHeader.setRows(5);
53 jScrollPane2.setViewportView(textLeftHeader);
54
55 jLabel2.setText("Letter Right Header");
56
57 textRightHeader.setColumns(20);
58 textRightHeader.setRows(5);
59 jScrollPane1.setViewportView(textRightHeader);
60
61 jLabel3.setText("Signatory Name");
62
63 buttonApply.setMnemonic('A');
64 buttonApply.setText("Apply");
65 buttonApply.addActionListener(new java.awt.event.ActionListener() {
66 public void actionPerformed(java.awt.event.ActionEvent evt) {
67 buttonApplyActionPerformed(evt);
68 }
69 });
70
71 buttonClose.setMnemonic('c');
72 buttonClose.setText("Close");
73 buttonClose.addActionListener(new java.awt.event.ActionListener() {
74 public void actionPerformed(java.awt.event.ActionEvent evt) {
75 buttonCloseActionPerformed(evt);
76 }
77 });
78
79 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
80 getContentPane().setLayout(layout);
81 layout.setHorizontalGroup(
82 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
83 .addGroup(layout.createSequentialGroup()
84 .addContainerGap()
85 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
86 .addGroup(layout.createSequentialGroup()
87 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
88 .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 209, Short.MAX_VALUE)
89 .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
90 .addGap(220, 220, 220))
91 .addGroup(layout.createSequentialGroup()
92 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
93 .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING)
94 .addComponent(jScrollPane1))
95 .addContainerGap())
96 .addGroup(layout.createSequentialGroup()
97 .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
98 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
99 .addComponent(textSignatory)
100 .addContainerGap())))
101 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
102 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
103 .addComponent(buttonApply, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
104 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
105 .addComponent(buttonClose, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
106 .addContainerGap())
107 );
108 layout.setVerticalGroup(
109 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
110 .addGroup(layout.createSequentialGroup()
111 .addContainerGap()
112 .addComponent(jLabel1)
113 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
114 .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
115 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
116 .addComponent(jLabel2)
117 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
118 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
119 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
120 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
121 .addComponent(jLabel3)
122 .addComponent(textSignatory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
123 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, Short.MAX_VALUE)
124 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
125 .addComponent(buttonApply)
126 .addComponent(buttonClose))
127 .addContainerGap())
128 );
129
130 pack();
131 }// </editor-fold>//GEN-END:initComponents
132
133 private void buttonCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCloseActionPerformed
134 // TODO add your handling code here:
135 dispose ();
136 }//GEN-LAST:event_buttonCloseActionPerformed
137
138 private void buttonApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonApplyActionPerformed
139 // TODO add your handling code here:
140 Utility.saveStationerySettings(textLeftHeader.getText(),
141 textRightHeader.getText(), textSignatory.getText());
142 }//GEN-LAST:event_buttonApplyActionPerformed
143
144 /**
145 * @param args the command line arguments
146 */
147 public static void main(String args[]) {
148 /* Set the Nimbus look and feel */
149 //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
150 /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
151 * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
152 */
153 try {
154 for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
155 if ("Nimbus".equals(info.getName())) {
156 javax.swing.UIManager.setLookAndFeel(info.getClassName());
157 break;
158 }
159 }
160 } catch (ClassNotFoundException ex) {
161 java.util.logging.Logger.getLogger(StationerySettingsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
162 } catch (InstantiationException ex) {
163 java.util.logging.Logger.getLogger(StationerySettingsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
164 } catch (IllegalAccessException ex) {
165 java.util.logging.Logger.getLogger(StationerySettingsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
166 } catch (javax.swing.UnsupportedLookAndFeelException ex) {
167 java.util.logging.Logger.getLogger(StationerySettingsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
168 }
169 //</editor-fold>
170
171 /* Create and display the dialog */
172 java.awt.EventQueue.invokeLater(new Runnable() {
173 public void run() {
174 StationerySettingsDialog dialog = new StationerySettingsDialog(new javax.swing.JFrame(), true);
175 dialog.addWindowListener(new java.awt.event.WindowAdapter() {
176 @Override
177 public void windowClosing(java.awt.event.WindowEvent e) {
178 System.exit(0);
179 }
180 });
181 dialog.setVisible(true);
182 }
183 });
184 }
185
186 // Variables declaration - do not modify//GEN-BEGIN:variables
187 private javax.swing.JButton buttonApply;
188 private javax.swing.JButton buttonClose;
189 private javax.swing.JLabel jLabel1;
190 private javax.swing.JLabel jLabel2;
191 private javax.swing.JLabel jLabel3;
192 private javax.swing.JScrollPane jScrollPane1;
193 private javax.swing.JScrollPane jScrollPane2;
194 private javax.swing.JTextArea textLeftHeader;
195 private javax.swing.JTextArea textRightHeader;
196 private javax.swing.JTextField textSignatory;
197 // End of variables declaration//GEN-END:variables
198 }