From 76c0588a0540d642e2ed30ee45fcb78c9dc74c49 Mon Sep 17 00:00:00 2001 From: weisj Date: Mon, 30 Mar 2020 14:26:14 +0200 Subject: [PATCH] Added property for high contrast. Added property for cell margins. Refactored table cell bound calculation. --- .../weisj/darklaf/ui/cell/CellUtil.java | 81 +++++++++++++++++++ .../weisj/darklaf/ui/cell/DarkCellBorder.java | 3 +- .../ui/combobox/DarkComboBoxBorder.java | 13 +-- .../darklaf/ui/spinner/DarkSpinnerBorder.java | 13 +-- .../darklaf/ui/table/DarkTableCellEditor.java | 2 +- .../weisj/darklaf/ui/table/DarkTableUI.java | 18 +++-- .../ui/table/TextTableCellEditorBorder.java | 65 +-------------- .../weisj/darklaf/ui/text/DarkTextUI.java | 6 ++ .../darklaf/properties/ui/borders.properties | 3 +- .../theme/darcula/darcula_defaults.properties | 1 + .../high_contrast_dark_defaults.properties | 1 + .../intellij/intellij_defaults.properties | 1 + .../solarized_dark_defaults.properties | 1 + .../solarized_light_defaults.properties | 1 + core/src/test/java/ui/DemoPanel.java | 6 +- core/src/test/java/ui/button/ButtonDemo.java | 14 +++- core/src/test/java/ui/table/TableDemo.java | 16 ++-- 17 files changed, 146 insertions(+), 99 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java b/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java index 30fde269..6bbeb5ef 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java @@ -24,6 +24,7 @@ package com.github.weisj.darklaf.ui.cell; import com.github.weisj.darklaf.ui.list.DarkListUI; +import com.github.weisj.darklaf.ui.table.DarkTableCellEditor; import com.github.weisj.darklaf.util.DarkUIUtil; import javax.swing.*; @@ -117,4 +118,84 @@ public class CellUtil { comp.setBackground(background); } } + + public static void paintTableEditorBorder(final Graphics g, final Component c, final JTable table, + final int width, final int height) { + int row = table.getEditingRow(); + int col = table.getEditingColumn(); + if (!table.getShowHorizontalLines()) { + if (row > CellUtil.getMinRowIndex(table)) g.fillRect(0, 0, width, 1); + g.fillRect(0, height - 1, width, 1); + } + if (!table.getShowVerticalLines()) { + if (col > CellUtil.getMinColumnIndex(table)) g.fillRect(0, 0, 1, height); + if (col < CellUtil.getMaxColumnIndex(table)) g.fillRect(width - 1, 0, 1, height); + } else if (isInWrapper(c)) { + if (table.getComponentOrientation().isLeftToRight()) { + g.fillRect(0, 0, 1, height); + } else { + g.fillRect(width - 1, 0, 1, height); + } + } + } + + protected static boolean isInWrapper(final Component c) { + return c.getParent() instanceof DarkTableCellEditor.IconWrapper; + } + + protected static boolean isListEditor(final Component c) { + return c instanceof JComponent + && Boolean.TRUE.equals(((JComponent) c).getClientProperty(DarkListUI.KEY_IS_LIST_RENDERER)) + && c.getParent() instanceof JList; + } + + public static Insets adjustEditorInsets(final Insets ins, final Component c) { + if (isInWrapper(c)) { + if (parentLTR(c)) { + ins.left -= ((DarkTableCellEditor.IconWrapper) c.getParent()).getIconCompGap(); + } else { + ins.right -= ((DarkTableCellEditor.IconWrapper) c.getParent()).getIconCompGap(); + } + } else if (isListEditor(c)) { + ListCellRenderer renderer = ((JList) c.getParent()).getCellRenderer(); + if (renderer instanceof JLabel) { + if (parentLTR(c)) { + ins.left -= ((JLabel) renderer).getIconTextGap() - 1; + } else { + ins.right -= ((JLabel) renderer).getIconTextGap() - 1; + } + } + } + return adjustTableCellEditorInsets(ins, DarkUIUtil.getParentOfType(JTable.class, c)); + } + + public static Insets adjustTableCellEditorInsets(final Insets ins, final JTable table) { + if (table != null && !table.getShowVerticalLines()) { + int cMin = getMinColumnIndex(table); + int column = table.getEditingColumn(); + if (column > cMin) ins.left++; + } + return ins; + } + + protected static boolean parentLTR(final Component c) { + return c.getParent().getComponentOrientation().isLeftToRight(); + } + + public static int getMinColumnIndex(final JTable table) { + Rectangle rect = table.getVisibleRect(); + return table.columnAtPoint(rect.getLocation()); + } + + public static int getMaxColumnIndex(final JTable table) { + Rectangle rect = table.getVisibleRect(); + Point p = rect.getLocation(); + p.x += rect.width - 1; + return table.columnAtPoint(p); + } + + public static int getMinRowIndex(final JTable table) { + Rectangle rect = table.getVisibleRect(); + return table.rowAtPoint(rect.getLocation()); + } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellBorder.java index 604ef3b0..40a01b78 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellBorder.java @@ -23,6 +23,7 @@ */ package com.github.weisj.darklaf.ui.cell; +import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.plaf.UIResource; @@ -32,6 +33,6 @@ import javax.swing.plaf.UIResource; public class DarkCellBorder extends EmptyBorder implements UIResource { public DarkCellBorder() { - super(2, 5, 2, 5); + super(UIManager.getInsets("Cell.borderInsets")); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java index 62aa98b7..e9d40e56 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java @@ -23,6 +23,7 @@ */ package com.github.weisj.darklaf.ui.combobox; +import com.github.weisj.darklaf.ui.cell.CellUtil; import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.GraphicsContext; @@ -140,14 +141,7 @@ public class DarkComboBoxBorder implements Border, UIResource { Component parent = c.getParent(); if (isTableCellEditor && parent instanceof JTable) { JTable table = ((JTable) parent); - if (!table.getShowHorizontalLines()) { - g.fillRect(0, 0, width, 1); - g.fillRect(0, height - 1, width, 1); - } - if (!table.getShowVerticalLines()) { - g.fillRect(0, 0, 1, height); - g.fillRect(width - 1, 0, 1, height); - } + CellUtil.paintTableEditorBorder(g, c, table, width, height); } else { DarkUIUtil.drawRect(g, 0, 0, width, height, 1); } @@ -167,7 +161,8 @@ public class DarkComboBoxBorder implements Border, UIResource { @Override public Insets getBorderInsets(final Component c) { if (ComboBoxConstants.isTreeOrTableCellEditor(c)) { - return new InsetsUIResource(cellPadding.top, cellPadding.left, cellPadding.bottom, cellPadding.right); + return CellUtil.adjustEditorInsets(new InsetsUIResource(cellPadding.top, cellPadding.left, + cellPadding.bottom, cellPadding.right), c); } if (c.getComponentOrientation().isLeftToRight()) { return new InsetsUIResource(boxPadding.top, boxPadding.left, boxPadding.bottom, borderSize); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java index 20e45ce5..acb36a1e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java @@ -23,6 +23,7 @@ */ package com.github.weisj.darklaf.ui.spinner; +import com.github.weisj.darklaf.ui.cell.CellUtil; import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.GraphicsContext; @@ -98,14 +99,7 @@ public class DarkSpinnerBorder implements Border, UIResource { DarkUIUtil.paintLineBorder(g, size, size, width - 2 * size, height - 2 * size, arc); } else if (tableCellEditor && (c.getParent() instanceof JTable)) { JTable table = (JTable) c.getParent(); - if (!table.getShowHorizontalLines()) { - g.fillRect(0, 0, width, 1); - g.fillRect(0, height - 1, width, 1); - } - if (!table.getShowVerticalLines()) { - g.fillRect(0, 0, 1, height); - g.fillRect(width - 1, 0, 1, height); - } + CellUtil.paintTableEditorBorder(g, c, table, width, height); } else { DarkUIUtil.drawRect(g, 0, 0, width, height, 1); } @@ -121,7 +115,8 @@ public class DarkSpinnerBorder implements Border, UIResource { @Override public Insets getBorderInsets(final Component c) { if (SpinnerConstants.isTreeOrTableCellEditor(c)) { - return new InsetsUIResource(cellInsets.top, cellInsets.left, cellInsets.bottom, cellInsets.right); + return CellUtil.adjustEditorInsets(new InsetsUIResource(cellInsets.top, cellInsets.left, + cellInsets.bottom, cellInsets.right), c); } return new InsetsUIResource(insets.top, insets.left, insets.bottom, insets.right); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java index a106679a..14cc4ee9 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java @@ -289,7 +289,7 @@ public class DarkTableCellEditor extends DefaultCellEditor { return checkBoxEditor; } - protected static class IconWrapper extends JPanel { + public static class IconWrapper extends JPanel { private final JLabel label; private JComponent c; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java index ea819331..3cd9a491 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java @@ -535,6 +535,7 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener { boolean scrollLtR = !isScrollPaneRtl(); boolean ltr = table.getComponentOrientation().isLeftToRight(); + boolean isEditorCell = table.isEditing() && table.getEditingRow() == row && table.getEditingColumn() == column; JTableHeader header = table.getTableHeader(); int draggedIndex = header != null ? viewIndexForColumn(header.getDraggedColumn()) @@ -543,7 +544,13 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener { table.getCellRect(row, draggedIndex, true), table) : 0; boolean isDragged = column == draggedIndex && dist != 0; + Rectangle rectWithSpacing = table.getCellRect(row, cMin, true); Rectangle r = new Rectangle(cellRect); + r.y = rectWithSpacing.y; + r.height = rectWithSpacing.height; + if (table.getShowHorizontalLines()) { + r.height--; + } if (!scrollBarVisible()) { if (ltr) { if (column == cMax && !isDragged) r.width += 1; @@ -565,12 +572,13 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener { } } } - if (!table.getShowVerticalLines() && column > cMin && isFocusCell(row, column)) { - r.x -= 1; - if (column < cMax) r.width += 1; + if (isEditorCell) { + if (!table.getShowVerticalLines()) { + if (column > cMin) r.x -= 1; + if (column > cMin && column < cMax) r.width += 1; + } } - if (table.isEditing() && table.getEditingRow() == row && table.getEditingColumn() == column) { - + if (isEditorCell) { Component component = table.getEditorComponent(); component.setBounds(r); component.validate(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/TextTableCellEditorBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/TextTableCellEditorBorder.java index e36db5ff..5b649fab 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/TextTableCellEditorBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/TextTableCellEditorBorder.java @@ -23,7 +23,7 @@ */ package com.github.weisj.darklaf.ui.table; -import com.github.weisj.darklaf.ui.text.DarkTextUI; +import com.github.weisj.darklaf.ui.cell.CellUtil; import com.github.weisj.darklaf.util.DarkUIUtil; import javax.swing.*; @@ -40,80 +40,21 @@ public class TextTableCellEditorBorder extends DarkTableCellBorder { borderColor = UIManager.getColor("TextField.border.enabled"); } - protected static boolean parentLTR(final Component c) { - return c.getParent().getComponentOrientation().isLeftToRight(); - } - @Override public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) { g.setColor(borderColor); JTable table = DarkUIUtil.getParentOfType(JTable.class, c); if (table != null) { - int row = table.getEditingRow(); - if (!table.getShowHorizontalLines()) { - if (row > getMinRowIndex(table)) g.fillRect(0, 0, width, 1); - g.fillRect(0, height - 1, width, 1); - } - if (!table.getShowVerticalLines()) { - g.fillRect(0, 0, 1, height); - g.fillRect(width - 1, 0, 1, height); - } else if (isInWrapper(c)) { - if (c.getParent().getComponentOrientation().isLeftToRight()) { - g.fillRect(0, 0, 1, height); - } else { - g.fillRect(width - 1, 0, 1, height); - } - } + CellUtil.paintTableEditorBorder(g, c, table, width, height); } else { DarkUIUtil.drawRect(g, x, y, width, height, 1); } } - protected int getMinColumnIndex(final JTable table) { - Rectangle rect = table.getVisibleRect(); - return table.columnAtPoint(rect.getLocation()); - } - - protected int getMinRowIndex(final JTable table) { - Rectangle rect = table.getVisibleRect(); - return table.rowAtPoint(rect.getLocation()); - } - - protected static boolean isListEditor(final Component c) { - return c instanceof JComponent - && Boolean.TRUE.equals(((JComponent) c).getClientProperty(DarkTextUI.KEY_IS_LIST_RENDER)) - && c.getParent() instanceof JList; - } - - protected static boolean isInWrapper(final Component c) { - return c.getParent() instanceof DarkTableCellEditor.IconWrapper; - } - @Override public Insets getBorderInsets(final Component c) { - Insets ins = super.getBorderInsets(); - if (isInWrapper(c)) { - if (parentLTR(c)) { - ins.left -= ((DarkTableCellEditor.IconWrapper) c.getParent()).getIconCompGap(); - } else { - ins.right -= ((DarkTableCellEditor.IconWrapper) c.getParent()).getIconCompGap(); - } - } else if (isListEditor(c)) { - ListCellRenderer renderer = ((JList) c.getParent()).getCellRenderer(); - if (renderer instanceof JLabel) { - if (parentLTR(c)) { - ins.left -= ((JLabel) renderer).getIconTextGap() - 1; - } else { - ins.right -= ((JLabel) renderer).getIconTextGap() - 1; - } - } - } - JTable table = DarkUIUtil.getParentOfType(JTable.class, c); - if (table != null && !table.getShowVerticalLines() && table.getEditingColumn() > getMinColumnIndex(table)) { - ins.left++; - } - return ins; + return CellUtil.adjustEditorInsets(super.getBorderInsets(), c); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java index 59e6c68a..07f32c2b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java @@ -188,6 +188,12 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi config.restore(); } + @Override + protected Rectangle getVisibleEditorRect() { + Rectangle rect = super.getVisibleEditorRect(); + return rect; + } + protected void paintBorderBackground(final Graphics2D g, final JTextComponent c) { g.setColor(getBackground(c)); Rectangle r = getDrawingRect(c); diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/borders.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/borders.properties index ea9483b5..02110f12 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/borders.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/borders.properties @@ -24,4 +24,5 @@ # TitledBorder.titleColor = %textForeground TitledBorder.border = com.github.weisj.darklaf.ui.titledborder.DarkTitledBorder -TitledBorder.borderColor = %borderSecondary \ No newline at end of file +TitledBorder.borderColor = %borderSecondary +Cell.borderInsets = 2,5,2,5 diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_defaults.properties b/core/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_defaults.properties index 01d3c5c3..85dd30eb 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_defaults.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_defaults.properties @@ -22,6 +22,7 @@ # # suppress inspection "UnusedProperty" for whole file Theme.dark = true +Theme.highContrast = false ####Background#### %background = 3c3f41 diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_defaults.properties b/core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_defaults.properties index 3b7db79b..78fae5fe 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_defaults.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_defaults.properties @@ -22,6 +22,7 @@ # # suppress inspection "UnusedProperty" for whole file Theme.dark = true +Theme.highContrast = true ####Background#### %background = 000000 diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_defaults.properties b/core/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_defaults.properties index 866b9336..b5b72a50 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_defaults.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_defaults.properties @@ -23,6 +23,7 @@ # # suppress inspection "UnusedProperty" for whole file Theme.dark = false +Theme.highContrast = false ####Background#### %background = F2F2F2 diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_defaults.properties b/core/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_defaults.properties index 974b6bb2..1f63fcc8 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_defaults.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_defaults.properties @@ -22,6 +22,7 @@ # # suppress inspection "UnusedProperty" for whole file Theme.dark = true +Theme.highContrast = false ####Background#### %background = 0E3C4A diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_defaults.properties b/core/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_defaults.properties index eb9a7226..e49f6473 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_defaults.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_defaults.properties @@ -23,6 +23,7 @@ # # suppress inspection "UnusedProperty" for whole file Theme.dark = false +Theme.highContrast = false ####Background#### %background = EEE8D5 diff --git a/core/src/test/java/ui/DemoPanel.java b/core/src/test/java/ui/DemoPanel.java index a3d6882a..f4c7bb8c 100644 --- a/core/src/test/java/ui/DemoPanel.java +++ b/core/src/test/java/ui/DemoPanel.java @@ -58,7 +58,11 @@ public class DemoPanel extends JPanel { public JPanel addControls(final int columns) { JPanel control = new JPanel(); - control.setLayout(new MigLayout("fillx, wrap " + columns, "[][grow]")); + String constraints = "fillx"; + if (columns > 0) { + constraints += ", wrap" + columns; + } + control.setLayout(new MigLayout(constraints, "[][grow]")); control.setBorder(DarkBorders.createLineBorder(1, 0, 0, 0)); controls.add(control); return control; diff --git a/core/src/test/java/ui/button/ButtonDemo.java b/core/src/test/java/ui/button/ButtonDemo.java index e1e9aeea..89261c44 100644 --- a/core/src/test/java/ui/button/ButtonDemo.java +++ b/core/src/test/java/ui/button/ButtonDemo.java @@ -84,6 +84,16 @@ public class ButtonDemo implements ComponentDemo { addActionListener(e -> UIManager.put("Button.defaultButtonFollowsFocus", isSelected())); }}); + controlPanel = panel.addControls(); + controlPanel.add(new JCheckBox("Text enabled") {{ + setSelected(true); + addActionListener(e -> button.setText(isSelected() ? "Test Button" : null)); + }}); + controlPanel.add(new JCheckBox("Icon enabled") {{ + setSelected(true); + addActionListener(e -> button.setIcon(isSelected() ? icon : null)); + }}); + controlPanel = panel.addControls(); controlPanel.add(new QuickColorChooser(DarkButtonUI.KEY_HOVER_COLOR, Color.BLACK, (b, c) -> button @@ -117,10 +127,6 @@ public class ButtonDemo implements ComponentDemo { } }); }}); - controlPanel.add(new JCheckBox("Icon Only") {{ - setSelected(false); - addActionListener(e -> button.setText(isSelected() ? null : "Test Button")); - }}); return panel; } diff --git a/core/src/test/java/ui/table/TableDemo.java b/core/src/test/java/ui/table/TableDemo.java index 393b0521..4824f2ac 100644 --- a/core/src/test/java/ui/table/TableDemo.java +++ b/core/src/test/java/ui/table/TableDemo.java @@ -46,11 +46,9 @@ public class TableDemo implements ComponentDemo { "Id", "Name", "Hourly Rate", "Part Time", "Components" }; - Object[][] data = new Object[][]{ - {1, "John", 40.0, false, "Item"}, - {2, "Rambo", 70.0, false, 10}, - {3, "Zorro", 60.0, true, "cell"}, - }; + Object[][] data = new Object[][]{{1, "John", 40.0, false, "Item"}, + {2, "Rambo", 70.0, false, 10}, + {3, "Zorro", 60.0, true, "cell"}}; AtomicBoolean editable = new AtomicBoolean(true); JTable table = new JTable(data, columns) { final TableCellEditor comboEditor = new DarkTableCellEditor(new JComboBox<>()); @@ -76,7 +74,7 @@ public class TableDemo implements ComponentDemo { JTableHeader header = table.getTableHeader(); DemoPanel panel = new DemoPanel(new JScrollPane(table)); - JPanel controlPanel = panel.addControls(); + JPanel controlPanel = panel.addControls(3); controlPanel.add(new JCheckBox("enabled") {{ setSelected(table.isEnabled()); addActionListener(e -> table.setEnabled(isSelected())); @@ -116,6 +114,12 @@ public class TableDemo implements ComponentDemo { addActionListener(e -> table.setRowSelectionAllowed(isSelected())); table.addPropertyChangeListener(e -> setSelected(table.getRowSelectionAllowed())); }}); + controlPanel = panel.addControls(3); + controlPanel.add(new JLabel("Row height:")); + controlPanel.add(new JSpinner() {{ + setValue(table.getRowHeight()); + addChangeListener(e -> table.setRowHeight(Integer.parseInt(getValue().toString()))); + }}); return panel; }