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

Ajp 8

The document describes a student's experiment involving using JTable in Java programs. It includes code to create a simple JTable with sample data. It then provides an exercise asking the student to write a program to create a JTable displaying the name, percentage, and grade of 10 students. The student provides the code for this program which creates and displays the JTable as requested.

Uploaded by

Ganesh Ekambe
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)
93 views4 pages

Ajp 8

The document describes a student's experiment involving using JTable in Java programs. It includes code to create a simple JTable with sample data. It then provides an exercise asking the student to write a program to create a JTable displaying the name, percentage, and grade of 10 students. The student provides the code for this program which creates and displays the JTable as requested.

Uploaded by

Ganesh Ekambe
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

Name of Student: Ekambe Ganesh Roll No.

: 53

Experiment No.: 08 DOS:

*Program Code

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

import javax.swing.*;
public class Pr8 {
JFrame f;
Pr8(){
f=new JFrame();
String data[][]={ {"22517","1 HOUR","CO5I"},
{"22518","1 HOUR","CO5I"},
{"22519","2 HOUR","CO5I"},
{"22316","2 HOUR","CO3I"},
{"22317","2 HOUR","CO3I"}};
String column[]={"Subject","Time","Class"};
JTable jt=new JTable(data,column);
jt.setBounds(30,40,200,300);
JScrollPane sp=new JScrollPane(jt);
f.add(sp);
f.setSize(300,400);
f.setVisible(true);
}
public static void main(String[] args) {
new Pr8();
}
}

Output
Name of Student: Ekambe Ganesh Roll No.: 53

Experiment No.: 08 DOS:

2. Write a program code to generate the following output.

import javax.swing.*;
public class Pr8ex1 {
JFrame f;
Pr8ex1(){
f=new JFrame();
String data[][]={ {"101","Amit","670000"},
{"102","Jai","780000"},
{"101","Sachin","700000"}};
String column[]={"ID","NAME","SALARY"};
JTable jt=new JTable(data,column);
jt.setBounds(30,40,200,300);
JScrollPane sp=new JScrollPane(jt);
f.add(sp);
f.setSize(300,400);
f.setVisible(true);
}
public static void main(String[] args) {
new Pr8ex1();
}
}

Output
Name of Student: Ekambe Ganesh Roll No.: 53

Experiment No.: 08 DOS:

xEXERCISE:

1. Write a Java program to create a table of Name of Student, Percentage and


Grade of 10 students using JTable.

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
public class Pr8ex2 {
JFrame f;
Pr8ex2(){
f=new JFrame();
String data[][]={ {"Ganesh","95","A+"},
{"Yash","80","A+"},
{"Rahul","85","A+"},
{"Durgesh","72","B"},
{"Shravan","75","B"},
{"Aditya","90","A+"},
{"Rohit","66","B"},
{"Ranjith","62","c"},
{"Abhijeet","50","c"},
{"Madhav","92","A+"}};
String column[]={"Student","Percentage","Grade"};
JTable jt=new JTable(data,column);
jt.setBounds(30,40,200,300);
JScrollPane sp=new JScrollPane(jt);
Name of Student: Ekambe Ganesh Roll No.: 53

Experiment No.: 08 DOS:

f.add(sp);
f.setSize(300,400);
f.setVisible(true);
}
public static void main(String[] args) {
new Pr8ex2();
}
}

Output

You might also like