From d4ea51f8ccdbde8e065996067099af43f0063f6e Mon Sep 17 00:00:00 2001 From: weisj Date: Wed, 18 Mar 2020 01:41:00 +0100 Subject: [PATCH] Extended table demo to include option for cell selection mode. --- core/src/test/java/ui/table/TableDemo.java | 29 +++++++++------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/core/src/test/java/ui/table/TableDemo.java b/core/src/test/java/ui/table/TableDemo.java index 01b8a8e0..abe954cc 100644 --- a/core/src/test/java/ui/table/TableDemo.java +++ b/core/src/test/java/ui/table/TableDemo.java @@ -102,25 +102,20 @@ public class TableDemo implements ComponentDemo { setSelected(header.getReorderingAllowed()); addActionListener(e -> header.setReorderingAllowed(isSelected())); }}); - JRadioButton column = new JRadioButton("column selection allowed") {{ + controlPanel.add(new JCheckBox("cell selection") {{ + setSelected(table.getCellSelectionEnabled()); + addActionListener(e -> table.setCellSelectionEnabled(isSelected())); + }}); + controlPanel.add(new JCheckBox("column selection") {{ setSelected(table.getColumnSelectionAllowed()); - addActionListener(e -> { - table.setColumnSelectionAllowed(isSelected()); - table.setRowSelectionAllowed(!isSelected()); - }); - }}; - JRadioButton row = new JRadioButton("row selection allowed") {{ + addActionListener(e -> table.setColumnSelectionAllowed(isSelected())); + table.addPropertyChangeListener(e -> setSelected(table.getColumnSelectionAllowed())); + }}); + controlPanel.add(new JCheckBox("row selection") {{ setSelected(table.getRowSelectionAllowed()); - addActionListener(e -> { - table.setRowSelectionAllowed(isSelected()); - table.setColumnSelectionAllowed(!isSelected()); - }); - }}; - ButtonGroup group = new ButtonGroup(); - group.add(column); - group.add(row); - controlPanel.add(column); - controlPanel.add(row); + addActionListener(e -> table.setRowSelectionAllowed(isSelected())); + table.addPropertyChangeListener(e -> setSelected(table.getRowSelectionAllowed())); + }}); return panel; }