Browse Source

Updated property names in SpinnerDemo.

Fixed too large background if combobox is editable.
pull/139/head
weisj 5 years ago
parent
commit
c7f11ed68c
  1. 3
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java
  2. 2
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java
  3. 2
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/comboBox.properties
  4. 15
      core/src/test/java/ui/spinner/SpinnerDemo.java

3
core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java

@ -123,8 +123,7 @@ public class DarkComboBoxBorder implements Border, UIResource {
public Insets getBorderInsets(final Component c) { public Insets getBorderInsets(final Component c) {
if (ComboBoxConstants.isTreeOrTableCellEditor(c)) { if (ComboBoxConstants.isTreeOrTableCellEditor(c)) {
return CellUtil.adjustEditorInsets(new InsetsUIResource(cellPadding.top, cellPadding.left, return CellUtil.adjustEditorInsets(new InsetsUIResource(cellPadding.top, cellPadding.left,
cellPadding.bottom, cellPadding.right), cellPadding.bottom, cellPadding.right), c);
c);
} }
if (c.getComponentOrientation().isLeftToRight()) { if (c.getComponentOrientation().isLeftToRight()) {
return new InsetsUIResource(boxPadding.top, boxPadding.left, boxPadding.bottom, borderSize); return new InsetsUIResource(boxPadding.top, boxPadding.left, boxPadding.bottom, borderSize);

2
core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java

@ -191,8 +191,10 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements ComboBoxConstants
public void paint(final Graphics g, final JComponent c) { public void paint(final Graphics g, final JComponent c) {
paintBackground(g, c, c.getWidth(), c.getHeight()); paintBackground(g, c, c.getWidth(), c.getHeight());
Rectangle r = rectangleForCurrentValue(); Rectangle r = rectangleForCurrentValue();
if (!comboBox.isEditable()) {
paintCurrentValue(g, r, hasFocus); paintCurrentValue(g, r, hasFocus);
} }
}
private void paintBackground(final Graphics g, final JComponent c, final int width, final int height) { private void paintBackground(final Graphics g, final JComponent c, final int width, final int height) {
final Container parent = c.getParent(); final Container parent = c.getParent();

2
core/src/main/resources/com/github/weisj/darklaf/properties/ui/comboBox.properties

@ -39,7 +39,7 @@ ComboBox.arc = %arc
ComboBox.borderThickness = %borderThickness ComboBox.borderThickness = %borderThickness
ComboBox.selectionForeground = %textSelectionForeground ComboBox.selectionForeground = %textSelectionForeground
ComboBox.insets = 5,5,5,5 ComboBox.insets = 5,5,5,5
ComboBox.cellEditorInsets = 0,0,0,0 ComboBox.cellEditorInsets = 1,0,1,0
ComboBox.buttonPad = 4 ComboBox.buttonPad = 4
#Icons #Icons

15
core/src/test/java/ui/spinner/SpinnerDemo.java

@ -23,6 +23,7 @@
*/ */
package ui.spinner; package ui.spinner;
import com.github.weisj.darklaf.ui.spinner.SpinnerConstants;
import ui.ComponentDemo; import ui.ComponentDemo;
import ui.DemoPanel; import ui.DemoPanel;
@ -50,16 +51,18 @@ public class SpinnerDemo implements ComponentDemo {
addActionListener(e -> spinner.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT addActionListener(e -> spinner.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT
: ComponentOrientation.RIGHT_TO_LEFT)); : ComponentOrientation.RIGHT_TO_LEFT));
}}); }});
controlPanel.add(new JCheckBox("JSpinner.variant = plusMinus") {{ controlPanel.add(new JCheckBox(SpinnerConstants.KEY_VARIANT + " = " + SpinnerConstants.VARIANT_PLUS_MINUS) {{
addActionListener(e -> spinner.putClientProperty("JSpinner.variant", isSelected() ? "plusMinus" : null)); addActionListener(e -> spinner.putClientProperty(SpinnerConstants.KEY_VARIANT,
isSelected() ? SpinnerConstants.VARIANT_PLUS_MINUS
: null));
}}); }});
controlPanel.add(new JCheckBox("JSpinner.isTreeCellEditor") {{ controlPanel.add(new JCheckBox(SpinnerConstants.KEY_IS_TREE_EDITOR) {{
setSelected(false); setSelected(false);
addActionListener(e -> spinner.putClientProperty("JSpinner.isTreeCellEditor", isSelected())); addActionListener(e -> spinner.putClientProperty(SpinnerConstants.KEY_IS_TREE_EDITOR, isSelected()));
}}); }});
controlPanel.add(new JCheckBox("JSpinner.isTableCellEditor") {{ controlPanel.add(new JCheckBox(SpinnerConstants.KEY_IS_TABLE_EDITOR) {{
setSelected(false); setSelected(false);
addActionListener(e -> spinner.putClientProperty("JSpinner.isTableCellEditor", isSelected())); addActionListener(e -> spinner.putClientProperty(SpinnerConstants.KEY_IS_TABLE_EDITOR, isSelected()));
}}); }});
return panel; return panel;
} }

Loading…
Cancel
Save