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

Practical NO 8

The document provides a Java program that creates a JTable within a JApplet. It defines column headers and populates the table with data about students, including their roll numbers, names, and cities. The JTable is added to a JScrollPane to enable scrolling as needed.
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)
5 views3 pages

Practical NO 8

The document provides a Java program that creates a JTable within a JApplet. It defines column headers and populates the table with data about students, including their roll numbers, names, and cities. The JTable is added to a JScrollPane to enable scrolling as needed.
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.

08
Write A program to Create JTable.
import java.awt.*;

import javax.swing.*;

/*<applet code="JTabledemo" width=600 height=500>

</applet>*/

public class JTabledemo extends JApplet

public void start()

Container ct=getContentPane();

ct.setLayout(new BorderLayout());

final String[]colHeads={"Roll","Name","City"};

final Object[][]data={

{"1","sai","veer"},

{"2","vaishnavi","bhor"},

{"3","sakshi","wai"},

{"4","samiksha","pargon"},

{"5","suhani","veer"},

{"6","snehal","veer"},

{"7","Ranu","dombivali"}

};
JTable table=new JTable(data,colHeads);

int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;

int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;

JScrollPane jsp=new JScrollPane(table,v,h);

ct.add(jsp,BorderLayout.CENTER);

You might also like