KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.swing.DefaultComboBoxModel JavaDoc;
25 import org.openide.DialogDescriptor;
26 import org.openide.DialogDisplayer;
27 import org.openide.util.NbBundle;
28
29
30
31
32 /**
33  *
34  * @author Libor Kotouc
35  */

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

106     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
107
private void initComponents() {
108         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
109
110         buttonGroup1 = new javax.swing.ButtonGroup JavaDoc();
111         jLabel1 = new javax.swing.JLabel JavaDoc();
112         jCheckBox1 = new javax.swing.JCheckBox JavaDoc();
113         jCheckBox2 = new javax.swing.JCheckBox JavaDoc();
114         jLabel5 = new javax.swing.JLabel JavaDoc();
115         jTextField2 = new javax.swing.JTextField JavaDoc();
116         jLabel2 = new javax.swing.JLabel JavaDoc();
117         jComboBox1 = new javax.swing.JComboBox JavaDoc();
118
119         setLayout(new java.awt.GridBagLayout JavaDoc());
120
121         jLabel1.setLabelFor(jComboBox1);
122         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(RADIOCustomizer.class, "LBL_RADIO_Group"));
123         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
124         gridBagConstraints.gridx = 0;
125         gridBagConstraints.gridy = 0;
126         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
127         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
128         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
129         add(jLabel1, gridBagConstraints);
130         jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(RADIOCustomizer.class, "ACSN_RADIO_Group"));
131         jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(RADIOCustomizer.class, "ACSD_RADIO_Group"));
132
133         org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(RADIOCustomizer.class, "LBL_RADIO_selected"));
134         jCheckBox1.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(0, 0, 0, 0)));
135         jCheckBox1.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
136         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
137         gridBagConstraints.gridx = 1;
138         gridBagConstraints.gridy = 2;
139         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
140         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
141         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 12);
142         add(jCheckBox1, gridBagConstraints);
143         jCheckBox1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(RADIOCustomizer.class, "ACSN_RADIO_selected"));
144         jCheckBox1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(RADIOCustomizer.class, "ACSD_RADIO_selected"));
145
146         org.openide.awt.Mnemonics.setLocalizedText(jCheckBox2, org.openide.util.NbBundle.getMessage(RADIOCustomizer.class, "LBL_RADIO_disabled"));
147         jCheckBox2.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(0, 0, 0, 0)));
148         jCheckBox2.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
149         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
150         gridBagConstraints.gridx = 1;
151         gridBagConstraints.gridy = 3;
152         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
153         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
154         gridBagConstraints.weighty = 1.0;
155         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 12, 12);
156         add(jCheckBox2, gridBagConstraints);
157         jCheckBox2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(RADIOCustomizer.class, "ACSN_RADIO_disabled"));
158         jCheckBox2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(RADIOCustomizer.class, "ACSD_RADIO_disabled"));
159
160         org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(RADIOCustomizer.class, "LBL_RADIO_"));
161         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
162         gridBagConstraints.gridx = 0;
163         gridBagConstraints.gridy = 2;
164         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
165         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
166         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
167         add(jLabel5, gridBagConstraints);
168         jLabel5.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(RADIOCustomizer.class, "ACSN_RADIO_State"));
169         jLabel5.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(RADIOCustomizer.class, "ACSD_RADIO_State"));
170
171         jTextField2.setColumns(30);
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(5, 12, 0, 12);
178         add(jTextField2, gridBagConstraints);
179
180         jLabel2.setLabelFor(jTextField2);
181         org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(RADIOCustomizer.class, "LBL_RADIO_Value"));
182         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
183         gridBagConstraints.gridx = 0;
184         gridBagConstraints.gridy = 1;
185         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
186         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
187         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
188         add(jLabel2, gridBagConstraints);
189         jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(RADIOCustomizer.class, "ACSN_RADIO_Value"));
190         jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(RADIOCustomizer.class, "ACSD_RADIO_Value"));
191
192         jComboBox1.setEditable(true);
193         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
194         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
195         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
196         gridBagConstraints.weightx = 1.0;
197         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 12);
198         add(jComboBox1, gridBagConstraints);
199
200     }
201     // </editor-fold>//GEN-END:initComponents
202

203     
204     // Variables declaration - do not modify//GEN-BEGIN:variables
205
private javax.swing.ButtonGroup JavaDoc buttonGroup1;
206     private javax.swing.JCheckBox JavaDoc jCheckBox1;
207     private javax.swing.JCheckBox JavaDoc jCheckBox2;
208     private javax.swing.JComboBox JavaDoc jComboBox1;
209     private javax.swing.JLabel JavaDoc jLabel1;
210     private javax.swing.JLabel JavaDoc jLabel2;
211     private javax.swing.JLabel JavaDoc jLabel5;
212     private javax.swing.JTextField JavaDoc jTextField2;
213     // End of variables declaration//GEN-END:variables
214

215 }
216
Popular Tags