Comments
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Cloud Expo on Google News

SYS-CON.TV
Cloud Expo & Virtualization 2009 East
PLATINUM SPONSORS:
IBM
Smarter Business Solutions Through Dynamic Infrastructure
IBM
Smarter Insights: How the CIO Becomes a Hero Again
Microsoft
Windows Azure
GOLD SPONSORS:
Appsense
Why VDI?
CA
Maximizing the Business Value of Virtualization in Enterprise and Cloud Computing Environments
ExactTarget
Messaging in the Cloud - Email, SMS and Voice
Freedom OSS
Stairway to the Cloud
Sun
Sun's Incubation Platform: Helping Startups Serve the Enterprise
POWER PANELS:
Cloud Computing & Enterprise IT: Cost & Operational Benefits
How and Why is a Flexible IT Infrastructure the Key To the Future?
Click For 2008 West
Event Webcasts
AFC- User Interface Controls
AFC- User Interface Controls

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:

  • Static controls - Used to display static text, graphic or both
  • Buttons - Used to create push buttons, radio buttons and check boxes
  • Lists - Used to create lists, combo boxes and dropdown combo boxes that contain text or graphics
  • Menus - Used to create floating menus, which can also include other buttons
  • Edit controls - Used to create single and multi-line edit controls
  • Status controls - Used to create status and progress bar controls
  • Tree controls - Used to create tree-like controls similar to those found in the Windows Explorer application

    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?

    About 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.

  • In order to post a comment you need to be registered and logged in.

    Register | Sign-in

    Reader Feedback: Page 1 of 1

    Latest Cloud Developer Stories
    Swisscom, the Swiss telecom, is going into the cloud business. Its subsidiary Swisscom IT Services AG has signed up with Red Hat as a Certified Cloud Provider and launched a public cloud Infrastructure-as-a-Service (IaaS) cloud targeting enterprise-class customers primarily in ...
    Apache Deltacloud, the Red Hat-contributed ReSTful API that abstracts differences between clouds so services on any cloud can be managed – provided of course there’s a driver – has graduated from the Apache Foundation’s incubator and is now a full-fledged Top-Level Project (TLP)....
    In a surprise move on Tuesday, January 10, Oracle wheeled out its Big Data Appliance. That’s the one it said in October would be ready sometime in the first half. Only nobody believed it meant early in the first half. Heck, it’s not even clear anybody thought Oracle could make ...
    Rackspace Hosting, the service leader in cloud computing, on Thursday announced its acquisition of SharePoint911, an industry leader in SharePoint consulting, training, and "JumpStart" services within SharePoint. The unification of both companies provides capabilities to deliver ...
    CloudLinux, Inc., on Thursday released CafeFS 3, a virtualized file system for shared hosters that cages each customer within its own virtualized file system. CageFS becomes part of CloudLinux OS at no additional charge. CloudLinux OS, the only commercially-supported Linux OS m...
    Subscribe to the World's Most Powerful Newsletters
    Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
    Click to Add our RSS Feeds to the Service of Your Choice:
    Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
    myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
    Publish Your Article! Please send it to editorial(at)sys-con.com!

    Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

    SYS-CON Featured Whitepapers
    ADS BY GOOGLE

    Breaking Cloud Computing News

    BEACHWOOD, Ohio, Feb. 16, 2012 /PRNewswire/ -- DDR Corp. (NYSE: DDR) today announced operating re...