0% found this document useful (0 votes)
23 views

Practical No

bmfrebfr

Uploaded by

ayushspayments
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Practical No

bmfrebfr

Uploaded by

ayushspayments
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

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());

Checkbox checkbox = new Checkbox("Accept Terms");


CheckboxGroup radioGroup = new CheckboxGroup();
Checkbox radioButton1 = new Checkbox("Java", radioGroup, false);
Checkbox radioButton2 = new Checkbox("Python", radioGroup, false);
add(checkbox);
add(radioButton1);
add(radioButton2);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
setVisible(true);
}
public static void main(String[] args) {
new SimpleCheckBoxRadioButtonExample();
}
}

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:

5. Write a program to create three buttons OK RESET and CANCEL


Program:
import java.awt.*;
public class ButtonExample extends Frame {
ButtonExample() {
setSize(300, 150);
setTitle("Button Example");
setLayout(new FlowLayout());
Button okButton = new Button("OK");
Button resetButton = new Button("RESET");
Button cancelButton = new Button("CANCEL");
add(okButton);
add(resetButton);
add(cancelButton);
setVisible(true);
}
public static void main(String[] args) {
new ButtonExample();
}
}

Output:

You might also like