0% found this document useful (0 votes)
256 views2 pages

Program - 8 // Writr A Program To Cerate A Table of Name of Student, Percentage and Grade of 10 Student Using Jtable

The document contains code to create two JTable objects to display student data and contact details. The first JTable displays the name, percentage, and grade for 10 students. The second displays the name, contact number, and city for 2 contacts. Both tables are added to a JScrollPane and container for display in a JFrame window.

Uploaded by

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

Program - 8 // Writr A Program To Cerate A Table of Name of Student, Percentage and Grade of 10 Student Using Jtable

The document contains code to create two JTable objects to display student data and contact details. The first JTable displays the name, percentage, and grade for 10 students. The second displays the name, contact number, and city for 2 contacts. Both tables are added to a JScrollPane and container for display in a JFrame window.

Uploaded by

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

program -8

// writr a program to
cerate a table of name of
student, Percentage and
grade of 10 student using
JTable
public class exer1 extends JFrame {
exer1() {
Container c = getContentPane();
c.setLayout(new BorderLayout());
String Title[] = { "Name", "Percentage", "Grade" };
Object Data[][] = {
{ "Swayam", "89", "A" },
{ "ManasI", "93", "B" },
{ "ManaN", "44", "B" },
{ "Manav", "34", "C" },
{ "Yash", "64", "B" },
{ "Pranav", "74", "B" },
{ "Smit", "85", "A" },
{ "Siddhant", "61", "C" },
{ "Jailal", "92", "A" },
{ "Shreyas", "24", "D" },
};
JTable jt = new JTable(Data, Title);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp
= new JScrollPane(jt, v, h);
c.add(jsp, BorderLayout.WEST);
}

public static void main(String args[]) {


exer1 j = new exer1(); j.setSize(300,
300); j.setVisible(true);
}
}

public class progcode1 extends JFrame {


progcode1() {
Container c = getContentPane();
c.setLayout(new BorderLayout());
String Title[] = { "Name", "Contact", "City" }; Object
Data[][] = {
{ "Swayam", "9146495650", "Nashik" },
{ "Mitsuha", "5562955648", "Kyoto" },
};
JTable jt = new JTable(Data, Title);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp
= new JScrollPane(jt, v, h);
c.add(jsp, BorderLayout.WEST);
}

public static void main(String args[]) {


progcode1 j = new progcode1();
j.setSize(300, 300); j.setVisible(true);
}
}

You might also like