-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScrollableTable.java
More file actions
86 lines (61 loc) · 1.82 KB
/
ScrollableTable.java
File metadata and controls
86 lines (61 loc) · 1.82 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
*
*/
package swing;
import java.awt.BorderLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
/**
* @author rutpatel
*
*/
public class ScrollableTable {
public static void main(String[] args) {
JFrame jFrame = new JFrame("Scrollable Table");
jFrame.setLayout(new BorderLayout());
JButton b1 = new JButton("B1");
JButton b2 = new JButton("B2");
String[] columnNames = { "Name", "Roll Number", "Department", "School Name", "City Name" };
String[][] data = { { "Kundan Kumar Jha", "4031", "CSE", "BVM", "New Jersey" },
{ "Anand Jha", "6014", "IT", "BVM", "New Jersey" } };
JTable t1 = new JTable(data, columnNames);
JScrollPane jsp = new JScrollPane(t1, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
t1.addMouseListener(new MouseListener() {
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseClicked(MouseEvent e) {
System.out.println(e.getPoint());
}
});
JButton b4 = new JButton("B4");
JButton b5 = new JButton("B5");
jFrame.add(b1, BorderLayout.NORTH);
jFrame.add(b2, BorderLayout.SOUTH);
jFrame.add(jsp, BorderLayout.CENTER);
jFrame.add(b4, BorderLayout.EAST);
jFrame.add(b5, BorderLayout.WEST);
jFrame.setSize(500, 300);
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jFrame.setVisible(true);
}
}