-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable.java
44 lines (32 loc) · 1.16 KB
/
table.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import javax.swing.JTable;
import javax.swing.JScrollPane;
import javax.swing.JFrame;
class table{
JFrame frame;
JTable tb;
table(){
//Creating instance of JFrame
frame = new JFrame("JTable");
String rows[][] = { {"100","Torle","70000"},{"101","Phix","65000"},
{"102","Lazyflower","60000"},{"103","Tom","55000"},{"104","Charlie","50000"},{"105","Tarzou","45000"},{"106","Mysterio","40000"}};
String column[] = {"ID","NAME","POINTS"};
//Initializing JTable
tb = new JTable(rows,column);
tb.setBounds(30, 40, 500, 300);
//Adding JTable to Scrollpane
JScrollPane scroll = new JScrollPane(tb);
//Adding ScrollPane to frame
frame.add(scroll);
/* ScrollPane doesn't work with Layout set to null
*/
// frame.setLayout(null);
//sets the frame visibility to true
frame.setVisible(true);
//This method sets the width and height of the frame
frame.setSize(500,100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args){
new table();
}
}