You are on page 1of 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