| By John Fronckowiak | Article Rating: |
|
| August 1, 1997 12:00 AM EDT | Reads: |
7,940 |
Foundations
This month I wrap up my two part review of the Application Foundation Classes with a closer look at the user interface controls it provides. In my past two columns, I've showed you how to install and use the Java SDK 2.0, which includes the Application Foundation Classes, and how to begin using the Application Foundation Classes in your own applications. Now it's time to take a closer look at what the Application Foundation Classes can do for the user interfaces of your Java applications.
The Controls
The Application Foundation Classes provide a number of enhanced user interface controls which can be used in your applications. These controls include:
The Application Foundation Class user interface controls make it easy to mix and match different types of controls. It's very easy to mix text and graphics on many of the controls. Next, I review the more common user interface controls. I will show you how to create static controls, buttons and menus using the Application Foundation Classes. Note: For your reference, in the last Visual J++ Corner column I provided a complete hierarchy of the Application Foundation Classes, including all of the user interface classes.
Static Controls
There are three primary types of static controls in the Application Foundation Classes. They are the static text control, the static graphic control and the static item control (used to display both text and a graphic image). The static text control is represented by the UIText class, the static graphic control by the UIGraphic class and the static item control by the UIItem class. The UIText constructor takes a single parameter - the text to be displayed. The UIGraphic control also takes a single constructor parameter - an Image object which represents the image to be displayed. Finally, the UIItem control takes three important parameters - the text to display, an Image object representing the graphic to display and text alignment constants. Listing 1 presents a simple panel class that creates each of these static controls. Figure 1 illustrates how these controls are rendered.
Buttons
There are three primary types of button controls in the Application Foundation Classes. They are push button controls, radio button controls and check box controls. The push button control is represented by the UIPushButton class, the radio button control by the UIRadioButton class and the check box control by the UICheckButton class. The UIPushButton constructor takes two parameters - the text of the button and style of the button. You can create three button styles: using the UIPushButton.RAISED constant, you can create a standard push button; using the UIButton.TOGGLE constant, you can create a two-state button; using the UIButton.TRITOGGLE, you can create a three-state button. If you substitute a UIGraphic or UIItem object for the text parameter in the constructor, you can easily create a button that displays a graphic or text and a graphic. The UIRadioButton and UICheckButton constructors each take a single parameter - simply the text to display on the button. Listing 2 shows you how to create buttons using the Application Foundation Classes. Figure 2 illustrates how the buttons defined in Listing 2 are rendered.
Menus
Finally, the last Application Foundation Class I will review here is the Menu control. Menu controls are comprised of three main classes: UIMenuItem, which represents an actual menu item; UIMenuList, which represents a list of menu items; and UIMenuButton, which represents a menu push button. When a menu push button is pressed, the menu is displayed. Menus are pretty easy to put together. As outlined in Listing 3, you begin by creating a menu list. The UIMenuList.add method is called to add new menu items. You can add text strings to create simple text-based menu items or you can create complex menu items by adding different types. In the example in Listing 3, I have added a check box menu item by simply adding a UICheckButton object to the menu list and a graphic and text menu item by adding a UIItem object to the menu list. It's also easy to create sub-menus: just add another menu list to the main menu list. Once you have constructed your menu hierarchy, the UIMenuButton item is created, which marries a menu list with the menu button. Figure 3 illustrates the menu defined in Listing 3.
J/Direct and the Future of AFC
The Application Foundation Classes are certainly powerful. I've only touched the tip of the iceberg; the Application Foundation Classes also include a set of Enterprise Classes. The Application Foundation Enterprise Classes include the ability to build transaction-enabled applications in Java that interface with Microsoft Transaction Server and also provide access to legacy information systems and databases.
Microsoft has announced their J/Direct initiative, which will be part of the Java Virtual Machine in Internet Explorer Version 4.0. J/Direct should strike fear into the hearts of the pure Java camp, as it will allow Java applications written for the new Microsoft Java Virtual Machine to directly access the Windows API. Does this mean that developers will rush to create applications using the J/Direct interfaces? I prefer to wait and see. Even though this industry moves at faster than light speeds, sometimes it takes the future a lot longer to get here than you'd expect. It is my opinion though that some sort of marriage between the Application Foundation Classes and J/Direct is somewhere in the near future, with a set of Application Foundation Classes optimized for the Windows VM that utilize J/Direct and another portable set that doesn't. This could create a win-win situation for developers, since they could still develop portable applications, but rely on the speed and close integration with the Windows platform when running on the Java Virtual Machine. Will I be right? I don't know, but it's an interesting enough story to keep me tuned in every day.
Next Month: The Visual J++ Database Wizard: Is The Magic Right For You?
Published August 1, 1997 Reads 7,940
Copyright © 1997 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By John Fronckowiak
John Fronckowiak is the President of IDC Consulting, Inc., providing consulting and technical writing. He is also a Clinical Assistant Professor in Information Systems at the Adult Learning Program of Medaille College and is the author of several books and articles about iPhone development, programming, database design and development and networking. Fronckowiak has previously spoken at the Internet Commerce Expo in Boston, and the Conference on Instructional Technologies. In addition, he has over a decade of experience in the classroom as a college professor and runs dozens of training sessions for application developers.
- Kindle 2 vs Nook
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- Confessions of a Ulitzer Addict
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- It's the Java vs. C++ Shootout Revisited!
- Cloud Computing Can Revitalize Your Career as Software Developer
- IBM Could "Reinvent" Java: Mills
- Oracle & Cloud Computing: Exclusive Q&A with SVP Richard Sarwal
- A Brief History of Cloud Computing
- Kindle 2 vs Nook
- Cloud CEOs, CTOs & SVPs to Speak at 4th International Cloud Computing Expo
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- A Cup of AJAX? Nay, Just Regular Java Please
- Java Developer's Journal Exclusive: 2006 "JDJ Editors' Choice" Awards
- The i-Technology Right Stuff
- JavaServer Faces (JSF) vs Struts
- Rich Internet Applications with Adobe Flex 2 and Java
- Java vs C++ "Shootout" Revisited
- Bean-Managed Persistence Using a Proxy List
- Reporting Made Easy with JasperReports and Hibernate
- Creating a Pet Store Application with JavaServer Faces, Spring, and Hibernate
- What's New in Eclipse?
- Why Do 'Cool Kids' Choose Ruby or PHP to Build Websites Instead of Java?
- i-Technology Predictions for 2007: Where's It All Headed?




































