Discuss AWT components CheckBox, and CheckBoxGroup briefly.

 CheckBox Class

Checkbox control is used to turn an option on(true) or off(false). There is a label for the checkbox representing what the checkbox does. The state of a checkbox can be changed by clicking on it. each

Commonly used Constructors

Checkbox();//Creates a check box with an empty string for its label. Checkbox(String label); //Creates a check box with the specified label.

 Checkbox(String label, boolean state); Creates a check box with the specified label and sets the specified state.

Checkbox(String label, boolean state, CheckboxGroup group); //Constructs a Checkbox with the specified label, set to the specified state, and in the specified check box group.


Public Methods

String getLabel(); //Gets the label of this check box.

boolean getState(); //Determines whether this check box is in the on or off state.

Object[] getSelectedObjects(); //Returns an array (length 1) containing the checkbox label or null if the checkbox is not selected. 

void setLabel(String label); //Sets this check box's label to be the string argument.

void setState(boolean state); //Sets the state of this check box to the specified state.

void setCheckboxGroup (CheckboxGroup g); //Sets this check box's group to the specified check box group.

                                OR,

Java AWT Checkbox

The Checkbox class is used to create a checkbox. It is used to turn an option on (true) or off (false). Clicking on a Checkbox changes its state from "on" to "off" or from "off" to "on".


AWT Checkbox Class Declaration

public class Checkbox extends Component implements ItemSelectable, Accessible  


Java AWT Checkbox Example

In the following example, we are creating two checkboxes using the Checkbox(String label) construct and adding them into the Frame using add() method.

CheckboxExample1.java

// importing AWT class  

import java.awt.*;    

public class CheckboxExample1  

{    

// constructor to initialize  

     CheckboxExample1() {    

// creating the frame with the title  

       Frame f = new Frame("Checkbox Example");    

// creating the checkboxes  

        Checkbox checkbox1 = new Checkbox("C++");    

        checkbox1.setBounds(100, 100,  50, 50);    

        Checkbox checkbox2 = new Checkbox("Java", true);    

// setting location of checkbox in frame          

checkbox2.setBounds(100, 150,  50, 50);    

// adding checkboxes to frame  

        f.add(checkbox1);    

        f.add(checkbox2);    

// setting size, layout and visibility of frame  

        f.setSize(400,400);    

        f.setLayout(null);    

        f.setVisible(true);    

     }    

// main method  

public static void main (String args[])    

{    

    new CheckboxExample1();    

}    

}    



CheckBoxGroup Class

It is possible to create a set of mutually exclusive checkboxes in which one and only one check box in the group can be checked at any one time. These checkboxes are often called radio buttons. To create a set of mutually exclusive checkboxes, you must first define the group to which they will belong and then specify that group when we construct checkboxes.

Commonly used Constructors

CheckboxGroup(); //Creates a new instance of CheckboxGroup.


Commonly used Public Methods

Checkbox getSelected Checkbox(); //Gets the current choice from this check box group
void setSelectedCheckbox(Checkbox box); //Sets the currently selected check box in this group to be the specified check box.


                 OR,

Java AWT CheckboxGroup

The object of CheckboxGroup class is used to group together a set of Checkboxes. At a time only one check box button is allowed to be in the "on" state and the remaining check box button in the "off" state. It inherits the object class

AWT CheckboxGroup Class Declaration
public class CheckboxGroup extends Object implements Serializable  

Java AWT CheckboxGroup Example
import java.awt.*;    
public class CheckboxGroupExample    
{    
       CheckboxGroupExample(){    
       Frame f= new Frame("CheckboxGroup Example");    
        CheckboxGroup cbg = new CheckboxGroup();  
        Checkbox checkBox1 = new Checkbox("C++", cbg, false);    
        checkBox1.setBounds(100,100, 50,50);    
        Checkbox checkBox2 = new Checkbox("Java", cbg, true);    
        checkBox2.setBounds(100,150, 50,50);    
        f.add(checkBox1);    
        f.add(checkBox2);    
        f.setSize(400,400);    
        f.setLayout(null);    
        f.setVisible(true);    
     }    
public static void main(String args[])    
{    
    new CheckboxGroupExample();    
}    
}  


Comments

Popular posts from this blog

Pure Versus Partial EC

Suppose that a data warehouse for Big-University consists of the following four dimensions: student, course, semester, and instructor, and two measures count and avg_grade. When at the lowest conceptual level (e.g., for a given student, course, semester, and instructor combination), the avg_grade measure stores the actual course grade of the student. At higher conceptual levels, avg_grade stores the average grade for the given combination. a) Draw a snowflake schema diagram for the data warehouse. b) Starting with the base cuboid [student, course, semester, instructor], what specific OLAP operations (e.g., roll-up from semester to year) should one perform in order to list the average grade of CS courses for each BigUniversity student. c) If each dimension has five levels (including all), such as “student < major < status < university < all”, how many cuboids will this cube contain (including the base and apex cuboids)?

Short note on E-Government Architecture