KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > html > palette > items > TABLECustomizer


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20
21 package org.netbeans.modules.html.palette.items;
22 import java.awt.Dialog JavaDoc;
23 import java.awt.event.ActionEvent JavaDoc;
24 import java.awt.event.ActionListener JavaDoc;
25 import javax.swing.JSpinner JavaDoc;
26 import javax.swing.SpinnerNumberModel JavaDoc;
27 import org.openide.DialogDescriptor;
28 import org.openide.DialogDisplayer;
29 import org.openide.util.NbBundle;
30
31
32
33 /**
34  *
35  * @author Libor Kotouc
36  */

37 public class TABLECustomizer extends javax.swing.JPanel JavaDoc {
38
39     private Dialog JavaDoc dialog = null;
40     private DialogDescriptor descriptor = null;
41     private boolean dialogOK = false;
42
43     private TABLE table;
44             
45     /** Creates new form TABLE_1Panel */
46     public TABLECustomizer(TABLE table) {
47         this.table = table;
48
49         initComponents();
50     }
51     
52     public boolean showDialog() {
53         
54         dialogOK = false;
55         
56         String JavaDoc displayName = "";
57         try {
58             displayName = NbBundle.getBundle("org.netbeans.modules.html.palette.items.resources.Bundle").getString("NAME_html-TABLE"); // NOI18N
59
}
60         catch (Exception JavaDoc e) {}
61         
62         descriptor = new DialogDescriptor
63                 (this, NbBundle.getMessage(TABLECustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true,
64                  DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION,
65                  new ActionListener JavaDoc() {
66                      public void actionPerformed(ActionEvent JavaDoc e) {
67                         if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
68                             evaluateInput();
69                             dialogOK = true;
70                         }
71                         dialog.dispose();
72              }
73          }
74                 );
75         
76         dialog = DialogDisplayer.getDefault().createDialog(descriptor);
77         dialog.setVisible(true);
78         repaint();
79         
80         return dialogOK;
81     }
82     
83     private void evaluateInput() {
84         
85         int rows = ((Integer JavaDoc)jSpinner1.getValue()).intValue();
86         table.setRows(rows);
87
88         int cols = ((Integer JavaDoc)jSpinner2.getValue()).intValue();
89         table.setCols(cols);
90
91         int border = ((Integer JavaDoc)jSpinner3.getValue()).intValue();
92         table.setBorder(border);
93
94         String JavaDoc width = jTextField1.getText();
95         table.setWidth(width);
96
97         int cspac = ((Integer JavaDoc)jSpinner4.getValue()).intValue();
98         table.setCspac(cspac);
99
100         int cpadd = ((Integer JavaDoc)jSpinner5.getValue()).intValue();
101         table.setCpadd(cpadd);
102         
103     }
104     
105     /** This method is called from within the constructor to
106      * initialize the form.
107      * WARNING: Do NOT modify this code. The content of this method is
108      * always regenerated by the Form Editor.
109      */

110     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
111
private void initComponents() {
112         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
113
114         jLabel1 = new javax.swing.JLabel JavaDoc();
115         jLabel2 = new javax.swing.JLabel JavaDoc();
116         jSpinner1 = new javax.swing.JSpinner JavaDoc();
117         jSpinner2 = new javax.swing.JSpinner JavaDoc();
118         jLabel3 = new javax.swing.JLabel JavaDoc();
119         jLabel4 = new javax.swing.JLabel JavaDoc();
120         jLabel5 = new javax.swing.JLabel JavaDoc();
121         jLabel6 = new javax.swing.JLabel JavaDoc();
122         jLabel7 = new javax.swing.JLabel JavaDoc();
123         jLabel8 = new javax.swing.JLabel JavaDoc();
124         jSpinner3 = new javax.swing.JSpinner JavaDoc();
125         jTextField1 = new javax.swing.JTextField JavaDoc();
126         jSpinner4 = new javax.swing.JSpinner JavaDoc();
127         jSpinner5 = new javax.swing.JSpinner JavaDoc();
128
129         setLayout(new java.awt.GridBagLayout JavaDoc());
130
131         jLabel1.setLabelFor(jSpinner2);
132         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "LBL_TABLE_Columns"));
133         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
134         gridBagConstraints.gridx = 0;
135         gridBagConstraints.gridy = 1;
136         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
137         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
138         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
139         add(jLabel1, gridBagConstraints);
140         jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "ACSN_TABLE_Columns"));
141         jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "ACSD_TABLE_Columns"));
142
143         jLabel2.setLabelFor(jSpinner1);
144         org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "LBL_TABLE_Rows"));
145         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
146         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
147         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
148         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
149         add(jLabel2, gridBagConstraints);
150         jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "ACSN_TABLE_Rows"));
151         jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "ACSD_TABLE_Rows"));
152
153         jSpinner1.setModel(new SpinnerNumberModel JavaDoc(table.getRows(), 0, Integer.MAX_VALUE, 1));
154         jSpinner1.setEditor(new JSpinner.NumberEditor JavaDoc(jSpinner1, "#"));
155         jSpinner1.setValue(new Integer JavaDoc(table.getRows()));
156         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
157         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
158         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
159         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 18);
160         add(jSpinner1, gridBagConstraints);
161
162         jSpinner2.setModel(new SpinnerNumberModel JavaDoc(table.getCols(), 0, Integer.MAX_VALUE, 1));
163         jSpinner2.setEditor(new JSpinner.NumberEditor JavaDoc(jSpinner2, "#"));
164         jSpinner2.setValue(new Integer JavaDoc(table.getCols()));
165         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
166         gridBagConstraints.gridx = 1;
167         gridBagConstraints.gridy = 1;
168         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
169         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
170         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 18);
171         add(jSpinner2, gridBagConstraints);
172
173         jLabel3.setLabelFor(jSpinner3);
174         org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "LBL_TABLE_Border"));
175         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
176         gridBagConstraints.gridx = 0;
177         gridBagConstraints.gridy = 2;
178         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
179         gridBagConstraints.insets = new java.awt.Insets JavaDoc(11, 12, 0, 0);
180         add(jLabel3, gridBagConstraints);
181         jLabel3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "ACSN_TABLE_Border"));
182         jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "ACSD_TABLE_Border"));
183
184         jLabel4.setLabelFor(jTextField1);
185         org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "LBL_TABLE_Width"));
186         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
187         gridBagConstraints.gridx = 0;
188         gridBagConstraints.gridy = 3;
189         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
190         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
191         add(jLabel4, gridBagConstraints);
192         jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "ACSN_TABLE_Width"));
193         jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "ACSD_TABLE_Width"));
194
195         jLabel5.setLabelFor(jSpinner4);
196         org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "LBL_TABLE_Spacing"));
197         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
198         gridBagConstraints.gridx = 0;
199         gridBagConstraints.gridy = 4;
200         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
201         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
202         add(jLabel5, gridBagConstraints);
203         jLabel5.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "ACSN_TABLE_Spacing"));
204         jLabel5.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "ACSD_TABLE_Spacing"));
205
206         jLabel6.setLabelFor(jSpinner5);
207         org.openide.awt.Mnemonics.setLocalizedText(jLabel6, org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "LBL_TABLE_Padding"));
208         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
209         gridBagConstraints.gridx = 0;
210         gridBagConstraints.gridy = 6;
211         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
212         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
213         add(jLabel6, gridBagConstraints);
214         jLabel6.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "ACSN_TABLE_Padding"));
215         jLabel6.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "ACSD_TABLE_Padding"));
216
217         org.openide.awt.Mnemonics.setLocalizedText(jLabel7, org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "LBL_TABLE_SpacingHelp"));
218         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
219         gridBagConstraints.gridx = 1;
220         gridBagConstraints.gridy = 5;
221         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
222         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
223         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 18);
224         add(jLabel7, gridBagConstraints);
225         jLabel7.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "ACSN_TABLE_SpacingHelp"));
226         jLabel7.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "ACSD_TABLE_SpacingHelp"));
227
228         org.openide.awt.Mnemonics.setLocalizedText(jLabel8, org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "LBL_TABLE_PaddingHelp"));
229         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
230         gridBagConstraints.gridx = 1;
231         gridBagConstraints.gridy = 7;
232         gridBagConstraints.gridwidth = 2;
233         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
234         gridBagConstraints.weightx = 1.0;
235         gridBagConstraints.weighty = 1.0;
236         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 12, 18);
237         add(jLabel8, gridBagConstraints);
238         jLabel8.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "ACSN_TABLE_PaddingHelp"));
239         jLabel8.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TABLECustomizer.class, "ACSD_TABLE_PaddingHelp"));
240
241         jSpinner3.setModel(new SpinnerNumberModel JavaDoc(table.getBorder(), 0, Integer.MAX_VALUE, 1));
242         jSpinner3.setEditor(new JSpinner.NumberEditor JavaDoc(jSpinner3, "#"));
243         jSpinner3.setValue(new Integer JavaDoc(table.getBorder()));
244         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
245         gridBagConstraints.gridx = 1;
246         gridBagConstraints.gridy = 2;
247         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
248         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
249         gridBagConstraints.insets = new java.awt.Insets JavaDoc(11, 12, 0, 18);
250         add(jSpinner3, gridBagConstraints);
251
252         jTextField1.setText(table.getWidth());
253         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
254         gridBagConstraints.gridx = 1;
255         gridBagConstraints.gridy = 3;
256         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
257         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
258         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 18);
259         add(jTextField1, gridBagConstraints);
260
261         jSpinner4.setModel(new SpinnerNumberModel JavaDoc(table.getCspac(), 0, Integer.MAX_VALUE, 1));
262         jSpinner4.setEditor(new JSpinner.NumberEditor JavaDoc(jSpinner4, "#"));
263         jSpinner4.setValue(new Integer JavaDoc(table.getCspac()));
264         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
265         gridBagConstraints.gridx = 1;
266         gridBagConstraints.gridy = 4;
267         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
268         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
269         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 18);
270         add(jSpinner4, gridBagConstraints);
271
272         jSpinner5.setModel(new SpinnerNumberModel JavaDoc(table.getCpadd(), 0, Integer.MAX_VALUE, 1));
273         jSpinner5.setEditor(new JSpinner.NumberEditor JavaDoc(jSpinner5, "#"));
274         jSpinner5.setValue(new Integer JavaDoc(table.getCpadd()));
275         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
276         gridBagConstraints.gridx = 1;
277         gridBagConstraints.gridy = 6;
278         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
279         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
280         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 18);
281         add(jSpinner5, gridBagConstraints);
282
283     }// </editor-fold>//GEN-END:initComponents
284

285     
286     // Variables declaration - do not modify//GEN-BEGIN:variables
287
private javax.swing.JLabel JavaDoc jLabel1;
288     private javax.swing.JLabel JavaDoc jLabel2;
289     private javax.swing.JLabel JavaDoc jLabel3;
290     private javax.swing.JLabel JavaDoc jLabel4;
291     private javax.swing.JLabel JavaDoc jLabel5;
292     private javax.swing.JLabel JavaDoc jLabel6;
293     private javax.swing.JLabel JavaDoc jLabel7;
294     private javax.swing.JLabel JavaDoc jLabel8;
295     private javax.swing.JSpinner JavaDoc jSpinner1;
296     private javax.swing.JSpinner JavaDoc jSpinner2;
297     private javax.swing.JSpinner JavaDoc jSpinner3;
298     private javax.swing.JSpinner JavaDoc jSpinner4;
299     private javax.swing.JSpinner JavaDoc jSpinner5;
300     private javax.swing.JTextField JavaDoc jTextField1;
301     // End of variables declaration//GEN-END:variables
302

303 }
304
Popular Tags