[go: up one dir, main page]

0% found this document useful (0 votes)
15 views10 pages

Practical 6

Practical

Uploaded by

jagtaptanay80
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)
15 views10 pages

Practical 6

Practical

Uploaded by

jagtaptanay80
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/ 10

Practical 6

import javax.swing.*;

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

cb.setBounds(50,50,120,20);

f.add(cb);

f.setLayout(null);

f.setSize(400,500);

f.setVisible(true); }

public static void main(String[] args)

new select();

Output :
Q2. Develop a program to demonstrate the use of ScrollPane in Swings

import javax.swing.*;

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

frame.add(scrollPane);

frame.setSize(300, 300);

frame.setVisible(true);

Output :
Practical 7
import javax.swing.*;

import javax.swing.tree.*;

import java.awt.*;

public class JTreeDemo

public static void main(String[] args) {

JFrame JFrameMain = new JFrame();

JFrameMain.setVisible(true);

JFrameMain.setSize(400,400);

DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("India");

DefaultMutableTreeNode maharashtraNode = new DefaultMutableTreeNode("Maharashtra");

DefaultMutableTreeNode gujrathNode = new DefaultMutableTreeNode("Gujrath");

rootNode.add(maharashtraNode);

rootNode.add(gujrathNode);

DefaultMutableTreeNode mumbaiSubNode = new DefaultMutableTreeNode("Mumbai");

DefaultMutableTreeNode puneSubNode = new DefaultMutableTreeNode("Pune");

DefaultMutableTreeNode nashikSubNode = new DefaultMutableTreeNode("Nashik");

DefaultMutableTreeNode nagpurSubNode = new DefaultMutableTreeNode("Nagpur");

maharashtraNode.add(mumbaiSubNode);

maharashtraNode.add(puneSubNode);

maharashtraNode.add(nashikSubNode);

maharashtraNode.add(nagpurSubNode);

JTree tree = new JTree(rootNode);

JFrameMain.add(tree);

}
}

Output :
Practical No . 8
import java.awt.*;

import javax.swing.*;

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

jf.add(jsp);

jf.setSize(550, 250);

jf.setTitle("Practical_8");

jf.setLayout(new FlowLayout());

jf.setVisible(true);

public static void main(String[] args)

table t = new table();

}
Output :
Practical No. 9
Q1.Develop a program to demonstrate the use of ProgressBar

import javax.swing.*;

public class ProgressBarExample extends JFrame{

JProgressBar jb;

int i=0,num=0;

ProgressBarExample(){

jb=new JProgressBar(0,2000);

jb.setBounds(40,40,160,30);

jb.setValue(0);

jb.setStringPainted(true);

add(jb);

setSize(250,150);

setLayout(null);

public void iterate(){

while(i<=2000){

jb.setValue(i);

i=i+20;

try {Thread.sleep(150);}catch(Exception e){}

public static void main(String[] args) {

ProgressBarExample m=new ProgressBarExample();

m.setVisible(true);

m.iterate();

}
Output :
Q2. Write a program using JProgressBar to show progress of Progress Bar when user clicks on JButton in Java
Programming

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.*;

class pbar extends JFrame implements ActionListener {

JProgressBar pb;

JButton b1 = new JButton("LOGIN");

pbar() {

setLayout(null);

pb = new JProgressBar(1, 100);

pb.setValue(0);

pb.setStringPainted(true);

b1.setBounds(20, 20, 80, 25);

pb.setBounds(110, 20, 200, 25);

pb.setVisible(false);

add(b1);

add(pb);

b1.addActionListener(this);

setResizable(false);

setDefaultCloseOperation(EXIT_ON_CLOSE);

public void actionPerformed(ActionEvent e) {

int i = 0;

if (e.getSource() == b1) {

pb.setVisible(true);

try {

while (i <= 100) {

Thread.sleep(50);

pb.paintImmediately(0, 0, 200, 25);

pb.setValue(i);
i++;

} catch (Exception e1) {

System.out.print("Caughted exception is =" + e1);

public class Progress1 {

public static void main(String arg[]) {

pbar m = new pbar();

m.setSize(330, 100);

m.setVisible(true);

Output :

You might also like