![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Sams Teach Yourself Visual J++ 6 in 21 Days
Toolbar and StatusBar ControlsThese two controls are found in many Windows programs. Toolbars normally appear at the top of an application window, and they provide users with an easy way to perform functions by offering them buttons for one-click operations. Status bars usually are at the bottom of an application window, and they offer an easy way to show users the status of different application items. Toolbar ControlThe Toolbar control is encapsulated in the Toolbar class. This control allows users to easily perform functions in an application. Heres the Toolbar icon that appears in the Toolbox:
When you add a Toolbar control to your form, four lines of default code are added that initialize the control with some default properties. These four lines of code are shown in the next example: toolBar1.setSize(new Point(292, 22)); toolBar1.setTabIndex(0); toolBar1.setDropDownArrows(true); toolBar1.setShowToolTips(true); Most of the methods available in the Toolbar class correspond to toolbar properties. Examples of this are the getAutoSize() method, the getBorderStyle() method, and the getAppearance() method. But with toolbars, youll be mostly interested in the events. The two events youll use more often than any others will be the buttonClick event and the buttonDropDown event. The buttonClick event is triggered whenever a button in the toolbar is clicked by the user. The buttonDropDown event is triggered whenever a button in the drop-down style is pressed. StatusBar ControlStatus bars are areas that are usually displayed at the bottom of an application window. Status bars are used by applications to display various kinds of status information. Heres the StatusBar icon that appears in the Toolbox:
When you add a status bar to your form, five lines of code that set the StatusBar controls property to default values are added for you. You can see them in the next example: statusBar1.setBackColor(Color.CONTROL); statusBar1.setLocation(new Point(0, 249)); statusBar1.setSize(new Point(292, 24)); statusBar1.setTabIndex(1); statusBar1.setText("statusBar1"); The method you will probably use more often than any other is the setText() method. This sets the text that will appear in the status bar. Of course, the showPanels property has to be set to false to use this method. SummaryWhen you write Visual J++ applications, you have many controls at your disposal. These controls make it very easy to create a user interface. Adding event handling to these controls is just as easy. With the double-click of a mouse button, you can have an event handler for any of the controls events. This ability to easily create user interfaces far surpasses the ability of a Visual C++ programmer to quickly create user interfaces. It puts Visual J++ on the same level with Visual Basic for creating user interfacestheyre both very easy.
|
![]() |
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |