1 19 20 21 package org.netbeans.modules.html.palette.items; 22 import java.awt.Dialog ; 23 import java.awt.event.ActionEvent ; 24 import java.awt.event.ActionListener ; 25 import javax.swing.JSpinner ; 26 import javax.swing.SpinnerNumberModel ; 27 import org.openide.DialogDescriptor; 28 import org.openide.DialogDisplayer; 29 import org.openide.util.NbBundle; 30 31 32 33 37 public class TABLECustomizer extends javax.swing.JPanel { 38 39 private Dialog dialog = null; 40 private DialogDescriptor descriptor = null; 41 private boolean dialogOK = false; 42 43 private TABLE table; 44 45 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 displayName = ""; 57 try { 58 displayName = NbBundle.getBundle("org.netbeans.modules.html.palette.items.resources.Bundle").getString("NAME_html-TABLE"); } 60 catch (Exception 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 () { 66 public void actionPerformed(ActionEvent 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 )jSpinner1.getValue()).intValue(); 86 table.setRows(rows); 87 88 int cols = ((Integer )jSpinner2.getValue()).intValue(); 89 table.setCols(cols); 90 91 int border = ((Integer )jSpinner3.getValue()).intValue(); 92 table.setBorder(border); 93 94 String width = jTextField1.getText(); 95 table.setWidth(width); 96 97 int cspac = ((Integer )jSpinner4.getValue()).intValue(); 98 table.setCspac(cspac); 99 100 int cpadd = ((Integer )jSpinner5.getValue()).intValue(); 101 table.setCpadd(cpadd); 102 103 } 104 105 110 private void initComponents() { 112 java.awt.GridBagConstraints gridBagConstraints; 113 114 jLabel1 = new javax.swing.JLabel (); 115 jLabel2 = new javax.swing.JLabel (); 116 jSpinner1 = new javax.swing.JSpinner (); 117 jSpinner2 = new javax.swing.JSpinner (); 118 jLabel3 = new javax.swing.JLabel (); 119 jLabel4 = new javax.swing.JLabel (); 120 jLabel5 = new javax.swing.JLabel (); 121 jLabel6 = new javax.swing.JLabel (); 122 jLabel7 = new javax.swing.JLabel (); 123 jLabel8 = new javax.swing.JLabel (); 124 jSpinner3 = new javax.swing.JSpinner (); 125 jTextField1 = new javax.swing.JTextField (); 126 jSpinner4 = new javax.swing.JSpinner (); 127 jSpinner5 = new javax.swing.JSpinner (); 128 129 setLayout(new java.awt.GridBagLayout ()); 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 (); 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 (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 (); 146 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 147 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 148 gridBagConstraints.insets = new java.awt.Insets (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 (table.getRows(), 0, Integer.MAX_VALUE, 1)); 154 jSpinner1.setEditor(new JSpinner.NumberEditor (jSpinner1, "#")); 155 jSpinner1.setValue(new Integer (table.getRows())); 156 gridBagConstraints = new java.awt.GridBagConstraints (); 157 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 158 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 159 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 18); 160 add(jSpinner1, gridBagConstraints); 161 162 jSpinner2.setModel(new SpinnerNumberModel (table.getCols(), 0, Integer.MAX_VALUE, 1)); 163 jSpinner2.setEditor(new JSpinner.NumberEditor (jSpinner2, "#")); 164 jSpinner2.setValue(new Integer (table.getCols())); 165 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 176 gridBagConstraints.gridx = 0; 177 gridBagConstraints.gridy = 2; 178 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 179 gridBagConstraints.insets = new java.awt.Insets (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 (); 187 gridBagConstraints.gridx = 0; 188 gridBagConstraints.gridy = 3; 189 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 190 gridBagConstraints.insets = new java.awt.Insets (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 (); 198 gridBagConstraints.gridx = 0; 199 gridBagConstraints.gridy = 4; 200 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 201 gridBagConstraints.insets = new java.awt.Insets (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 (); 209 gridBagConstraints.gridx = 0; 210 gridBagConstraints.gridy = 6; 211 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 212 gridBagConstraints.insets = new java.awt.Insets (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 (); 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 (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 (); 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 (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 (table.getBorder(), 0, Integer.MAX_VALUE, 1)); 242 jSpinner3.setEditor(new JSpinner.NumberEditor (jSpinner3, "#")); 243 jSpinner3.setValue(new Integer (table.getBorder())); 244 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (11, 12, 0, 18); 250 add(jSpinner3, gridBagConstraints); 251 252 jTextField1.setText(table.getWidth()); 253 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (5, 12, 0, 18); 259 add(jTextField1, gridBagConstraints); 260 261 jSpinner4.setModel(new SpinnerNumberModel (table.getCspac(), 0, Integer.MAX_VALUE, 1)); 262 jSpinner4.setEditor(new JSpinner.NumberEditor (jSpinner4, "#")); 263 jSpinner4.setValue(new Integer (table.getCspac())); 264 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (12, 12, 0, 18); 270 add(jSpinner4, gridBagConstraints); 271 272 jSpinner5.setModel(new SpinnerNumberModel (table.getCpadd(), 0, Integer.MAX_VALUE, 1)); 273 jSpinner5.setEditor(new JSpinner.NumberEditor (jSpinner5, "#")); 274 jSpinner5.setValue(new Integer (table.getCpadd())); 275 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (5, 12, 0, 18); 281 add(jSpinner5, gridBagConstraints); 282 283 } 285 286 private javax.swing.JLabel jLabel1; 288 private javax.swing.JLabel jLabel2; 289 private javax.swing.JLabel jLabel3; 290 private javax.swing.JLabel jLabel4; 291 private javax.swing.JLabel jLabel5; 292 private javax.swing.JLabel jLabel6; 293 private javax.swing.JLabel jLabel7; 294 private javax.swing.JLabel jLabel8; 295 private javax.swing.JSpinner jSpinner1; 296 private javax.swing.JSpinner jSpinner2; 297 private javax.swing.JSpinner jSpinner3; 298 private javax.swing.JSpinner jSpinner4; 299 private javax.swing.JSpinner jSpinner5; 300 private javax.swing.JTextField jTextField1; 301 303 } 304 | Popular Tags |