Tips and tricks

  Default button
  Tree selection models
  Default menus
  Testing a layout's resizing behaviour
  Selecting small grid cells
  JSeparators
  JTextArea
  JCheckBox and JRadioButton


Default button     Top of page

Every layout can have a default button (the one you would set with getRootPane().setDefaultButton(JButton)). To define a default button with RADi, set the button's variable name to "defaultButton".


Tree selection models     Top of page

Because JTree lacks a selectionMode property (like JList has), RADi offers some TreeSelectionModels you choose from the selectionModel .
DefaultTreeSelectionModel is the default selection model. It allows all kinds of selections.
TreeContiguousSelectionModel allows only contiguous selections.
TreeSingleSelectionModel allows only one single selection at a time.


Default menus     Top of page

Whenever you insert a menu bar into the design grid, the menu bar is populated with default menus. You can easily change the defaults (maybe to add icons or to customize the language): Open the , edit the menus and then press Save as default (see Menu editor).
To restore the RADi defaults, delete the file defaultmenus from the RADi directory.

Items of default menus are defined through Action objects. RADi creates the following actions: newAction, openAction, saveAction, saveAsAction, cutAction, copyAction, pasteAction and helpAction.

About how to internationalize menu items and actions, see the section about Internationalization.


Testing a layout's resizing behaviour     Top of page

An important aspect of a layout is its resizing behaviour. You can test resizing in two ways:
Select 'Window | Show Test Frame' or press this .
Before the test frame opens, it is pack()'ed and you see your layout at its preferred size. Then enlarge and reduce frame size and see what happens.
Select 'Grid | Fixed Size' (or press this ).
A is drawn around the layout, you can resize it as you would do with a real frame border. Then adjust column and row weights until the layout reacts as you intend.
Tip: You can set the fixed size at 'Grid | Fixed Size...'.


Selecting small grid cells     Top of page

If column width or row height of a grid cell is < 4 pixels, you cannot select this cell with the mouse. Once a grid cell is selected, you can navigate grid cells using the arrow keys.


JSeparator     Top of page

A JSeparator, by default, has a preferred size of (0, 2) respectively (2, 0) with horizontal/vertical orientation (values are LookAndFeel depend). As a result, separators without selected anchors are invisible. So, for horizontal separators, set the left and right anchors, for vertical separators, set the top and bottom anchors.

Note: RADi will set the anchors for you whenever you insert a JSeparator into a layout grid and will also change this setting as you change the separator's orientation property.


JTextArea     Top of page

Sometimes you want a JTextArea without a scroll pane (as a kind of multiline label). You can specify the text either exactly as it shall be displayed, including line breaks, or you can set the lineWrap and the wrapStyleWord properties. If you take the second approach, the text area is laid out dependent on the width of its grid cell. You may notice, that the text area's layout doesn't change if you reduce the cell width at a later time. You can force it to do so by changing the wrapStyleWord property's value and changing it back again.


JCheckBox and JRadioButton     Top of page

You should not stretch JCheckBoxes or JRadioButtons by selecting the left and right anchors. The reason for this is, that the sensitive area should not be larger than the visible component bounds.