HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML
 

"AFC-User Interface Controls"
Vol. 2, Issue 8, p. 12

	

Listing 1: Creating static controls using the AFC.
 
// Create a panel that contains AFC static controls 
  
class StaticControls extends UIPanel { 
  public StaticControls() { 
    Toolkit tools = getToolkit(); 

    // Load Images 
    Image disk = tools.getImage("disk.gif"); 
    Image arrow = tools.getImage("arrow.gif"); 

    setBackground(Color.lightGray); 

    // Static Text Example 
    add(new UIText("Example")); 

    // Static Graphic Example 
    add(new UIGraphic(arrow)); 

    // Static Item Example 
    add(new UIItem(disk,"Save File",0, 
                    UIItem.ABOVE)); 

  }; 
}; 

Listing 2: Creating button controls using the AFC.
 
// Create a panel that contains AFC button controls 
  
class ButtonControls extends UIPanel { 
  private UIRadioButton RadioButton; 
  private UICheckButton CheckButton; 
  private UIPushButton PushButton; 
  private UIPushButton ImagePushButton; 

  public ButtonControls() { 
    setBackground(Color.lightGray); 
    Toolkit tools = getToolkit(); 

    // Load Images 
    Image disk = tools.getImage("disk.gif"); 

    // Radio Button Example 
    add(RadioButton = new  
         UIRadioButton("I'm a Radio Button!")); 

    // Check Box Example 
    add(CheckButton = new  
         UICheckButton("I'm a Check Box!")); 

    // Push Button Example 
    add(PushButton = new  
          UIPushButton("I'm a Push Button!", 
                       UIPushButton.RAISED)); 
    
    // Image Push Button Example 
    UIItem item = new UIItem(disk,"Save File", 
                             0,UIItem.ABOVE); 
    add(ImagePushButton = new UIPushButton(item, 
                                UIPushButton.RAISED)); 
  }; 
}; 

Listing 3: Creating button controls with a check box.
 
// Create a panel that contains AFC a menu control 
class MenuControls extends UIPanel { 
  public MenuControls() { 
    setBackground(Color.lightGray); 
    Toolkit tools = getToolkit(); 

    // Load Image 
    Image disk = tools.getImage("disk.gif"); 

    // Create A Menu List 
    UIMenuList MenuList = new UIMenuList(); 

    // Add Standard Menu Items 
    MenuList.add("First Menu Item"); 
    MenuList.add("Second Menu Item"); 
    MenuList.add("Third Menu Item"); 

    // Add A Menu Break 
    MenuList.add(new UILine()); 

    // Create A Sub Menu Item 
    UIMenuList SubMenuList = new UIMenuList(); 

    // Add Sub Menu Items 
    SubMenuList.add("First Sub-Menu Item"); 
    SubMenuList.add("First Sub-Menu Item"); 

    // Add The Sub Menu To The Main Menu 
    MenuList.add(new UIMenuItem("Sub Menu Item",  
                    SubMenuList)); 

    // Add A Menu Break 
    MenuList.add(new UILine()); 

    // Add A Check Box Menu Item 
    MenuList.add(new  
      UICheckButton("I'm a Check Box!")); 
  
    // Add an Image Menu Item 
    MenuList.add(new UIItem(disk,"Save File", 
                            0,UIItem.ABOVE)); 

    // Create The Menu Button 
    add(new UIMenuButton("My Menu Button", MenuList)); 
  }; 
};


 

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.