![]() ![]() ![]() |
INPRISE Online And ZD Journals Present:
For those applets and applications where you want to present a lot of related information in a small amount of real estate, you can’t beat TabsetPanel components. In fact, if you look through the latest versions of Windows and Windows applications, you’ll see TabsetPanel-style components just about everywhere. In this article, we’ll show you how to configure a TabsetPanel as quickly as possible.
Put it on your tab
Figure A: You can add a
simple TabsetPanel component to an applet very quickly.
The first step is to start a new applet project. You can use all the default values in both the project and applet wizards. Now we’ll add a TabsetPanel component to the applet. The TabsetPanel component is in the Containers page of the Component Palette. Click on the Containers tab, then drag a TabsetPanel component from the Containers page and resize it to occupy most of the applet. Next, we’ll create five tab pages in our TabsetPanel, as shown in Figure B. There are two ways to create the pages in a TabsetPanel: labels first or panels first.
Figure B: You can
create the five tab pages on the TabsetPanel in two ways.
The label-first method When the labels property’s string list editor appears, enter the text for the five labels, as shown in Figure C. Click OK to save the new labels.
Figure C: You can use
the labels property’s string list editor to create
new pages or to edit the labels of existing pages.
In the Object Inspector, enter 0 for the TabsetPanel object’s selectedIndex property to make the first page active in the Form Designer. On the Containers page of the Component Palette, select the BevelPanel, and place it on the active page of the TabsetPanel. Select the next page of the TabsetPanel by entering 1 for its selectedIndex property. When the second page becomes active, place a BevelPanel on that page too. Repeat this process for the remaining pages so that each page contains a BevelPanel component. At this point, you can change the active page of the TabsetPanel two ways: You can change the object’s selectedIndex property, as we described above, or you can click on the corresponding BevelPanel object’s name in the Navigation pane.
The panel-first method However, adding the second BevelPanel is a bit trickier using this method, since you’ll have to click in the region just to the right of the first page’s tab. This is awkward at best—and almost impossible as the tabs begin to occupy most of the space at the top or bottom of the TabsetPanel. Instead, you can create new pages by placing the new BevelPanel components via the Navigation pane instead of the Form Designer pane. Specifically, drop the new BevelPanel components on the name of the TabsetPanel. As JBuilder creates new pages for the TabsetPanel, it automatically creates labels for each page based on the name of the component you’ve placed on them (in this case bevelPanel1, bevelPanel2, and so on), as shown in Figure D. Naturally, you can use the labels property’s string list editor to modify the labels that JBuilder created for you.
Figure D: When you add
panels to the TabsetPanel first, JBuilder assigns default
labels to each of the pages.
Who’s on first? TabsetPanel1.setSelectedIndex(2); to the end of the jbInit() method. Calling the setSelectedIndex() method at the end of the jbInit() method forces the property to the new value prior to displaying the TabsetPanel. You’ll place this statement after the code that implements the user modifications to the labels, panels, and so on. (This ensures that other modifications to the TabsetPanel won’t affect which tab appears first.)
Conclusion Alvin J. Alexander is the president and chief scientist of Mission Data Corporation (www.missiondata.com), an employee-owned software engineering and systems integration firm. You can reach him online at alvina@missiondata.com. Tim Gooch is editor-in-chief of JBuilder Developer's Journal as well as several other ZD Journals publications.
Back to Top Back to Index of Articles Copyright © 1997, ZD Journals, a division of Ziff-Davis Inc. ZD Journals and ZD Jounals logo are trademarks of Ziff-Davis Inc. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff-Davis is prohibited. |