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. 4
      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) {
if (ComboBoxConstants.isTreeOrTableCellEditor(c)) {
return CellUtil.adjustEditorInsets(new InsetsUIResource(cellPadding.top, cellPadding.left,
cellPadding.bottom, cellPadding.right),
c);
cellPadding.bottom, cellPadding.right), c);
}
if (c.getComponentOrientation().isLeftToRight()) {
return new InsetsUIResource(boxPadding.top, boxPadding.left, boxPadding.bottom, borderSize);

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

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

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

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

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

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

Loading…
Cancel
Save