0% found this document useful (0 votes)
17 views4 pages

Practical No. 8

Uploaded by

ganeshkumbhar638
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)
17 views4 pages

Practical No. 8

Uploaded by

ganeshkumbhar638
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/ 4

Q. Develop a program to demonstrate the use of JTable.

import javax.swing.*;
public class P8b1 {
JFrame f ;
P8b1(){
f = new JFrame("JTables Execution");
String data[][] ={ {"101","Siddhi","Bolaikar"},
{"102","Ganesh","Kumbhar"}
};
String column[] = {"Roll no","First Name","Last Name"};

JTable j = new JTable(data, column);


j.setBounds(40,50,100,300);
JScrollPane jsp = new JScrollPane(j);
f.add(jsp);
f.setSize(500,500);
f.setVisible(true);
f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new P8b1();
}
}
Q. Write a program code to generate the following output.
import javax.swing.*;
public class P8b2 {
JFrame f ;
P8b2(){
f = new JFrame("JTables Execution");
String data[][] ={ {"101","Amit","670000"},
{"102","Jai","780000"},
{"101","Sachin","700000"}
};
String column[] = {"ID","Name","Salary"};

JTable j = new JTable(data, column);


j.setBounds(40,50,100,300);
JScrollPane jsp = new JScrollPane(j);
f.add(jsp);
f.setSize(500,500);
f.setVisible(true);
f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new P8b2();
}
}
Q1. Write a Java program to create a table of Name of Student, Percentage and Grade of 10
students using JTable.
import javax.swing.*;
public class P8e1 {
JFrame f ;
P8e1(){
f = new JFrame("JTables Execution");
String data[][] ={ {"ABC","89%","A"},
{"PQR","95%","A+"},
{"XYZ","85%","A"},
{"SPD","75%","B+"},
{"SDF","67%","B"},
{"RTY","98%","A+"},
{"YTH","45%","C"},
{"UYT","55%","C+"},
{"SWR","32%","Fail"},
{"RVG","77%","B+"}
};
String column[] = {"Name of Student","Percentage","Grade"};

JTable j = new JTable(data, column);


j.setBounds(40,50,300,500);
JScrollPane jsp = new JScrollPane(j);
f.add(jsp);
f.setSize(500,500);
f.setVisible(true);
f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new P8e1();
}
}

You might also like