0% found this document useful (0 votes)
9 views8 pages

Practical 6-9

Uploaded by

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

Practical 6-9

Uploaded by

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

Practical 7

import java.awt.*;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
class Ex7 extends JFrame
{
Ex7()
{
DefaultMutableTreeNode Style=new DefaultMutableTreeNode("Style");
DefaultMutableTreeNode Color=new DefaultMutableTreeNode("Color");
DefaultMutableTreeNode Font=new DefaultMutableTreeNode("Font");
Style.add(Color);
Style.add(Font);
DefaultMutableTreeNode Red=new DefaultMutableTreeNode("Red");
DefaultMutableTreeNode Blue=new DefaultMutableTreeNode("Blue");
Color.add(Red);
Color.add(Blue);
DefaultMutableTreeNode Font1=new DefaultMutableTreeNode("Times New
Roman");
DefaultMutableTreeNode Font2=new DefaultMutableTreeNode("calibari");
Font.add(Font1);
Font.add(Font2);
JTree jt=new JTree(Style);
add(jt);
setVisible(true);
setSize(300,400);
}
public static void main(String [] args)
{
Ex7 e=new Ex7();
}
}
Output:
Practical 8
import javax.swing.*;
class Ex8 extends JFrame {
Ex8() {
String[][] row = {{"abc", "1", "5000"},
{"xyz", "2", "2000"}};
String[] col = {"Name", "ID", "Salary"};
JTable t = new JTable(row, col);
t.setBounds(40, 30, 220, 50);
JScrollPane jp=new JScrollPane(t);
add(jp);
setLayout(null);
setSize(300, 400);
setVisible(true);
}
public static void main(String[] args) {
Ex8 e = new Ex8();
}
}Output:
Practical 6
import javax.swing.*;
import java.awt.*;
public class Practical6 extends JFrame {
Practical6() {
JLabel j1 = new JLabel("Languages");
JComboBox<String> jb = new JComboBox<>();
jb.addItem("English");
jb.addItem("Marathi");
jb.addItem("Hindi");
jb.addItem("Sanskrit");
setLayout(new FlowLayout());
add(j1);
add(jb);
setSize(300, 400);
setVisible(true);
}
public static void main(String[] args) {
new Practical6();
}
}Output:
Practical 9
import javax.swing.*;
import java.awt.*;
class Ex9 extends JFrame
{
int i=0;
JProgressBar jb;
Ex9()
{
setTitle("JFrame Example");
jb=new JProgressBar(0,2000);
jb.setBounds(40,40,160,30);
jb.setValue(0);
jb.setStringPainted(true);
add(jb);
setSize(250,150);
setLayout(null);
setVisible(true);
}
void iterate()
{
while(i<2000)
{
jb.setValue(i);
i+=40;
try {
Thread.sleep(150);
}
catch (InterruptedException e)
{}
}
}
public static void main(String args[])
{
Ex9 e=new Ex9();
e.iterate();
}
}
Output:

You might also like