KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.netbeans.modules.html.palette.items;
21 import java.awt.Dialog JavaDoc;
22 import java.awt.event.ActionEvent JavaDoc;
23 import java.awt.event.ActionListener JavaDoc;
24 import org.openide.DialogDescriptor;
25 import org.openide.DialogDisplayer;
26 import org.openide.util.NbBundle;
27
28
29
30
31 /**
32  *
33  * @author Libor Kotouc
34  */

35 public class BUTTONCustomizer extends javax.swing.JPanel JavaDoc {
36
37     private Dialog JavaDoc dialog = null;
38     private DialogDescriptor descriptor = null;
39     private boolean dialogOK = false;
40
41     BUTTON button;
42
43     /** Creates new form TABLECustomizerPanel */
44     public BUTTONCustomizer(BUTTON button) {
45         this.button = button;
46         
47         initComponents();
48     }
49     
50     public boolean showDialog() {
51         
52         dialogOK = false;
53         
54         String JavaDoc displayName = "";
55         try {
56             displayName = NbBundle.getBundle("org.netbeans.modules.html.palette.items.resources.Bundle").getString("NAME_html-BUTTON"); // NOI18N
57
}
58         catch (Exception JavaDoc e) {}
59         
60         descriptor = new DialogDescriptor
61                 (this, NbBundle.getMessage(BUTTONCustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true,
62                  DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION,
63                  new ActionListener JavaDoc() {
64                      public void actionPerformed(ActionEvent JavaDoc e) {
65                         if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
66                             evaluateInput();
67                             dialogOK = true;
68                         }
69                         dialog.dispose();
70              }
71          }
72                 );
73         
74         dialog = DialogDisplayer.getDefault().createDialog(descriptor);
75         dialog.setVisible(true);
76         repaint();
77         
78         return dialogOK;
79     }
80     
81     private void evaluateInput() {
82         
83         String JavaDoc value = jTextField1.getText();
84         button.setValue(value);
85         
86         if (jRadioButton1.isSelected())
87             button.setType(BUTTON.TYPE_SUBMIT);
88         else if (jRadioButton2.isSelected())
89             button.setType(BUTTON.TYPE_RESET);
90         else if (jRadioButton3.isSelected())
91             button.setType(BUTTON.TYPE_BUTTON);
92
93         button.setDisabled(jCheckBox1.isSelected());
94         
95         String JavaDoc name = jTextField2.getText();
96         button.setName(name);
97         
98     }
99     
100     /** This method is called from within the constructor to
101      * initialize the form.
102      * WARNING: Do NOT modify this code. The content of this method is
103      * always regenerated by the Form Editor.
104      */

105     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
106
private void initComponents() {
107         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
108
109         buttonGroup1 = new javax.swing.ButtonGroup JavaDoc();
110         jTextField1 = new javax.swing.JTextField JavaDoc();
111         jLabel1 = new javax.swing.JLabel JavaDoc();
112         jLabel2 = new javax.swing.JLabel JavaDoc();
113         jLabel3 = new javax.swing.JLabel JavaDoc();
114         jRadioButton1 = new javax.swing.JRadioButton JavaDoc();
115         jRadioButton2 = new javax.swing.JRadioButton JavaDoc();
116         jRadioButton3 = new javax.swing.JRadioButton JavaDoc();
117         jCheckBox1 = new javax.swing.JCheckBox JavaDoc();
118         jTextField2 = new javax.swing.JTextField JavaDoc();
119         jLabel4 = new javax.swing.JLabel JavaDoc();
120
121         setLayout(new java.awt.GridBagLayout JavaDoc());
122
123         jTextField1.setColumns(30);
124         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
125         gridBagConstraints.gridx = 1;
126         gridBagConstraints.gridy = 0;
127         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
128         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
129         gridBagConstraints.weightx = 1.0;
130         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 12);
131         add(jTextField1, gridBagConstraints);
132
133         jLabel1.setLabelFor(jTextField1);
134         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "LBL_BUTTON_Label"));
135         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
136         gridBagConstraints.gridx = 0;
137         gridBagConstraints.gridy = 0;
138         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
139         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
140         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
141         add(jLabel1, gridBagConstraints);
142         jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "ACSN_BUTTON_Label"));
143         jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "ACSD_BUTTON_Label"));
144
145         org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "LBL_BUTTON_Type"));
146         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
147         gridBagConstraints.gridx = 0;
148         gridBagConstraints.gridy = 1;
149         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
150         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
151         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
152         add(jLabel2, gridBagConstraints);
153         jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "ACSN_BUTTON_Type"));
154         jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "ACSD_BUTTON_Type"));
155
156         org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "LBL_BUTTON_InitState"));
157         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
158         gridBagConstraints.gridx = 0;
159         gridBagConstraints.gridy = 4;
160         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
161         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
162         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
163         add(jLabel3, gridBagConstraints);
164         jLabel3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "ACSN_BUTTON_InitState"));
165         jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "ACSD_BUTTON_InitState"));
166
167         buttonGroup1.add(jRadioButton1);
168         jRadioButton1.setSelected(true);
169         org.openide.awt.Mnemonics.setLocalizedText(jRadioButton1, org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "LBL_BUTTON_submit"));
170         jRadioButton1.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(0, 0, 0, 0)));
171         jRadioButton1.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
172         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
173         gridBagConstraints.gridx = 1;
174         gridBagConstraints.gridy = 1;
175         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
176         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
177         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 12);
178         add(jRadioButton1, gridBagConstraints);
179         jRadioButton1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "ACSN_BUTTON_submit"));
180         jRadioButton1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "ACSD_BUTTON_Submit"));
181
182         buttonGroup1.add(jRadioButton2);
183         org.openide.awt.Mnemonics.setLocalizedText(jRadioButton2, org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "LBL_BUTTON_reset"));
184         jRadioButton2.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(0, 0, 0, 0)));
185         jRadioButton2.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
186         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
187         gridBagConstraints.gridx = 1;
188         gridBagConstraints.gridy = 2;
189         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
190         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
191         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 12);
192         add(jRadioButton2, gridBagConstraints);
193         jRadioButton2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "ACSN_BUTTON_reset"));
194         jRadioButton2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "ACSD_BUTTON_Reset"));
195
196         buttonGroup1.add(jRadioButton3);
197         org.openide.awt.Mnemonics.setLocalizedText(jRadioButton3, org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "LBL_BUTTON_standard"));
198         jRadioButton3.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(0, 0, 0, 0)));
199         jRadioButton3.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
200         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
201         gridBagConstraints.gridx = 1;
202         gridBagConstraints.gridy = 3;
203         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
204         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
205         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 12);
206         add(jRadioButton3, gridBagConstraints);
207         jRadioButton3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "ACSN_BUTTON_standard"));
208         jRadioButton3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "ACSD_BUTTON_Standard"));
209
210         org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "LBL_BUTTON_disabled"));
211         jCheckBox1.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(0, 0, 0, 0)));
212         jCheckBox1.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
213         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
214         gridBagConstraints.gridx = 1;
215         gridBagConstraints.gridy = 4;
216         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
217         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
218         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 12);
219         add(jCheckBox1, gridBagConstraints);
220         jCheckBox1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "ACSN_BUTTON_disabled"));
221         jCheckBox1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "ACSD_BUTTON_disabled"));
222
223         jTextField2.setColumns(30);
224         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
225         gridBagConstraints.gridx = 1;
226         gridBagConstraints.gridy = 5;
227         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
228         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
229         gridBagConstraints.weighty = 1.0;
230         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 12, 12);
231         add(jTextField2, gridBagConstraints);
232
233         jLabel4.setLabelFor(jTextField2);
234         org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "LBL_BUTTON_Name"));
235         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
236         gridBagConstraints.gridx = 0;
237         gridBagConstraints.gridy = 5;
238         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
239         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
240         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 12, 0);
241         add(jLabel4, gridBagConstraints);
242         jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "ACSN_BUTTON_Name"));
243         jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BUTTONCustomizer.class, "ACSD_BUTTON_Name"));
244
245     }
246     // </editor-fold>//GEN-END:initComponents
247

248     
249     // Variables declaration - do not modify//GEN-BEGIN:variables
250
private javax.swing.ButtonGroup JavaDoc buttonGroup1;
251     private javax.swing.JCheckBox JavaDoc jCheckBox1;
252     private javax.swing.JLabel JavaDoc jLabel1;
253     private javax.swing.JLabel JavaDoc jLabel2;
254     private javax.swing.JLabel JavaDoc jLabel3;
255     private javax.swing.JLabel JavaDoc jLabel4;
256     private javax.swing.JRadioButton JavaDoc jRadioButton1;
257     private javax.swing.JRadioButton JavaDoc jRadioButton2;
258     private javax.swing.JRadioButton JavaDoc jRadioButton3;
259     private javax.swing.JTextField JavaDoc jTextField1;
260     private javax.swing.JTextField JavaDoc jTextField2;
261     // End of variables declaration//GEN-END:variables
262

263 }
264
Popular Tags