-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathTableColumnManagerDemo.java
More file actions
62 lines (54 loc) · 1.52 KB
/
TableColumnManagerDemo.java
File metadata and controls
62 lines (54 loc) · 1.52 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
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.table.*;
public class TableColumnManagerDemo extends JPanel
{
private TableColumnManager marquee;
private JSpinner scrollFrequency;
private JSpinner scrollAmount;
private JSpinner preferredWidth;
private JSpinner wrapAmount;
TableColumnManagerDemo()
{
setLayout( new BorderLayout(10, 10) );
setBorder( new EmptyBorder(10, 10, 10, 10) );
JComponent center = createCenterPanel();
add(center, BorderLayout.CENTER);
}
public JComponent createCenterPanel()
{
JTable table = new JTable( new DefaultTableModel(15, 15) )
{
public Class getColumnClass(int column)
{
int modelColumn = convertColumnIndexToModel( column );
return (modelColumn == 0) ? Integer.class : Object.class;
}
};
table.setPreferredScrollableViewportSize(table.getPreferredSize());
TableColumnManager tcm = new TableColumnManager(table);
tcm.hideColumn(2);
tcm.hideColumn("E");
// tcm.showColumn("C");
tcm.showColumn(2);
return new JScrollPane( table );
}
public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
public static void createAndShowGUI()
{
JFrame frame = new JFrame("Table Column Manager");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add( new TableColumnManagerDemo() );
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}