source file name: TableDemo.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class TableDemo extends JFrame
{
public TableDemo()
{
setLayout(null);
JLabel lb=new JLabel("Student's Qualification");
String cols[]={"std.","name","year","grade"};
String[][] data={
{"SSC","UESchool","2010","7"},
{"HSC","DBJ","2012","6.5"},
{"BSC","DBJ","2015","6.2"}
};
JTable tb=new JTable(data,cols);
JPanel panel = new JPanel();
lb.setBounds(50,50,150,20);
JScrollPane sp=new JScrollPane(tb);
sp.setBounds(50,90,200,200);
add(lb);add(sp);
}
public static void main(String as[])
{
TableDemo f=new TableDemo();
f.setTitle("Table program");
f.setSize(300,300);
f.setVisible(true);
}
}
Output:
0 Comments
Post a Comment