-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResumeTableView.java
More file actions
95 lines (59 loc) · 2.58 KB
/
Copy pathResumeTableView.java
File metadata and controls
95 lines (59 loc) · 2.58 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
87
88
89
90
91
92
93
94
95
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;
public class ResumeTableView extends JPanel {
JTable table;
JScrollPane scrollPane;
// JTable resumeTable;
// JScrollPane resumeScrollPane;
public ResumeTableView(ScheduleTableCreator stc) {
String[] columns = new String[]{"Nr.", "Articol de lucrare", "um", "cantitate", "ore"};
String[][] data = stc.getTasksTable();
JPanel gridbagPanel = new JPanel();
//this.setLayout(new GridBagLayout());
GridBagConstraints gc = new GridBagConstraints();
gc.anchor = GridBagConstraints.EAST;
table = new JTable(data,columns);
OrarGridViewTableModel orarGridViewTableModel = new OrarGridViewTableModel(data,columns);
table.setModel(orarGridViewTableModel);
scrollPane = new JScrollPane(table);
table.setFillsViewportHeight(true);
//table.setRowSelectionAllowed(false);
//table.getTableHeader().setResizingAllowed(true);
//table.getTableHeader().setReorderingAllowed(false);
//table.setColumnSelectionAllowed(false);
//table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
TableColumnAdjuster tca = new TableColumnAdjuster(table);
tca.adjustColumns();
//resize();
JPanel bottomPanel = new JPanel(new GridLayout(1,3));
// bottomPanel.add(new JPanel());
// bottomPanel.add(new JPanel());
bottomPanel.add(scrollPane);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
}
public void resize(){
//resize after changes have been made
TableColumnAdjuster tca = new TableColumnAdjuster(table);
tca.adjustColumns();
int numOfRows = table.getRowCount() + 2;
int rowHeight = table.getRowHeight();
int width = 559;
width = 0;
for (int columnIndex = 0; columnIndex < table.getColumnCount(); columnIndex++)
{
System.out.println(table.getColumnModel().getColumn(columnIndex).getMinWidth() + " ");
width += table.getColumnModel().getColumn(columnIndex).getWidth();
}
int height = numOfRows * rowHeight + 50;
int padding = 20;
scrollPane.setPreferredSize(new Dimension(width + padding,height + padding + 3));
table.setPreferredSize(new Dimension(width,height));
this.setPreferredSize(new Dimension(width,height));
this.revalidate();
this.repaint();
}
public JScrollPane getScrollPane() {
return scrollPane;
}
}