0% found this document useful (0 votes)
6 views3 pages

Ajp Prac 8

Uploaded by

saeedarwatkar
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)
6 views3 pages

Ajp Prac 8

Uploaded by

saeedarwatkar
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/ 3

Practical No.

8
 Program Code:

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


import java.awt.*;
import javax.swing.*;
/*<applet code= "saee_table1" width=500 height=500>
</applet>*/

public class saee_table1 extends JApplet


{
public void init()
{
Container c = getContentPane();
final Object data[][]={{"Saee","18","1234567890"} , {"Soham","14","9870654321"}};
final String colhead[]={"Name","Age","Mobile No."};
JTable jt = new JTable(data,colhead);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h= ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(jt,v,h);
c.add(jsp);
}
}

OUTPUT:
2) Write a program to generate the following output.
import java.awt.*;
import javax.swing.*;
/*<applet code= "saee_table2" width=500 height=500>
</applet>*/

public class saee_table2 extends JApplet


{
public void init()
{
Container c = getContentPane();
final Object data[][]={{"101","Amit","670000"} , {"102","Jai","780000"} , {"103","Sachin","700000"}};
final String colhead[]={"ID","Name","Salary"};
JTable jt = new JTable(data,colhead);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h= ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(jt,v,h);
c.add(jsp);
}
}

OUTPUT:
 Exercise:
1) Write a program to create a table of Name of Student, Percentage and Grade of 10 students
using JTable.

import java.awt.*;
import javax.swing.*;
/*<applet code= "saee_table3" width=500 height=500>
</applet>*/

public class saee_table3 extends JApplet


{
public void init()
{
Container c = getContentPane();
final Object data[][]={ {"Saee","97%","A+"} , {"Soham","90%","A"} , {"Sarthak","85%","B"} ,
{"Sakshi","80%","C+"} , {"Jay","88%","B+"} , {"Ajay","98%","A+"} ,
{"Vijay","80%","C+"} , {"Ranvijay","67%","E"} , {"Digvijay","88%","B+"} , {"Arjun","67%","E"} };
final String colhead[]={"NAME","PERCENTAGE","GRADE"};
JTable jt = new JTable(data,colhead);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h= ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(jt,v,h);
c.add(jsp);
}
}
OUTPUT:

You might also like