0% found this document useful (0 votes)
6 views5 pages

JPR 14

The document contains multiple Java Swing applications demonstrating various GUI components. It includes examples of radio buttons, text fields, buttons, lists, and checkboxes. Each example creates a JFrame with specific components and layouts to showcase their functionality.

Uploaded by

shindearyan226
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

JPR 14

The document contains multiple Java Swing applications demonstrating various GUI components. It includes examples of radio buttons, text fields, buttons, lists, and checkboxes. Each example creates a JFrame with specific components and layouts to showcase their functionality.

Uploaded by

shindearyan226
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

Design an applet/application to demonstrate the use of Radio Button


and Checkbox.

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

ButtonGroup rall = new ButtonGroup();


rall.add(r1);
rall.add(r2);

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:

3. Write a program to create three Buttons with Caption OK RESET and


CANCEL
import java.util.*;
import java.awt.*;
import javax.swing.*;

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:

4. Develop an applet/application using List components to add names of


10 different cities.
import java.util.*;
import java.awt.*;
import javax.swing.*;

class ListDemo{
ListDemo(){
JFrame fr = new JFrame();

String[] cities = {
"Pune", "Mumbai", "Satara", "Jalgaon", "Sangli",
"Nashik", "Nagpur", "Sambhaji Nagar", "Kolhapur", "Solapur"
};

JList<String> l = new JList<>(cities);


JScrollPane s = new JScrollPane(l);

l.setVisibleRowCount(5);

fr.add(new JLabel("Select City: "));


fr.add(s);

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:

5. Develop applet/application to select multiple names of news papers.

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"};

JList<String> l = new JList<>(News);


JScrollPane s = new JScrollPane(l);

l.setVisibleRowCount(3);

fr.add(new JLabel("Select Newspaper: "));


fr.add(s);

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:

You might also like