1 19 20 package org.netbeans.modules.form.layoutsupport.delegates; 21 22 import java.util.ResourceBundle ; 23 24 import javax.swing.*; 25 import javax.swing.border.TitledBorder ; 26 27 import org.openide.util.Utilities; 28 29 32 33 public class GridBagControlCenter extends javax.swing.JPanel { 34 35 private GridBagCustomizer customizer; 36 37 private ResourceBundle bundle; 38 39 private ActionL actionLsnr; 40 41 static final long serialVersionUID =-3758289034173265028L; 42 43 public GridBagControlCenter(GridBagCustomizer customizer) { 44 bundle = GridBagLayoutSupport.getBundleHack(); 45 46 initComponents(); 47 48 ButtonGroup anchorGroup = new ButtonGroup(); 49 50 anchorGroup.add(nwButton); 51 anchorGroup.add(nButton); 52 anchorGroup.add(neButton); 53 anchorGroup.add(wButton); 54 anchorGroup.add(cButton); 55 anchorGroup.add(eButton); 56 anchorGroup.add(swButton); 57 anchorGroup.add(sButton); 58 anchorGroup.add(seButton); 59 60 61 63 ((TitledBorder )anchorPanel.getBorder()).setTitle(bundle.getString("CTL_GBC_anchorPanel")); 64 ((TitledBorder )fillPanel.getBorder()).setTitle(bundle.getString("CTL_GBC_fillPanel")); 65 ((TitledBorder )ipadPanel.getBorder()).setTitle(bundle.getString("CTL_GBC_ipadPanel")); 66 ((TitledBorder )insetsPanel.getBorder()).setTitle(bundle.getString("CTL_GBC_insetsPanel")); 67 ((TitledBorder )gridSizePanel.getBorder()).setTitle(bundle.getString("CTL_GBC_gridSizePanel")); 68 69 70 nwButton.setToolTipText(bundle.getString("CTL_GBC_anchor.NW")); 71 nButton.setToolTipText(bundle.getString("CTL_GBC_anchor.N")); 72 neButton.setToolTipText(bundle.getString("CTL_GBC_anchor.NE")); 73 wButton.setToolTipText(bundle.getString("CTL_GBC_anchor.W")); 74 cButton.setToolTipText(bundle.getString("CTL_GBC_anchor.C")); 75 eButton.setToolTipText(bundle.getString("CTL_GBC_anchor.E")); 76 swButton.setToolTipText(bundle.getString("CTL_GBC_anchor.SW")); 77 sButton.setToolTipText(bundle.getString("CTL_GBC_anchor.S")); 78 seButton.setToolTipText(bundle.getString("CTL_GBC_anchor.SE")); 79 80 horizontalFillButton.setToolTipText(bundle.getString("CTL_GBC_fill.H")); 81 verticalFillButton.setToolTipText(bundle.getString("CTL_GBC_fill.V")); 82 83 ipadHMButton.setToolTipText(bundle.getString("CTL_GBC_ipad.HM")); 84 ipadHPButton.setToolTipText(bundle.getString("CTL_GBC_ipad.HP")); 85 ipadVMButton.setToolTipText(bundle.getString("CTL_GBC_ipad.VM")); 86 ipadVPButton.setToolTipText(bundle.getString("CTL_GBC_ipad.VP")); 87 88 topMButton.setToolTipText(bundle.getString("CTL_GBC_insets.topM")); 89 topPButton.setToolTipText(bundle.getString("CTL_GBC_insets.topP")); 90 leftPButton.setToolTipText(bundle.getString("CTL_GBC_insets.leftP")); 91 leftMButton.setToolTipText(bundle.getString("CTL_GBC_insets.leftM")); 92 rightMButton.setToolTipText(bundle.getString("CTL_GBC_insets.rightM")); 93 rightPButton.setToolTipText(bundle.getString("CTL_GBC_insets.rightP")); 94 bottomMButton.setToolTipText(bundle.getString("CTL_GBC_insets.bottomM")); 95 bottomPButton.setToolTipText(bundle.getString("CTL_GBC_insets.bottomP")); 96 HMButton.setToolTipText(bundle.getString("CTL_GBC_insets.HM")); 97 HPButton.setToolTipText(bundle.getString("CTL_GBC_insets.HP")); 98 VMButton.setToolTipText(bundle.getString("CTL_GBC_insets.VM")); 99 VPButton.setToolTipText(bundle.getString("CTL_GBC_insets.VP")); 100 BMButton.setToolTipText(bundle.getString("CTL_GBC_insets.BM")); 101 BPButton.setToolTipText(bundle.getString("CTL_GBC_insets.BP")); 102 103 gridSizeHMButton.setToolTipText(bundle.getString("CTL_GBC_gridSize.HM")); 104 gridSizeHPButton.setToolTipText(bundle.getString("CTL_GBC_gridSize.HP")); 105 gsRHButton.setToolTipText(bundle.getString("CTL_GBC_gridSize.RH")); 106 gridSizeVMButton.setToolTipText(bundle.getString("CTL_GBC_gridSize.VM")); 107 gridSizeVPButton.setToolTipText(bundle.getString("CTL_GBC_gridSize.VP")); 108 gsRVButton.setToolTipText(bundle.getString("CTL_GBC_gridSize.RV")); 109 110 this.customizer = customizer; 111 } 112 113 private void initComponents() { 114 setLayout(new java.awt.GridBagLayout ()); 115 java.awt.GridBagConstraints gridBagConstraints1; 116 117 actionLsnr = new ActionL (); 118 119 anchorPanel = new javax.swing.JPanel (); 120 anchorPanel.setLayout(new java.awt.GridBagLayout ()); 121 java.awt.GridBagConstraints gridBagConstraints2; 122 anchorPanel.setBorder(new javax.swing.border.TitledBorder ( 123 new javax.swing.border.EtchedBorder (), "anchorPanel")); 125 nwButton = new javax.swing.JToggleButton (); 126 nwButton.setIcon(new ImageIcon(Utilities.loadImage( 127 "org/netbeans/modules/form/layoutsupport/resources/nw.gif"))); nwButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 129 nwButton.setActionCommand("NW"); nwButton.addActionListener(actionLsnr); 131 132 gridBagConstraints2 = new java.awt.GridBagConstraints (); 133 anchorPanel.add(nwButton, gridBagConstraints2); 134 135 nButton = new javax.swing.JToggleButton (); 136 nButton.setIcon(new ImageIcon(Utilities.loadImage( 137 "org/netbeans/modules/form/layoutsupport/resources/n.gif"))); nButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 139 nButton.setActionCommand("N"); nButton.addActionListener(actionLsnr); 141 142 gridBagConstraints2 = new java.awt.GridBagConstraints (); 143 anchorPanel.add(nButton, gridBagConstraints2); 144 145 neButton = new javax.swing.JToggleButton (); 146 neButton.setIcon(new ImageIcon(Utilities.loadImage( 147 "org/netbeans/modules/form/layoutsupport/resources/ne.gif"))); neButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 149 neButton.setActionCommand("NE"); neButton.addActionListener(actionLsnr); 151 152 gridBagConstraints2 = new java.awt.GridBagConstraints (); 153 gridBagConstraints2.gridwidth = 0; 154 anchorPanel.add(neButton, gridBagConstraints2); 155 156 wButton = new javax.swing.JToggleButton (); 157 wButton.setIcon(new ImageIcon(Utilities.loadImage( 158 "org/netbeans/modules/form/layoutsupport/resources/w.gif"))); wButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 160 wButton.setActionCommand("W"); wButton.addActionListener(actionLsnr); 162 163 gridBagConstraints2 = new java.awt.GridBagConstraints (); 164 anchorPanel.add(wButton, gridBagConstraints2); 165 166 cButton = new javax.swing.JToggleButton (); 167 cButton.setIcon(new ImageIcon(Utilities.loadImage( 168 "org/netbeans/modules/form/layoutsupport/resources/c.gif"))); cButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 170 cButton.setActionCommand("C"); cButton.addActionListener(actionLsnr); 172 173 gridBagConstraints2 = new java.awt.GridBagConstraints (); 174 anchorPanel.add(cButton, gridBagConstraints2); 175 176 eButton = new javax.swing.JToggleButton (); 177 eButton.setIcon(new ImageIcon(Utilities.loadImage( 178 "org/netbeans/modules/form/layoutsupport/resources/e.gif"))); eButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 180 eButton.setActionCommand("E"); eButton.addActionListener(actionLsnr); 182 183 gridBagConstraints2 = new java.awt.GridBagConstraints (); 184 gridBagConstraints2.gridwidth = 0; 185 anchorPanel.add(eButton, gridBagConstraints2); 186 187 swButton = new javax.swing.JToggleButton (); 188 swButton.setIcon(new ImageIcon(Utilities.loadImage( 189 "org/netbeans/modules/form/layoutsupport/resources/sw.gif"))); swButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 191 swButton.setActionCommand("SW"); swButton.addActionListener(actionLsnr); 193 194 gridBagConstraints2 = new java.awt.GridBagConstraints (); 195 gridBagConstraints2.insets = new java.awt.Insets (0, 0, 4, 0); 196 anchorPanel.add(swButton, gridBagConstraints2); 197 198 sButton = new javax.swing.JToggleButton (); 199 sButton.setIcon(new ImageIcon(Utilities.loadImage( 200 "org/netbeans/modules/form/layoutsupport/resources/s.gif"))); sButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 202 sButton.setActionCommand("S"); sButton.addActionListener(actionLsnr); 204 205 gridBagConstraints2 = new java.awt.GridBagConstraints (); 206 gridBagConstraints2.insets = new java.awt.Insets (0, 0, 4, 0); 207 anchorPanel.add(sButton, gridBagConstraints2); 208 209 seButton = new javax.swing.JToggleButton (); 210 seButton.setIcon(new ImageIcon(Utilities.loadImage( 211 "org/netbeans/modules/form/layoutsupport/resources/se.gif"))); seButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 213 seButton.setActionCommand("SE"); seButton.addActionListener(actionLsnr); 215 216 gridBagConstraints2 = new java.awt.GridBagConstraints (); 217 gridBagConstraints2.insets = new java.awt.Insets (0, 0, 4, 0); 218 anchorPanel.add(seButton, gridBagConstraints2); 219 220 221 gridBagConstraints1 = new java.awt.GridBagConstraints (); 222 gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; 223 gridBagConstraints1.weightx = 1.0; 224 gridBagConstraints1.weighty = 1.0; 225 add(anchorPanel, gridBagConstraints1); 226 227 fillPanel = new javax.swing.JPanel (); 228 fillPanel.setLayout(new java.awt.GridBagLayout ()); 229 java.awt.GridBagConstraints gridBagConstraints3; 230 fillPanel.setBorder(new javax.swing.border.TitledBorder ( 231 new javax.swing.border.EtchedBorder (), "fillPanel")); 233 horizontalFillButton = new javax.swing.JToggleButton (); 234 horizontalFillButton.setIcon(new ImageIcon(Utilities.loadImage( 235 "org/netbeans/modules/form/layoutsupport/resources/horizontal.gif"))); horizontalFillButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 237 horizontalFillButton.addActionListener(actionLsnr); 238 239 gridBagConstraints3 = new java.awt.GridBagConstraints (); 240 gridBagConstraints3.insets = new java.awt.Insets (0, 0, 4, 0); 241 fillPanel.add(horizontalFillButton, gridBagConstraints3); 242 243 verticalFillButton = new javax.swing.JToggleButton (); 244 verticalFillButton.setIcon(new ImageIcon(Utilities.loadImage( 245 "org/netbeans/modules/form/layoutsupport/resources/vertical.gif"))); verticalFillButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 247 verticalFillButton.addActionListener(actionLsnr); 248 249 gridBagConstraints3 = new java.awt.GridBagConstraints (); 250 gridBagConstraints3.insets = new java.awt.Insets (0, 0, 4, 0); 251 fillPanel.add(verticalFillButton, gridBagConstraints3); 252 253 254 gridBagConstraints1 = new java.awt.GridBagConstraints (); 255 gridBagConstraints1.gridx = 0; 256 gridBagConstraints1.gridy = 1; 257 gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; 258 gridBagConstraints1.weightx = 1.0; 259 gridBagConstraints1.weighty = 1.0; 260 add(fillPanel, gridBagConstraints1); 261 262 ipadPanel = new javax.swing.JPanel (); 263 ipadPanel.setLayout(new java.awt.GridBagLayout ()); 264 java.awt.GridBagConstraints gridBagConstraints4; 265 ipadPanel.setBorder(new javax.swing.border.TitledBorder ( 266 new javax.swing.border.EtchedBorder (), "iPaddingPanel")); 268 jLabel1 = new javax.swing.JLabel (); 269 jLabel1.setIcon(new ImageIcon(Utilities.loadImage( 270 "org/netbeans/modules/form/layoutsupport/resources/horizontalGr.gif"))); 272 gridBagConstraints4 = new java.awt.GridBagConstraints (); 273 gridBagConstraints4.insets = new java.awt.Insets (0, 0, 0, 5); 274 ipadPanel.add(jLabel1, gridBagConstraints4); 275 276 ipadHMButton = new javax.swing.JButton (); 277 ipadHMButton.setIcon(new ImageIcon(Utilities.loadImage( 278 "org/netbeans/modules/form/layoutsupport/resources/minus.gif"))); ipadHMButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 280 ipadHMButton.setActionCommand("HM"); ipadHMButton.addActionListener(actionLsnr); 282 283 gridBagConstraints4 = new java.awt.GridBagConstraints (); 284 ipadPanel.add(ipadHMButton, gridBagConstraints4); 285 286 ipadHPButton = new javax.swing.JButton (); 287 ipadHPButton.setIcon(new ImageIcon(Utilities.loadImage( 288 "org/netbeans/modules/form/layoutsupport/resources/plus.gif"))); ipadHPButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 290 ipadHPButton.setActionCommand("HP"); ipadHPButton.addActionListener(actionLsnr); 292 293 gridBagConstraints4 = new java.awt.GridBagConstraints (); 294 gridBagConstraints4.gridwidth = 0; 295 ipadPanel.add(ipadHPButton, gridBagConstraints4); 296 297 jLabel2 = new javax.swing.JLabel (); 298 jLabel2.setIcon(new ImageIcon(Utilities.loadImage( 299 "org/netbeans/modules/form/layoutsupport/resources/verticalGr.gif"))); 301 gridBagConstraints4 = new java.awt.GridBagConstraints (); 302 gridBagConstraints4.insets = new java.awt.Insets (0, 0, 4, 5); 303 ipadPanel.add(jLabel2, gridBagConstraints4); 304 305 ipadVMButton = new javax.swing.JButton (); 306 ipadVMButton.setIcon(new ImageIcon(Utilities.loadImage( 307 "org/netbeans/modules/form/layoutsupport/resources/minus.gif"))); ipadVMButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 309 ipadVMButton.setActionCommand("VM"); ipadVMButton.addActionListener(actionLsnr); 311 312 gridBagConstraints4 = new java.awt.GridBagConstraints (); 313 gridBagConstraints4.insets = new java.awt.Insets (0, 0, 4, 0); 314 ipadPanel.add(ipadVMButton, gridBagConstraints4); 315 316 ipadVPButton = new javax.swing.JButton (); 317 ipadVPButton.setIcon(new ImageIcon(Utilities.loadImage( 318 "org/netbeans/modules/form/layoutsupport/resources/plus.gif"))); ipadVPButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 320 ipadVPButton.setActionCommand("VP"); ipadVPButton.addActionListener(actionLsnr); 322 323 gridBagConstraints4 = new java.awt.GridBagConstraints (); 324 gridBagConstraints4.insets = new java.awt.Insets (0, 0, 4, 0); 325 ipadPanel.add(ipadVPButton, gridBagConstraints4); 326 327 328 gridBagConstraints1 = new java.awt.GridBagConstraints (); 329 gridBagConstraints1.gridx = 0; 330 gridBagConstraints1.gridy = 2; 331 gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; 332 gridBagConstraints1.weightx = 1.0; 333 gridBagConstraints1.weighty = 1.0; 334 add(ipadPanel, gridBagConstraints1); 335 336 insetsPanel = new javax.swing.JPanel (); 337 insetsPanel.setLayout(new java.awt.GridBagLayout ()); 338 java.awt.GridBagConstraints gridBagConstraints5; 339 insetsPanel.setBorder(new javax.swing.border.TitledBorder ( 340 new javax.swing.border.EtchedBorder (), "insetsPanel")); 342 topMButton = new javax.swing.JButton (); 343 topMButton.setIcon(new ImageIcon(Utilities.loadImage( 344 "org/netbeans/modules/form/layoutsupport/resources/minus.gif"))); topMButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 346 topMButton.setActionCommand("tM"); topMButton.addActionListener(actionLsnr); 348 349 gridBagConstraints5 = new java.awt.GridBagConstraints (); 350 gridBagConstraints5.gridx = 1; 351 gridBagConstraints5.gridy = 0; 352 gridBagConstraints5.insets = new java.awt.Insets (0, 0, 8, 0); 353 gridBagConstraints5.anchor = java.awt.GridBagConstraints.NORTH; 354 insetsPanel.add(topMButton, gridBagConstraints5); 355 356 topPButton = new javax.swing.JButton (); 357 topPButton.setIcon(new ImageIcon(Utilities.loadImage( 358 "org/netbeans/modules/form/layoutsupport/resources/plus.gif"))); topPButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 360 topPButton.setActionCommand("tP"); topPButton.addActionListener(actionLsnr); 362 363 gridBagConstraints5 = new java.awt.GridBagConstraints (); 364 gridBagConstraints5.gridx = 2; 365 gridBagConstraints5.gridy = 0; 366 gridBagConstraints5.insets = new java.awt.Insets (0, 0, 8, 0); 367 gridBagConstraints5.anchor = java.awt.GridBagConstraints.NORTH; 368 insetsPanel.add(topPButton, gridBagConstraints5); 369 370 leftPButton = new javax.swing.JButton (); 371 leftPButton.setIcon(new ImageIcon(Utilities.loadImage( 372 "org/netbeans/modules/form/layoutsupport/resources/plus.gif"))); leftPButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 374 leftPButton.setActionCommand("lP"); leftPButton.addActionListener(actionLsnr); 376 377 gridBagConstraints5 = new java.awt.GridBagConstraints (); 378 gridBagConstraints5.gridx = 0; 379 gridBagConstraints5.gridy = 0; 380 gridBagConstraints5.anchor = java.awt.GridBagConstraints.SOUTHEAST; 381 insetsPanel.add(leftPButton, gridBagConstraints5); 382 383 leftMButton = new javax.swing.JButton (); 384 leftMButton.setIcon(new ImageIcon(Utilities.loadImage( 385 "org/netbeans/modules/form/layoutsupport/resources/minus.gif"))); leftMButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 387 leftMButton.setActionCommand("lM"); leftMButton.addActionListener(actionLsnr); 389 390 gridBagConstraints5 = new java.awt.GridBagConstraints (); 391 gridBagConstraints5.gridx = 0; 392 gridBagConstraints5.gridy = 1; 393 gridBagConstraints5.anchor = java.awt.GridBagConstraints.NORTHEAST; 394 insetsPanel.add(leftMButton, gridBagConstraints5); 395 396 rightPButton = new javax.swing.JButton (); 397 rightPButton.setIcon(new ImageIcon(Utilities.loadImage( 398 "org/netbeans/modules/form/layoutsupport/resources/plus.gif"))); rightPButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 400 rightPButton.setActionCommand("rP"); rightPButton.addActionListener(actionLsnr); 402 403 gridBagConstraints5 = new java.awt.GridBagConstraints (); 404 gridBagConstraints5.gridx = 3; 405 gridBagConstraints5.gridy = 0; 406 gridBagConstraints5.anchor = java.awt.GridBagConstraints.SOUTH; 407 insetsPanel.add(rightPButton, gridBagConstraints5); 408 409 rightMButton = new javax.swing.JButton (); 410 rightMButton.setIcon(new ImageIcon(Utilities.loadImage( 411 "org/netbeans/modules/form/layoutsupport/resources/minus.gif"))); rightMButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 413 rightMButton.setActionCommand("rM"); rightMButton.addActionListener(actionLsnr); 415 416 gridBagConstraints5 = new java.awt.GridBagConstraints (); 417 gridBagConstraints5.gridx = 3; 418 gridBagConstraints5.gridy = 1; 419 gridBagConstraints5.anchor = java.awt.GridBagConstraints.NORTH; 420 insetsPanel.add(rightMButton, gridBagConstraints5); 421 422 bottomMButton = new javax.swing.JButton (); 423 bottomMButton.setIcon(new ImageIcon(Utilities.loadImage( 424 "org/netbeans/modules/form/layoutsupport/resources/minus.gif"))); bottomMButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 426 bottomMButton.setActionCommand("bM"); bottomMButton.addActionListener(actionLsnr); 428 429 gridBagConstraints5 = new java.awt.GridBagConstraints (); 430 gridBagConstraints5.gridx = 1; 431 gridBagConstraints5.gridy = 1; 432 gridBagConstraints5.insets = new java.awt.Insets (8, 0, 0, 0); 433 insetsPanel.add(bottomMButton, gridBagConstraints5); 434 435 bottomPButton = new javax.swing.JButton (); 436 bottomPButton.setIcon(new ImageIcon(Utilities.loadImage( 437 "org/netbeans/modules/form/layoutsupport/resources/plus.gif"))); bottomPButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 439 bottomPButton.setActionCommand("bP"); bottomPButton.addActionListener(actionLsnr); 441 442 gridBagConstraints5 = new java.awt.GridBagConstraints (); 443 gridBagConstraints5.gridx = 2; 444 gridBagConstraints5.gridy = 1; 445 gridBagConstraints5.insets = new java.awt.Insets (8, 0, 0, 0); 446 insetsPanel.add(bottomPButton, gridBagConstraints5); 447 448 jLabel3 = new javax.swing.JLabel (); 449 jLabel3.setIcon(new ImageIcon(Utilities.loadImage( 450 "org/netbeans/modules/form/layoutsupport/resources/horizontalGr.gif"))); 452 gridBagConstraints5 = new java.awt.GridBagConstraints (); 453 gridBagConstraints5.gridx = 0; 454 gridBagConstraints5.gridy = 2; 455 gridBagConstraints5.insets = new java.awt.Insets (8, 0, 0, 5); 456 insetsPanel.add(jLabel3, gridBagConstraints5); 457 458 HMButton = new javax.swing.JButton (); 459 HMButton.setIcon(new ImageIcon(Utilities.loadImage( 460 "org/netbeans/modules/form/layoutsupport/resources/minus.gif"))); HMButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 462 HMButton.setActionCommand("HM"); HMButton.addActionListener(actionLsnr); 464 465 gridBagConstraints5 = new java.awt.GridBagConstraints (); 466 gridBagConstraints5.gridx = 1; 467 gridBagConstraints5.gridy = 2; 468 gridBagConstraints5.insets = new java.awt.Insets (8, 0, 0, 0); 469 insetsPanel.add(HMButton, gridBagConstraints5); 470 471 HPButton = new javax.swing.JButton (); 472 HPButton.setIcon(new ImageIcon(Utilities.loadImage( 473 "org/netbeans/modules/form/layoutsupport/resources/plus.gif"))); HPButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 475 HPButton.setActionCommand("HP"); HPButton.addActionListener(actionLsnr); 477 478 gridBagConstraints5 = new java.awt.GridBagConstraints (); 479 gridBagConstraints5.gridx = 2; 480 gridBagConstraints5.gridy = 2; 481 gridBagConstraints5.insets = new java.awt.Insets (8, 0, 0, 0); 482 insetsPanel.add(HPButton, gridBagConstraints5); 483 484 jLabel4 = new javax.swing.JLabel (); 485 jLabel4.setIcon(new ImageIcon(Utilities.loadImage( 486 "org/netbeans/modules/form/layoutsupport/resources/verticalGr.gif"))); 488 gridBagConstraints5 = new java.awt.GridBagConstraints (); 489 gridBagConstraints5.gridx = 0; 490 gridBagConstraints5.gridy = 3; 491 gridBagConstraints5.insets = new java.awt.Insets (0, 0, 0, 5); 492 insetsPanel.add(jLabel4, gridBagConstraints5); 493 494 VMButton = new javax.swing.JButton (); 495 VMButton.setIcon(new ImageIcon(Utilities.loadImage( 496 "org/netbeans/modules/form/layoutsupport/resources/minus.gif"))); VMButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 498 VMButton.setActionCommand("VM"); VMButton.addActionListener(actionLsnr); 500 501 gridBagConstraints5 = new java.awt.GridBagConstraints (); 502 gridBagConstraints5.gridx = 1; 503 gridBagConstraints5.gridy = 3; 504 insetsPanel.add(VMButton, gridBagConstraints5); 505 506 VPButton = new javax.swing.JButton (); 507 VPButton.setIcon(new ImageIcon(Utilities.loadImage( 508 "org/netbeans/modules/form/layoutsupport/resources/plus.gif"))); VPButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 510 VPButton.setActionCommand("VP"); VPButton.addActionListener(actionLsnr); 512 513 gridBagConstraints5 = new java.awt.GridBagConstraints (); 514 gridBagConstraints5.gridx = 2; 515 gridBagConstraints5.gridy = 3; 516 insetsPanel.add(VPButton, gridBagConstraints5); 517 518 jLabel5 = new javax.swing.JLabel (); 519 jLabel5.setIcon(new ImageIcon(Utilities.loadImage( 520 "org/netbeans/modules/form/layoutsupport/resources/bothGr.gif"))); 522 gridBagConstraints5 = new java.awt.GridBagConstraints (); 523 gridBagConstraints5.gridx = 0; 524 gridBagConstraints5.gridy = 4; 525 gridBagConstraints5.insets = new java.awt.Insets (0, 0, 4, 5); 526 insetsPanel.add(jLabel5, gridBagConstraints5); 527 528 BMButton = new javax.swing.JButton (); 529 BMButton.setIcon(new ImageIcon(Utilities.loadImage( 530 "org/netbeans/modules/form/layoutsupport/resources/minus.gif"))); BMButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 532 BMButton.setActionCommand("BM"); BMButton.addActionListener(actionLsnr); 534 535 gridBagConstraints5 = new java.awt.GridBagConstraints (); 536 gridBagConstraints5.gridx = 1; 537 gridBagConstraints5.gridy = 4; 538 gridBagConstraints5.insets = new java.awt.Insets (0, 0, 4, 0); 539 insetsPanel.add(BMButton, gridBagConstraints5); 540 541 BPButton = new javax.swing.JButton (); 542 BPButton.setIcon(new ImageIcon(Utilities.loadImage( 543 "org/netbeans/modules/form/layoutsupport/resources/plus.gif"))); BPButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 545 BPButton.setActionCommand("BP"); BPButton.addActionListener(actionLsnr); 547 548 gridBagConstraints5 = new java.awt.GridBagConstraints (); 549 gridBagConstraints5.gridx = 2; 550 gridBagConstraints5.gridy = 4; 551 gridBagConstraints5.insets = new java.awt.Insets (0, 0, 4, 0); 552 insetsPanel.add(BPButton, gridBagConstraints5); 553 554 555 gridBagConstraints1 = new java.awt.GridBagConstraints (); 556 gridBagConstraints1.gridheight = 2; 557 gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; 558 gridBagConstraints1.weightx = 1.0; 559 gridBagConstraints1.weighty = 1.0; 560 add(insetsPanel, gridBagConstraints1); 561 562 gridSizePanel = new javax.swing.JPanel (); 563 gridSizePanel.setLayout(new java.awt.GridBagLayout ()); 564 java.awt.GridBagConstraints gridBagConstraints6; 565 gridSizePanel.setBorder(new javax.swing.border.TitledBorder ( 566 new javax.swing.border.EtchedBorder (), "panelSizePanel")); 568 jLabel6 = new javax.swing.JLabel (); 569 jLabel6.setIcon(new ImageIcon(Utilities.loadImage( 570 "org/netbeans/modules/form/layoutsupport/resources/horizontalGr.gif"))); 572 gridBagConstraints6 = new java.awt.GridBagConstraints (); 573 gridBagConstraints6.insets = new java.awt.Insets (0, 0, 0, 5); 574 gridSizePanel.add(jLabel6, gridBagConstraints6); 575 576 gridSizeHMButton = new javax.swing.JButton (); 577 gridSizeHMButton.setIcon(new ImageIcon(Utilities.loadImage( 578 "org/netbeans/modules/form/layoutsupport/resources/minus.gif"))); gridSizeHMButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 580 gridSizeHMButton.setActionCommand("HM"); gridSizeHMButton.addActionListener(actionLsnr); 582 583 gridBagConstraints6 = new java.awt.GridBagConstraints (); 584 gridSizePanel.add(gridSizeHMButton, gridBagConstraints6); 585 586 gridSizeHPButton = new javax.swing.JButton (); 587 gridSizeHPButton.setIcon(new ImageIcon(Utilities.loadImage( 588 "org/netbeans/modules/form/layoutsupport/resources/plus.gif"))); gridSizeHPButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 590 gridSizeHPButton.setActionCommand("HP"); gridSizeHPButton.addActionListener(actionLsnr); 592 593 gridBagConstraints6 = new java.awt.GridBagConstraints (); 594 gridSizePanel.add(gridSizeHPButton, gridBagConstraints6); 595 596 gsRHButton = new javax.swing.JToggleButton (); 597 gsRHButton.setIcon(new ImageIcon(Utilities.loadImage( 598 "org/netbeans/modules/form/layoutsupport/resources/remainder.gif"))); gsRHButton.setMargin(new java.awt.Insets (5, 5, 5, 5)); 600 gsRHButton.setActionCommand("HR"); gsRHButton.addActionListener(actionLsnr); 602 603 gridBagConstraints6 = new java.awt.GridBagConstraints (); 604 gridBagConstraints6.gridwidth = 0; 605 gridSizePanel.add(gsRHButton, gridBagConstraints6); 606 607 jLabel8 = new javax.swing.JLabel (); 608 jLabel8.setIcon(new ImageIcon(Utilities.loadImage( 609 "org/netbeans/modules/form/layoutsupport/resources/verticalGr.gif"))); 611 gridBagConstraints6 = new java.awt.GridBagConstraints (); 612 gridBagConstraints6.insets = new java.awt.Insets (0, 0, 4, 5); 613 gridSizePanel.add(jLabel8, gridBagConstraints6); 614 615 gridSizeVMButton = new javax.swing.JButton (); 616 gridSizeVMButton.setIcon(new ImageIcon(Utilities.loadImage( 617 "org/netbeans/modules/form/layoutsupport/resources/minus.gif"))); gridSizeVMButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 619 gridSizeVMButton.setActionCommand("VM"); gridSizeVMButton.addActionListener(actionLsnr); 621 622 gridBagConstraints6 = new java.awt.GridBagConstraints (); 623 gridBagConstraints6.insets = new java.awt.Insets (0, 0, 4, 0); 624 gridSizePanel.add(gridSizeVMButton, gridBagConstraints6); 625 626 gridSizeVPButton = new javax.swing.JButton (); 627 gridSizeVPButton.setIcon(new ImageIcon(Utilities.loadImage( 628 "org/netbeans/modules/form/layoutsupport/resources/plus.gif"))); gridSizeVPButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 630 gridSizeVPButton.setActionCommand("VP"); gridSizeVPButton.addActionListener(actionLsnr); 632 633 gridBagConstraints6 = new java.awt.GridBagConstraints (); 634 gridBagConstraints6.insets = new java.awt.Insets (0, 0, 4, 0); 635 gridSizePanel.add(gridSizeVPButton, gridBagConstraints6); 636 637 gsRVButton = new javax.swing.JToggleButton (); 638 gsRVButton.setIcon(new ImageIcon(Utilities.loadImage( 639 "org/netbeans/modules/form/layoutsupport/resources/remainder.gif"))); gsRVButton.setMargin(new java.awt.Insets (5, 5, 5, 5)); 641 gsRVButton.setActionCommand("VR"); gsRVButton.addActionListener(actionLsnr); 643 644 gridBagConstraints6 = new java.awt.GridBagConstraints (); 645 gridBagConstraints6.gridwidth = 0; 646 gridBagConstraints6.insets = new java.awt.Insets (0, 0, 4, 0); 647 gridSizePanel.add(gsRVButton, gridBagConstraints6); 648 649 650 gridBagConstraints1 = new java.awt.GridBagConstraints (); 651 gridBagConstraints1.gridx = 1; 652 gridBagConstraints1.gridy = 2; 653 gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; 654 gridBagConstraints1.weightx = 1.0; 655 gridBagConstraints1.weighty = 1.0; 656 add(gridSizePanel, gridBagConstraints1); 657 658 } 659 660 private void gridSizeButtonAction(java.awt.event.ActionEvent evt) { 661 int what = evt.getActionCommand().charAt(0) == 'H' ? GridBagCustomizer.HORIZONTAL : GridBagCustomizer.VERTICAL; 662 int action = 0; 663 664 switch (evt.getActionCommand().charAt(1)) { 665 case 'P': 666 action = GridBagCustomizer.PLUS; 667 break; 668 case 'M': 669 action = GridBagCustomizer.MINUS; 670 break; 671 case 'R': 672 action = 0; 673 break; 674 default: 675 return; 676 } 677 customizer.modifyGridSize(action, what); 678 } 679 680 private void insetsButtonAction(java.awt.event.ActionEvent evt) { 681 int action = evt.getActionCommand().charAt(1) == 'P' ? GridBagCustomizer.PLUS : GridBagCustomizer.MINUS; 682 int what = 0; 683 684 switch (evt.getActionCommand().charAt(0)) { 685 case 't': 686 what = GridBagCustomizer.TOP; 687 break; 688 case 'l': 689 what = GridBagCustomizer.LEFT; 690 break; 691 case 'b': 692 what = GridBagCustomizer.BOTTOM; 693 break; 694 case 'r': 695 what = GridBagCustomizer.RIGHT; 696 break; 697 case 'H': 698 what = GridBagCustomizer.HORIZONTAL; 699 break; 700 case 'V': 701 what = GridBagCustomizer.VERTICAL; 702 break; 703 case 'B': 704 what = GridBagCustomizer.HORIZONTAL + GridBagCustomizer.VERTICAL; 705 break; 706 } 707 customizer.modifyInsets(action, what); 708 } 709 710 private void ipadButtonAction(java.awt.event.ActionEvent evt) { 711 if (evt.getActionCommand().equals("HM")) customizer.modifyIPad(GridBagCustomizer.MINUS, GridBagCustomizer.HORIZONTAL); 713 else if (evt.getActionCommand().equals("HP")) customizer.modifyIPad(GridBagCustomizer.PLUS, GridBagCustomizer.HORIZONTAL); 715 else if (evt.getActionCommand().equals("VM")) customizer.modifyIPad(GridBagCustomizer.MINUS, GridBagCustomizer.VERTICAL); 717 else if (evt.getActionCommand().equals("VP")) customizer.modifyIPad(GridBagCustomizer.PLUS, GridBagCustomizer.VERTICAL); 719 } 720 721 private void fillButtonAction(java.awt.event.ActionEvent evt) { 722 if (horizontalFillButton.isSelected() && verticalFillButton.isSelected()) 723 customizer.setFill(java.awt.GridBagConstraints.BOTH); 724 else if (horizontalFillButton.isSelected()) 725 customizer.setFill(java.awt.GridBagConstraints.HORIZONTAL); 726 else if (verticalFillButton.isSelected()) 727 customizer.setFill(java.awt.GridBagConstraints.VERTICAL); 728 else 729 customizer.setFill(java.awt.GridBagConstraints.NONE); 730 } 731 732 private void anchorButtonAction(java.awt.event.ActionEvent evt) { 733 String command = evt.getActionCommand(); 734 735 if (command.equals("NW")) customizer.setAnchor(java.awt.GridBagConstraints.NORTHWEST); 737 else if (command.equals("N")) customizer.setAnchor(java.awt.GridBagConstraints.NORTH); 739 else if (command.equals("NE")) customizer.setAnchor(java.awt.GridBagConstraints.NORTHEAST); 741 else if (command.equals("W")) customizer.setAnchor(java.awt.GridBagConstraints.WEST); 743 else if (command.equals("C")) customizer.setAnchor(java.awt.GridBagConstraints.CENTER); 745 else if (command.equals("E")) customizer.setAnchor(java.awt.GridBagConstraints.EAST); 747 else if (command.equals("SW")) customizer.setAnchor(java.awt.GridBagConstraints.SOUTHWEST); 749 else if (command.equals("S")) customizer.setAnchor(java.awt.GridBagConstraints.SOUTH); 751 else if (command.equals("SE")) customizer.setAnchor(java.awt.GridBagConstraints.SOUTHEAST); 753 } 754 755 756 private javax.swing.JPanel anchorPanel; 757 private javax.swing.JToggleButton nwButton; 758 private javax.swing.JToggleButton nButton; 759 private javax.swing.JToggleButton neButton; 760 private javax.swing.JToggleButton wButton; 761 private javax.swing.JToggleButton cButton; 762 private javax.swing.JToggleButton eButton; 763 private javax.swing.JToggleButton swButton; 764 private javax.swing.JToggleButton sButton; 765 private javax.swing.JToggleButton seButton; 766 private javax.swing.JPanel fillPanel; 767 private javax.swing.JToggleButton horizontalFillButton; 768 private javax.swing.JToggleButton verticalFillButton; 769 private javax.swing.JPanel ipadPanel; 770 private javax.swing.JLabel jLabel1; 771 private javax.swing.JButton ipadHMButton; 772 private javax.swing.JButton ipadHPButton; 773 private javax.swing.JLabel jLabel2; 774 private javax.swing.JButton ipadVMButton; 775 private javax.swing.JButton ipadVPButton; 776 private javax.swing.JPanel insetsPanel; 777 private javax.swing.JButton topMButton; 778 private javax.swing.JButton topPButton; 779 private javax.swing.JButton leftPButton; 780 private javax.swing.JButton leftMButton; 781 private javax.swing.JButton rightPButton; 782 private javax.swing.JButton rightMButton; 783 private javax.swing.JButton bottomMButton; 784 private javax.swing.JButton bottomPButton; 785 private javax.swing.JLabel jLabel3; 786 private javax.swing.JButton HMButton; 787 private javax.swing.JButton HPButton; 788 private javax.swing.JLabel jLabel4; 789 private javax.swing.JButton VMButton; 790 private javax.swing.JButton VPButton; 791 private javax.swing.JLabel jLabel5; 792 private javax.swing.JButton BMButton; 793 private javax.swing.JButton BPButton; 794 private javax.swing.JPanel gridSizePanel; 795 private javax.swing.JLabel jLabel6; 796 private javax.swing.JButton gridSizeHMButton; 797 private javax.swing.JButton gridSizeHPButton; 798 private javax.swing.JToggleButton gsRHButton; 799 private javax.swing.JLabel jLabel8; 800 private javax.swing.JButton gridSizeVMButton; 801 private javax.swing.JButton gridSizeVPButton; 802 private javax.swing.JToggleButton gsRVButton; 803 804 805 void newSelection(java.util.List proxies) { 806 807 int anchor = -1; 808 boolean noAnchor = false; 809 int fill = -1; 810 boolean noFill = false; 811 812 boolean remainderH = true; 813 boolean remainderV = true; 814 815 java.util.Iterator it = proxies.iterator(); 816 817 818 for (int i = 0; it.hasNext(); i++) { 819 GridBagCustomizer.GBComponentProxy p =(GridBagCustomizer.GBComponentProxy) it.next(); 820 java.awt.GridBagConstraints con = p.getRealConstraints(); 821 822 if (i == 0) { 823 anchor = con.anchor; 824 fill = con.fill; 825 } 826 else { 827 if (con.anchor != anchor) 828 noAnchor = true; 829 if (con.fill != fill) 830 noFill = true; 831 } 832 833 if (con.gridwidth != java.awt.GridBagConstraints.REMAINDER) 834 remainderH = false; 835 836 if (con.gridheight != java.awt.GridBagConstraints.REMAINDER) 837 remainderV = false; 838 839 } 840 841 843 nwButton.setSelected((!noAnchor) && anchor == java.awt.GridBagConstraints.NORTHWEST); 844 nButton.setSelected((!noAnchor) && anchor == java.awt.GridBagConstraints.NORTH); 845 neButton.setSelected((!noAnchor) && anchor == java.awt.GridBagConstraints.NORTHEAST); 846 wButton.setSelected((!noAnchor) && anchor == java.awt.GridBagConstraints.WEST); 847 cButton.setSelected((!noAnchor) && anchor == java.awt.GridBagConstraints.CENTER); 848 eButton.setSelected((!noAnchor) && anchor == java.awt.GridBagConstraints.EAST); 849 swButton.setSelected((!noAnchor) && anchor == java.awt.GridBagConstraints.SOUTHWEST); 850 sButton.setSelected((!noAnchor) && anchor == java.awt.GridBagConstraints.SOUTH); 851 seButton.setSelected((!noAnchor) && anchor == java.awt.GridBagConstraints.SOUTHEAST); 852 853 horizontalFillButton.setSelected(!noFill && 855 (fill == java.awt.GridBagConstraints.HORIZONTAL || fill == java.awt.GridBagConstraints.BOTH)); 856 857 verticalFillButton.setSelected(!noFill && 858 (fill == java.awt.GridBagConstraints.VERTICAL || fill == java.awt.GridBagConstraints.BOTH)); 859 860 gsRHButton.setSelected(remainderH); 862 gsRVButton.setSelected(remainderV); 863 } 864 865 private class ActionL implements java.awt.event.ActionListener { 866 public void actionPerformed(java.awt.event.ActionEvent evt) { 867 Object src = evt.getSource(); 868 if (nwButton.equals (src) 869 || nButton.equals (src) 870 || neButton.equals (src) 871 || wButton.equals (src) 872 || cButton.equals (src) 873 || eButton.equals (src) 874 || swButton.equals (src) 875 || sButton.equals (src) 876 || seButton.equals (src) 877 ) { 878 anchorButtonAction(evt); 879 } 880 else if (horizontalFillButton.equals(src) 881 || verticalFillButton.equals(src) 882 ) 883 { 884 fillButtonAction(evt); 885 } 886 else if (ipadHMButton.equals(src) 887 || ipadHPButton.equals(src) 888 || ipadVMButton.equals(src) 889 || ipadVPButton.equals(src) 890 ) 891 { 892 ipadButtonAction(evt); 893 } 894 else if (BMButton.equals(src) 895 || BPButton.equals(src) 896 || HMButton.equals(src) 897 || HPButton.equals(src) 898 || VMButton.equals(src) 899 || VPButton.equals(src) 900 || topPButton.equals(src) 901 || topMButton.equals(src) 902 || leftPButton.equals(src) 903 || leftMButton.equals(src) 904 || rightPButton.equals(src) 905 || rightMButton.equals(src) 906 || bottomPButton.equals(src) 907 || bottomMButton.equals(src) 908 ) 909 { 910 insetsButtonAction(evt); 911 } 912 else if (gridSizeHMButton.equals(src) 913 || gridSizeHPButton.equals(src) 914 || gsRHButton.equals(src) 915 || gridSizeVMButton.equals(src) 916 || gridSizeVPButton.equals(src) 917 || gsRVButton.equals(src) 918 ) 919 { 920 gridSizeButtonAction(evt); 921 } 922 } 923 } 924 } 925 | Popular Tags |