Practical No
Practical No
1
1. Design an applet to demonstrate the use of Radio Button and Checkbox.
Program:
import java.awt.*;
public class SimpleCheckBoxRadioButtonExample extends Frame {
SimpleCheckBoxRadioButtonExample() {
setSize(300, 150);
setTitle("Simple Checkbox & Radio Button Example");
setLayout(new FlowLayout());
Output:
2. Design an applet application to create form using text fields , text area,
Button and Label.
Program:
import java.awt.*;
import java.awt.event.*;
public class SimpleFormExample extends Frame implements ActionListener {
TextField nameField;
TextArea addressArea;
Button submitButton;
Label resultLabel;
SimpleFormExample() {
setSize(400, 300);
setTitle("Simple Form Example");
setLayout(new FlowLayout());
setVisible(true);
add(new Label("Name:"));
nameField = new TextField(20);
add(nameField);
add(new Label("Address:"));
addressArea = new TextArea(5, 20);
add(addressArea);
submitButton = new Button("Submit");
submitButton.addActionListener(this);
add(submitButton);
resultLabel = new Label();
add(resultLabel);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);}
});
}
public void actionPerformed(ActionEvent ae) {
String name = nameField.getText();
String address = addressArea.getText();
resultLabel.setText("Name: " + name + ", Address: " + address);
}
public static void main(String[] args) {
new SimpleFormExample();
}}
Output:
3. Develop a Program using label to display “Welcome to java ”.
Program:
import java.awt.*;
public class WelcomeLabelExample extends Frame
WelcomeLabelExample() {
setSize(300, 150);
setTitle("Welcome Message");
setLayout(new FlowLayout());
Label welcomeLabel = new Label("Welcome to Java");
add(welcomeLabel);
setVisible(true);
}
public static void main(String[] args) {
new WelcomeLabelExample();
}
}
Output:
4.Develop a program to select a multiple language known to user (eg. Marathi, Hindi,
Sanskrit, English)
Program:
import java.awt.*;
import java.awt.event.*;
public class SimpleCheckBoxRadioButtonExample extends Frame {
SimpleCheckBoxRadioButtonExample() {
setSize(300, 150);
setLayout(new FlowLayout());
Checkbox checkbox = new Checkbox("Marathi");
Checkbox checkbox1 = new Checkbox("Hindi");
Checkbox checkbox2 = new Checkbox("English");
Checkbox checkbox3 = new Checkbox("Sanskrit");
Button b=new Button("SUBMIT");
add(checkbox);
add(checkbox1);
add(checkbox2);
add(checkbox3);
add(b);
setVisible(true);
}
public static void main(String[] args) {
new SimpleCheckBoxRadioButtonExample();
}
}
Output:
Output: