Practical 6
import [Link].*;
public class select
JFrame f;
Exp_6_2()
f=new JFrame("States of India");
String country[]={"Maharashtra","Goa","Gujarat","Assam","Hyderabad","Delhi"};
JComboBox cb=new JComboBox(country);
[Link](50,50,120,20);
[Link](cb);
[Link](null);
[Link](400,500);
[Link](true); }
public static void main(String[] args)
new select();
Output :
Q2. Develop a program to demonstrate the use of ScrollPane in Swings
import [Link].*;
public class ScrollPaneExample {
public static void main(String[] args) {
JFrame frame = new JFrame("ScrollPane Example");
JTextArea textArea = new JTextArea(20, 20);
JScrollPane scrollPane = new JScrollPane(textArea);
[Link](scrollPane);
[Link](300, 300);
[Link](true);
Output :
Practical 7
import [Link].*;
import [Link].*;
import [Link].*;
public class JTreeDemo
public static void main(String[] args) {
JFrame JFrameMain = new JFrame();
[Link](true);
[Link](400,400);
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("India");
DefaultMutableTreeNode maharashtraNode = new DefaultMutableTreeNode("Maharashtra");
DefaultMutableTreeNode gujrathNode = new DefaultMutableTreeNode("Gujrath");
[Link](maharashtraNode);
[Link](gujrathNode);
DefaultMutableTreeNode mumbaiSubNode = new DefaultMutableTreeNode("Mumbai");
DefaultMutableTreeNode puneSubNode = new DefaultMutableTreeNode("Pune");
DefaultMutableTreeNode nashikSubNode = new DefaultMutableTreeNode("Nashik");
DefaultMutableTreeNode nagpurSubNode = new DefaultMutableTreeNode("Nagpur");
[Link](mumbaiSubNode);
[Link](puneSubNode);
[Link](nashikSubNode);
[Link](nagpurSubNode);
JTree tree = new JTree(rootNode);
[Link](tree);
}
}
Output :
Practical No . 8
import [Link].*;
import [Link].*;
public class table {
public table()
JFrame jf = new JFrame();
String rows[][] = { { "Tanay Jagtap", "69", "C" },
{ "Pranav Thakur", "98", "A" },
{ "Krushna Zate", "90", "B" },
{ "Sahil Chavan", "75", "B" } ,
{ "Nitin Pawar", "98", "A" },
{ "Digambar Lokhande", "88", "A" },
{ "Siddhant Sonawane", "78", "B" },
{ "Kunal Ghude", "92", "A" },
{ "Pratik Gaikar", "91", "A" },
{ "Arya Kadale", "83", "A" } };
String cols[] = { "Name", "Percentage", "Grades" };
JTable jt = new JTable(rows, cols);
JScrollPane jsp = new JScrollPane(jt);
[Link](jsp);
[Link](550, 250);
[Link]("Practical_8");
[Link](new FlowLayout());
[Link](true);
public static void main(String[] args)
table t = new table();
}
Output :
Practical No. 9
[Link] a program to demonstrate the use of ProgressBar
import [Link].*;
public class ProgressBarExample extends JFrame{
JProgressBar jb;
int i=0,num=0;
ProgressBarExample(){
jb=new JProgressBar(0,2000);
[Link](40,40,160,30);
[Link](0);
[Link](true);
add(jb);
setSize(250,150);
setLayout(null);
public void iterate(){
while(i<=2000){
[Link](i);
i=i+20;
try {[Link](150);}catch(Exception e){}
public static void main(String[] args) {
ProgressBarExample m=new ProgressBarExample();
[Link](true);
[Link]();
}
Output :
Q2. Write a program using JProgressBar to show progress of Progress Bar when user clicks on JButton in Java
Programming
import [Link];
import [Link];
import [Link].*;
class pbar extends JFrame implements ActionListener {
JProgressBar pb;
JButton b1 = new JButton("LOGIN");
pbar() {
setLayout(null);
pb = new JProgressBar(1, 100);
[Link](0);
[Link](true);
[Link](20, 20, 80, 25);
[Link](110, 20, 200, 25);
[Link](false);
add(b1);
add(pb);
[Link](this);
setResizable(false);
setDefaultCloseOperation(EXIT_ON_CLOSE);
public void actionPerformed(ActionEvent e) {
int i = 0;
if ([Link]() == b1) {
[Link](true);
try {
while (i <= 100) {
[Link](50);
[Link](0, 0, 200, 25);
[Link](i);
i++;
} catch (Exception e1) {
[Link]("Caughted exception is =" + e1);
public class Progress1 {
public static void main(String arg[]) {
pbar m = new pbar();
[Link](330, 100);
[Link](true);
Output :