JPR 14
JPR 14
import java.util.*;
import java.awt.*;
import javax.swing.*;
class ButtDemo{
ButtDemo(){
JFrame fr = new JFrame();
JRadioButton r1 = new JRadioButton("Male");
JRadioButton r2 = new JRadioButton("Female");
fr.add(r1);
fr.add(r2);
fr.getContentPane().setBackground(Color.CYAN);
fr.setSize(500,500);
fr.setLayout(new FlowLayout());
fr.setVisible(true);
}
public static void main(String[] args){
ButtDemo bd = new ButtDemo();
}
}
OUTPUT:
2. Design an applet/application to create form using Text Filed, Text Area,
Button and Label
import java.util.*;
import java.awt.*;
import javax.swing.*;
class TextDemo{
TextDemo(){
JFrame fr = new JFrame();
JTextField t = new JTextField();
JLabel l = new JLabel("Enter Name: ");
JButton b = new JButton("Submit");
b.setBounds(190,150,80,30);
l.setBounds(50,100,100,30);
t.setBounds(160,100,130,30);
fr.add(b);
fr.add(t);
fr.add(l);
fr.getContentPane().setBackground(Color.CYAN);
fr.setSize(500,500);
fr.setLayout(null);
fr.setVisible(true);
}
public static void main(String[] args){
TextDemo bd = new TextDemo();
}
}
OUTPUT:
class ThreeButtons{
ThreeButtons(){
JFrame fr = new JFrame();
JButton b1 = new JButton("OK");
JButton b2 = new JButton("RESET");
JButton b3 = new JButton("CANCEL");
b1.setBounds(100,90,80,30);
b2.setBounds(100,130,80,30);
b3.setBounds(100,170,80,30);
fr.add(b1);
fr.add(b2);
fr.add(b3);
fr.getContentPane().setBackground(Color.CYAN);
fr.setSize(500,500);
fr.setLayout(null);
fr.setVisible(true);
}
public static void main(String[] args){
ThreeButtons bd = new ThreeButtons();
}
}
OUTPUT:
class ListDemo{
ListDemo(){
JFrame fr = new JFrame();
String[] cities = {
"Pune", "Mumbai", "Satara", "Jalgaon", "Sangli",
"Nashik", "Nagpur", "Sambhaji Nagar", "Kolhapur", "Solapur"
};
l.setVisibleRowCount(5);
fr.getContentPane().setBackground(Color.CYAN);
fr.setSize(500,500);
fr.setLayout(new FlowLayout());
fr.setVisible(true);
}
public static void main(String[] args){
ListDemo bd = new ListDemo();
}
}
OUTPUT:
import java.util.*;
import java.awt.*;
import javax.swing.*;
class NewspaperList{
NewspaperList(){
JFrame fr = new JFrame();
String[] News = {
"The Times of India", "The Hindu", "Indian Express",
"Hindustan Times",
"The Economic Times","Lokmat", "Sakal", "The Telegraph"};
l.setVisibleRowCount(3);
fr.getContentPane().setBackground(Color.CYAN);
fr.setSize(500,500);
fr.setLayout(new FlowLayout());
fr.setVisible(true);
}
public static void main(String[] args){
NewspaperList bd = new NewspaperList();
}
}
OUTPUT: