summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/gui/helper/ColumnSelector.java
diff options
context:
space:
mode:
Diffstat (limited to 'dozentenmodul/src/main/java/gui/helper/ColumnSelector.java')
-rw-r--r--dozentenmodul/src/main/java/gui/helper/ColumnSelector.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/dozentenmodul/src/main/java/gui/helper/ColumnSelector.java b/dozentenmodul/src/main/java/gui/helper/ColumnSelector.java
new file mode 100644
index 00000000..45929614
--- /dev/null
+++ b/dozentenmodul/src/main/java/gui/helper/ColumnSelector.java
@@ -0,0 +1,30 @@
+package gui.helper;
+
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+import javax.swing.AbstractButton;
+import javax.swing.JTable;
+
+public class ColumnSelector implements ItemListener {
+
+ private final JTable table;
+ private final Integer[] columns;
+
+ public ColumnSelector(JTable table, Integer... columns) {
+ this.table = table;
+ this.columns = columns;
+ }
+
+ public void itemStateChanged(ItemEvent e) {
+ if (!(e.getSource() instanceof AbstractButton))
+ return;
+ Boolean checked = e.getStateChange() == ItemEvent.SELECTED;
+ for (int x = 0, y = table.getRowCount(); x < y; x++) {
+ for (Integer col : columns) {
+ table.setValueAt(checked, x, col);
+ }
+ }
+ }
+
+}