[View INPRISE Home Page][View Product List][Search This Web Site][View Available Downloads][Join Inprise Membership][Enter Discussion Area][Send Email To Webmaster]
INPRISE Online And ZD Journals Present:



Building a TabsetPanel
By Alvin J. Alexander and Tim Gooch

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
Adding a TabsetPanel component is a quick and painless process with JBuilder. In the next few steps, you’ll see how to build the TabsetPanel component shown in Figure A.

 

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
You can add the labels for the TabsetPanel tabs prior to placing components on the individual pages. To do so, begin by double-clicking on the TabsetPanel object’s labels property.

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
In contrast to the label-first method, you also can add BevelPanel objects directly to the TabsetPanel object. The obvious way to do this is by dropping the BevelPanel directly on the TabsetPanel.

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?
When your applet starts running, you’ll probably want to display the first tab in the TabsetPanel. Then again, you may want to display a different one if certain conditions exist. Either way, you may want to specify which page appears first. To do this, add the line

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
Configuring a TabsetPanel isn’t terribly intuitive, but it’s also fairly painless. In most cases, you should be able to use the techniques we’ve shown here to get your TabsetPanel-based interfaces up and running in almost no time.


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.
Trademarks & Copyright © 1998 INPRISE Corporation.