Creating button control

Frame Creation- 

Frame can be created using two methods- 

1. Inherites Frame class. 

2. Create the object of Frame class. 

Here we will create button using Frame(through second method)- 

import java.awt.*; 

class first 

first() 

//Create an object of Frame 

Frame F1= new Frame(); 

//Create an object of button

Button b1= new Button ("click me");  

//Set the attribute of button

//setBounds (left,top,width,height);

b1.setBounds(50,80,80,80);  

//add() is used to add the button control to Frame

F1.add(b1); 

//Call the functions using Frame's object

F1.setSize(400,400); 

F1.setLayout(null); 

F1.setVisible(true);  


public static void main(String args[]) 

first Fst1= new first(); 

}

Comments

Popular posts from this blog

Creating Control Programs