Delphi Clinic C++Builder Gate Training & Consultancy Delphi Notes Weblog Dr.Bob's Webshop
Hubert Klein Ikkink (aka Mr.Haki) - Communications Officer
 Mr.Haki's JBuilder Jar #23
See Also: JBuilder Papers

Adding space
User interface design in Java has to be done with layout managers. These layout managers determine where components will be placed. Most layout managers use the getPreferredSize(), getMinimumSize(), getMaximumSize() to determine the size of the components. Besides these sizes most layout managers have got properties for horizontal and vertical gap distance between components. But maybe we want some more freedom to determine the spacing between components, but do not want to exclude the use of the layout managers.

And that is were the borland.jbcl.view.Spacer class comes into play. This class is a component we can set the preferredSize, minimumSize, maximumSize properties of. The layout manager will use these values to layout the different components.

So all we have to do is to add the Spacer component to our application and change the size properties. And because this component is a real component we can add it to our Component Palette and drop it on our panels in the Visual Designer.

Follow these steps to add the component to the Component Palette:

  1. Select Tools | Configure Palette... from the JBuilder main menu.
  2. Select the Add from Archive page.
  3. Use the jbcl2.0.jar archive file (it can be found in the lib folder in the JBuilder2 folder).
  4. Select the borland.jbcl.view package from the packages list.
  5. Select the Spacer bean from the list of beans.
  6. Select the page you want the component to be installed on.
  7. Click on the Install button.
  8. Close the dialog window.

Once it is on the Component Palette we can drop it on our panels in the Visual Designer. The following applet shows the use of the Spacer component. By clicking the button a new frame will be opened which allows us to experiment with different spacer sizes.

Source code:


This webpage © 1997-2009 by Bob Swart (aka Dr.Bob - www.drbob42.com). All Rights Reserved.