1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.xulux.guilayer.swing.extensions;
17
18 import javax.swing.JTable;
19 import javax.swing.table.TableColumnModel;
20 import javax.swing.table.TableModel;
21
22
23
24
25
26
27
28
29
30 public class NyxJTable extends JTable {
31
32
33
34
35 private NyxJTable siblingTable;
36
37
38
39 private boolean changing;
40
41
42
43
44 public NyxJTable() {
45 super();
46 }
47
48
49
50
51
52 public NyxJTable(TableModel dm, TableColumnModel cm) {
53 super(dm, cm);
54 }
55
56
57
58
59 public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
60 super.changeSelection(rowIndex, columnIndex, toggle, extend);
61 if (getSiblingTable() != null && !getSiblingTable().isChanging()) {
62 changing = true;
63 getSiblingTable().changeSelection(rowIndex, columnIndex, toggle, extend);
64 changing = false;
65 }
66 }
67
68
69
70
71 public NyxJTable getSiblingTable() {
72 return siblingTable;
73 }
74
75
76
77
78 public void setSiblingTable(NyxJTable siblingTable) {
79 this.siblingTable = siblingTable;
80 }
81
82
83
84
85 public boolean isChanging() {
86 return changing;
87 }
88
89
90
91
92 public void setColumnSelectionInterval(int index0, int index1) {
93
94
95
96 if (index1 >= getColumnCount()) {
97 index1 = getColumnCount() - 1;
98 }
99 super.setColumnSelectionInterval(index0, index1);
100 if (getSiblingTable() != null && !getSiblingTable().isChanging()) {
101 changing = true;
102 getSiblingTable().setColumnSelectionInterval(index0, index1);
103 changing = false;
104 }
105 }
106
107
108
109
110 public void setRowSelectionInterval(int index0, int index1) {
111 super.setRowSelectionInterval(index0, index1);
112 if (getSiblingTable() != null && !getSiblingTable().isChanging()) {
113 changing = true;
114 getSiblingTable().setRowSelectionInterval(index0, index1);
115 changing = false;
116 }
117 }
118
119 }