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 org.openide.DialogDescriptor; 25 import org.openide.DialogDisplayer; 26 import org.openide.util.NbBundle; 27 28 29 30 31 35 public class BUTTONCustomizer extends javax.swing.JPanel { 36 37 private Dialog dialog = null; 38 private DialogDescriptor descriptor = null; 39 private boolean dialogOK = false; 40 41 BUTTON button; 42 43 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 displayName = ""; 55 try { 56 displayName = NbBundle.getBundle("org.netbeans.modules.html.palette.items.resources.Bundle").getString("NAME_html-BUTTON"); } 58 catch (Exception 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 () { 64 public void actionPerformed(ActionEvent 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 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 name = jTextField2.getText(); 96 button.setName(name); 97 98 } 99 100 105 private void initComponents() { 107 java.awt.GridBagConstraints gridBagConstraints; 108 109 buttonGroup1 = new javax.swing.ButtonGroup (); 110 jTextField1 = new javax.swing.JTextField (); 111 jLabel1 = new javax.swing.JLabel (); 112 jLabel2 = new javax.swing.JLabel (); 113 jLabel3 = new javax.swing.JLabel (); 114 jRadioButton1 = new javax.swing.JRadioButton (); 115 jRadioButton2 = new javax.swing.JRadioButton (); 116 jRadioButton3 = new javax.swing.JRadioButton (); 117 jCheckBox1 = new javax.swing.JCheckBox (); 118 jTextField2 = new javax.swing.JTextField (); 119 jLabel4 = new javax.swing.JLabel (); 120 121 setLayout(new java.awt.GridBagLayout ()); 122 123 jTextField1.setColumns(30); 124 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 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 (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 (); 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 (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 (); 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 (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 (new java.awt.Insets (0, 0, 0, 0))); 171 jRadioButton1.setMargin(new java.awt.Insets (0, 0, 0, 0)); 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 (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 (new java.awt.Insets (0, 0, 0, 0))); 185 jRadioButton2.setMargin(new java.awt.Insets (0, 0, 0, 0)); 186 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (new java.awt.Insets (0, 0, 0, 0))); 199 jRadioButton3.setMargin(new java.awt.Insets (0, 0, 0, 0)); 200 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (new java.awt.Insets (0, 0, 0, 0))); 212 jCheckBox1.setMargin(new java.awt.Insets (0, 0, 0, 0)); 213 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 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 (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 (); 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 (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 248 249 private javax.swing.ButtonGroup buttonGroup1; 251 private javax.swing.JCheckBox jCheckBox1; 252 private javax.swing.JLabel jLabel1; 253 private javax.swing.JLabel jLabel2; 254 private javax.swing.JLabel jLabel3; 255 private javax.swing.JLabel jLabel4; 256 private javax.swing.JRadioButton jRadioButton1; 257 private javax.swing.JRadioButton jRadioButton2; 258 private javax.swing.JRadioButton jRadioButton3; 259 private javax.swing.JTextField jTextField1; 260 private javax.swing.JTextField jTextField2; 261 263 } 264 | Popular Tags |