Java AWT Checkbox


Changing the state of an item is known as an event. For instance, click on catch, hauling mouse and so forth. The java.awt.event bundle gives numerous occasion classes and Listener interfaces for event handling.

AWT Checkbox Class Declaration

  1. public class Checkbox extends Component implements ItemSelectable, Accessible  

Java AWT class declaration

  1. public class Panel extends Container implements Accessible  

Java AWT Panel Example

import java.awt.*;  
  • public class PanelExample {  
  •      PanelExample()  
  •         {  
  •         Frame f= new Frame("Panel Example");    
  •         Panel panel=new Panel();  
  •         panel.setBounds(40,80,200,200);    
  •         panel.setBackground(Color.gray);  
  •         Button b1=new Button("Button 1");     
  •         b1.setBounds(50,100,80,30);    
  •         b1.setBackground(Color.yellow);   
  •         Button b2=new Button("Button 2");   
  •         b2.setBounds(100,100,80,30);    
  •         b2.setBackground(Color.green);   
  •         panel.add(b1); panel.add(b2);  
  •         f.add(panel);  
  •         f.setSize(400,400);    
  •         f.setLayout(null);    
  •         f.setVisible(true);    
  •         }  
  •         public static void main(String args[])  
  •         {  
  •         new PanelExample();  
  •         }  
  • }  
  • Output:

    java awt Panel example 1





    javacodegeeks is optimized for learning.© javacodegeeks .
    All Right Reserved and you agree to have read and accepted our term and condition