1 19 20 package org.netbeans.modules.html.palette.items; 21 import java.awt.Dialog ; 22 import java.awt.event.ActionEvent ; 23 import java.awt.event.ActionListener ; 24 import javax.swing.DefaultComboBoxModel ; 25 import org.openide.DialogDescriptor; 26 import org.openide.DialogDisplayer; 27 import org.openide.util.NbBundle; 28 29 30 31 32 36 public class RADIOCustomizer extends javax.swing.JPanel { 37 38 private Dialog 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 (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 displayName = ""; 59 try { 60 displayName = NbBundle.getBundle("org.netbeans.modules.html.palette.items.resources.Bundle").getString("NAME_html-RADIO"); } 62 catch (Exception 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 () { 68 public void actionPerformed(ActionEvent 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) radio.setGroup(jComboBox1.getSelectedItem().toString()); 91 92 String value = jTextField2.getText(); 93 radio.setValue(value); 94 95 radio.setSelected(jCheckBox1.isSelected()); 96 97 radio.setDisabled(jCheckBox2.isSelected()); 98 99 } 100 101 106 private void initComponents() { 108 java.awt.GridBagConstraints gridBagConstraints; 109 110 buttonGroup1 = new javax.swing.ButtonGroup (); 111 jLabel1 = new javax.swing.JLabel (); 112 jCheckBox1 = new javax.swing.JCheckBox (); 113 jCheckBox2 = new javax.swing.JCheckBox (); 114 jLabel5 = new javax.swing.JLabel (); 115 jTextField2 = new javax.swing.JTextField (); 116 jLabel2 = new javax.swing.JLabel (); 117 jComboBox1 = new javax.swing.JComboBox (); 118 119 setLayout(new java.awt.GridBagLayout ()); 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 (); 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 (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 (new java.awt.Insets (0, 0, 0, 0))); 135 jCheckBox1.setMargin(new java.awt.Insets (0, 0, 0, 0)); 136 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (new java.awt.Insets (0, 0, 0, 0))); 148 jCheckBox2.setMargin(new java.awt.Insets (0, 0, 0, 0)); 149 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 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 (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 (); 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 (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 (); 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 (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 (); 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 (12, 12, 0, 12); 198 add(jComboBox1, gridBagConstraints); 199 200 } 201 203 204 private javax.swing.ButtonGroup buttonGroup1; 206 private javax.swing.JCheckBox jCheckBox1; 207 private javax.swing.JCheckBox jCheckBox2; 208 private javax.swing.JComboBox jComboBox1; 209 private javax.swing.JLabel jLabel1; 210 private javax.swing.JLabel jLabel2; 211 private javax.swing.JLabel jLabel5; 212 private javax.swing.JTextField jTextField2; 213 215 } 216 | Popular Tags |