Java
  Home arrow Java arrow Page 5 - Java's Basic User Interface Components
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Java's Basic User Interface Components
By: Gayathri Gokul
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 13
    2003-10-20

    Table of Contents:
  • Java's Basic User Interface Components
  • Adding a Control to a Container
  • The Button Class
  • The Label Class
  • The Checkbox Class
  • The CheckboxGroup Class
  • The Choice List Class
  • The TextField and TextArea Class
  • Setting a Password Character
  • TextArea

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Java's Basic User Interface Components - The Checkbox Class


    (Page 5 of 10 )

    Check Boxes are labeled or unlabeled boxes that can be either “Checked off” or “Empty”. Typically, they are used to select or deselect an option in a program, such as the “Disable sound” check boxes from a Windows screen.

    Check Boxes are generally nonexclusive, which means that if you have six check boxes in container, all the six can either be checked or unchecked at the same time. This component can be organized into check box group, which is sometimes called radio buttons. Both kinds of check boxes are created using the Checkbox class. To create a nonexclusive check box you can use one of the following constructors:

  • Checkbox() creates an unlabeled checkbox that is not checked.
  • Checkbox(String) creates an unchecked checkbox with the given label as its string.

    After you create a checkbox object, you can use the setState(boolean) method with a true value as argument for checked checkboxes, and false to uncheck it. Six checkboxes are created in Example 4, which is an applet to enable you to select up to six courses at a time. All five checkboxes are unchecked only the second option is checked.

    Example 4

    /*
    <Applet code= “CheckboxTest.class”
    Width = 200
    Height = 150>
    </applet>
    */

    Import java.awt.*;

    Public class CheckboxTest extends java.applet.Applet
    {
    Checkbox c1 = new Checkbox (“Java”);
    Checkbox c2 = new Checkbox (“XML”);
    Checkbox c3 = new Checkbox (“VB”);
    Checkbox c4 = new Checkbox (“Oracle”);
    Checkbox c5 = new Checkbox (“SQL”);
    Checkbox c6 = new Checkbox (“ASP”);


    Public void init(){
    Add(c1);
    c2.setStatus(true);
    add(c2);
    add(c3);
    add(c4);
    add(c5);
    add(c6);
    }
    }

    More Java Articles
    More By Gayathri Gokul


     

  •    

    JAVA ARTICLES

    - New Object Initialization in Java
    - Adding Images With iTextSharp
    - Adding Columns With iTextSharp
    - Creating Simple PDF Files With iTextSharp
    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway