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.
12 public class StationerySettingsDialog
extends javax
.swing
.JDialog
{
15 * Creates new form StationerySettingsDialog
17 public StationerySettingsDialog(java
.awt
.Frame parent
, boolean modal
) {
20 textLeftHeader
.setText(Utility
.leftLetterHeader
);
21 textRightHeader
.setText(Utility
.rightLetterHeader
);
22 textSignatory
.setText(Utility
.signatoryName
);
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.
30 @SuppressWarnings("unchecked")
31 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
32 private void initComponents() {
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();
45 setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
46 setTitle("Stationery Settings");
47 setLocationByPlatform(true);
49 jLabel1
.setText("Letter Left Header");
51 textLeftHeader
.setColumns(20);
52 textLeftHeader
.setRows(5);
53 jScrollPane2
.setViewportView(textLeftHeader
);
55 jLabel2
.setText("Letter Right Header");
57 textRightHeader
.setColumns(20);
58 textRightHeader
.setRows(5);
59 jScrollPane1
.setViewportView(textRightHeader
);
61 jLabel3
.setText("Signatory Name");
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
);
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
);
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()
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
))
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
)
108 layout
.setVerticalGroup(
109 layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
110 .addGroup(layout
.createSequentialGroup()
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
))
131 }// </editor-fold>//GEN-END:initComponents
133 private void buttonCloseActionPerformed(java
.awt
.event
.ActionEvent evt
) {//GEN-FIRST:event_buttonCloseActionPerformed
134 // TODO add your handling code here:
136 }//GEN-LAST:event_buttonCloseActionPerformed
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
145 * @param args the command line arguments
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
154 for (javax
.swing
.UIManager
.LookAndFeelInfo info
: javax
.swing
.UIManager
.getInstalledLookAndFeels()) {
155 if ("Nimbus".equals(info
.getName())) {
156 javax
.swing
.UIManager
.setLookAndFeel(info
.getClassName());
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
);
171 /* Create and display the dialog */
172 java
.awt
.EventQueue
.invokeLater(new Runnable() {
174 StationerySettingsDialog dialog
= new StationerySettingsDialog(new javax
.swing
.JFrame(), true);
175 dialog
.addWindowListener(new java
.awt
.event
.WindowAdapter() {
177 public void windowClosing(java
.awt
.event
.WindowEvent e
) {
181 dialog
.setVisible(true);
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