Browse Source

Extended table demo to include option for cell selection mode.

pull/97/head
weisj 5 years ago
parent
commit
d4ea51f8cc
  1. 29
      core/src/test/java/ui/table/TableDemo.java

29
core/src/test/java/ui/table/TableDemo.java

@ -102,25 +102,20 @@ public class TableDemo implements ComponentDemo {
setSelected(header.getReorderingAllowed()); setSelected(header.getReorderingAllowed());
addActionListener(e -> header.setReorderingAllowed(isSelected())); 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()); setSelected(table.getColumnSelectionAllowed());
addActionListener(e -> { addActionListener(e -> table.setColumnSelectionAllowed(isSelected()));
table.setColumnSelectionAllowed(isSelected()); table.addPropertyChangeListener(e -> setSelected(table.getColumnSelectionAllowed()));
table.setRowSelectionAllowed(!isSelected()); }});
}); controlPanel.add(new JCheckBox("row selection") {{
}};
JRadioButton row = new JRadioButton("row selection allowed") {{
setSelected(table.getRowSelectionAllowed()); setSelected(table.getRowSelectionAllowed());
addActionListener(e -> { addActionListener(e -> table.setRowSelectionAllowed(isSelected()));
table.setRowSelectionAllowed(isSelected()); table.addPropertyChangeListener(e -> setSelected(table.getRowSelectionAllowed()));
table.setColumnSelectionAllowed(!isSelected()); }});
});
}};
ButtonGroup group = new ButtonGroup();
group.add(column);
group.add(row);
controlPanel.add(column);
controlPanel.add(row);
return panel; return panel;
} }

Loading…
Cancel
Save