Current Page: NeXtMidas Training NetBeans - Part 2 (GUIs) Using the GUI Builder Demo Step 4 - Add Widget Cont.
| Adding Button widget for control of GUI: By default, when a GUI form is used, NeXtMidas assumes all the controls are defined. and does not attempt to "re-create" them. To avoid this (and allow `GCONTROL` to create the controls), place a MidasControls widget in the location where the `GCONTROL` should place its controls and give it the variable name of pane0; `GCONTROL` then adds all of its controls on the MidasControls widget when the macro runs. To use Swing button widgets instead of the MidasControls, create a ButtonGroup from the Palette window and rename the widget's variable name to match the `GCONTROL` button's name. Since we defined our button as `gcontrol button state "" "Exit"`, we need to name the ButtonGroup widget to state to let NeXtMidas pass messages from that button group to the processMessage prodcedure in our macro. Next create the Exit button by selecting Button from the Palette window, then clicking on the place on the GUI form where you want it to be displayed. Click image for larger view. Rename the variable of the JButton widget to match the `GCONTROL` button name. Right-click and select Change Variable Name and enter exit. You should also rename the text of the button, right-click and select Edit Text and enter Exit for the exit button. The button text does not need to match the button variable name and can have more user-friendly text and helpful "toolTipText". The JButton widget has to be associated with the ButtonGroup for NeXtMidas to correlate and automatically pass the button events to the processMessage procedure. Select the button on the form, then on the button's Properties window change the buttonGroup property to the state ButtonGroup. Click image for larger view.