Aim: Write A Program To Demonstrate The Use of AWT Components. X. Program Code
Aim: Write A Program To Demonstrate The Use of AWT Components. X. Program Code
/*
<APPLET Code="RadioButtonTest" Width=500 Height=200>
</APPLET>
*/
add(chkRed);
add(chkBlue);
add(chkYellow);
add(chkGreen);
add(chkOrange);
}
}
Output :
2. Design an applet/application to create form using Text Field, Text Area,
Button and Label.
Code :
import java.awt.*;
XIII. Exercise
1. Develop a program using Label to display message “Welcome to Java”
Code :
import java.awt.*;
class L
{
L()
{
Frame f=new Frame();
Label l1=new Label("Welcome to Java");
l1.setBounds(100,50,120,80);
f.add(l1);
f.setSize(500,500);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String a[])
{
new L();
}
}
OutPut:
2. Develop a program to select multiple languages known to user. (e. g
Marathi, Hindi, English, Sanskrit).
Code :
import java.awt.*;
public class Exp_1_4
{
Exp_1_4()
{
Frame f= new Frame();
Choice c=new Choice();
c.setBounds(100,100, 75,75);
c.add("Marathi");
c.add("Hindi");
c.add("English");
c.add("Sanskrit");
f.add(c);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String args[])
{
new Exp_1_4();
}
}
OutPut :
3. Write a program to create three Buttons with Caption OK, RESET and
CANCEL.
Code :
import java.awt.*;
class Exp_1_5 extends Frame
{
Button b1,b2,b3;
Exp_1_5()
{
this.setLayout(null);
b1=new Button("OK");
b2=new Button("RESET");
b3=new Button("CANCEL");
this.add(b1);
this.add(b2);
this.add(b3);
b1.setBounds(100,260,70,40);
b2.setBounds(180,260,70,40);
b3.setBounds(260,260,70,40);
}
public static void main(String args[])
{
Exp_1_5 ml=new Exp_1_5();
ml.setVisible(true);
ml.setSize(400,400);
ml.setTitle("my login window");
}
}
OutPut :