Browse Source

Made buttons in file chooser smaller.

Fixed button properties not being applied to ToggleButtons.
pull/97/head
weisj 5 years ago
parent
commit
d96ecbb23b
  1. 14
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java
  2. 26
      core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUI.java

14
core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java

@ -141,8 +141,8 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene
} }
public static boolean isFullShadow(final Component c) { public static boolean isFullShadow(final Component c) {
return c instanceof JButton return c instanceof AbstractButton
&& VARIANT_FULL_SHADOW.equals(((JButton) c).getClientProperty(KEY_VARIANT)); && VARIANT_FULL_SHADOW.equals(((AbstractButton) c).getClientProperty(KEY_VARIANT));
} }
protected static boolean isIconOnly(final AbstractButton b) { protected static boolean isIconOnly(final AbstractButton b) {
@ -162,8 +162,8 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene
} }
public static boolean isNoArc(final Component c) { public static boolean isNoArc(final Component c) {
return c instanceof JButton return c instanceof AbstractButton
&& Boolean.TRUE.equals(((JButton) c).getClientProperty(KEY_NO_ARC)); && Boolean.TRUE.equals(((AbstractButton) c).getClientProperty(KEY_NO_ARC));
} }
private boolean shouldDrawBackground(final JComponent c) { private boolean shouldDrawBackground(final JComponent c) {
@ -174,12 +174,12 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene
} }
public static boolean isSquare(final Component c) { public static boolean isSquare(final Component c) {
return c instanceof JButton && Boolean.TRUE.equals(((JButton) c).getClientProperty(KEY_SQUARE)); return c instanceof AbstractButton && Boolean.TRUE.equals(((AbstractButton) c).getClientProperty(KEY_SQUARE));
} }
public static boolean isThin(final Component c) { public static boolean isThin(final Component c) {
if (c instanceof JButton) { if (c instanceof AbstractButton) {
boolean isThin = Boolean.TRUE.equals(((JButton) c).getClientProperty(KEY_THIN)); boolean isThin = Boolean.TRUE.equals(((AbstractButton) c).getClientProperty(KEY_THIN));
return isThin || doConvertToShadow((AbstractButton) c); return isThin || doConvertToShadow((AbstractButton) c);
} }
return false; return false;

26
core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUI.java

@ -90,8 +90,7 @@ public class DarkFileChooserUI extends DarkFileChooserUIBridge {
return d; return d;
} }
}; };
directoryComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, directoryComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, lookInLabelText);
lookInLabelText);
lookInLabel.setLabelFor(directoryComboBox); lookInLabel.setLabelFor(directoryComboBox);
directoryComboBoxModel = createDirectoryComboBoxModel(fc); directoryComboBoxModel = createDirectoryComboBoxModel(fc);
directoryComboBox.setModel(directoryComboBoxModel); directoryComboBox.setModel(directoryComboBoxModel);
@ -106,6 +105,9 @@ public class DarkFileChooserUI extends DarkFileChooserUIBridge {
// Up Button // Up Button
JButton upFolderButton = new TooltipAwareButton(getChangeToParentDirectoryAction()); JButton upFolderButton = new TooltipAwareButton(getChangeToParentDirectoryAction());
upFolderButton.putClientProperty(DarkButtonUI.KEY_NO_SHADOW_OVERWRITE, true); upFolderButton.putClientProperty(DarkButtonUI.KEY_NO_SHADOW_OVERWRITE, true);
upFolderButton.putClientProperty(DarkButtonUI.KEY_SQUARE, true);
upFolderButton.putClientProperty(DarkButtonUI.KEY_ALT_ARC, true);
upFolderButton.setFocusable(false);
upFolderButton.setText(null); upFolderButton.setText(null);
upFolderButton.setIcon(upFolderIcon); upFolderButton.setIcon(upFolderIcon);
upFolderButton.setToolTipText(upFolderToolTipText); upFolderButton.setToolTipText(upFolderToolTipText);
@ -130,6 +132,9 @@ public class DarkFileChooserUI extends DarkFileChooserUIBridge {
homeFolderAccessibleName); homeFolderAccessibleName);
b.setAlignmentX(JComponent.LEFT_ALIGNMENT); b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
b.setAlignmentY(JComponent.CENTER_ALIGNMENT); b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
b.setFocusable(false);
b.putClientProperty(DarkButtonUI.KEY_SQUARE, true);
b.putClientProperty(DarkButtonUI.KEY_ALT_ARC, true);
b.setMargin(shrinkwrap); b.setMargin(shrinkwrap);
b.addActionListener(getGoHomeAction()); b.addActionListener(getGoHomeAction());
@ -141,6 +146,9 @@ public class DarkFileChooserUI extends DarkFileChooserUIBridge {
b = new TooltipAwareButton(filePane.getNewFolderAction()); b = new TooltipAwareButton(filePane.getNewFolderAction());
b.putClientProperty(DarkButtonUI.KEY_NO_SHADOW_OVERWRITE, true); b.putClientProperty(DarkButtonUI.KEY_NO_SHADOW_OVERWRITE, true);
b.setText(null); b.setText(null);
b.setFocusable(false);
b.putClientProperty(DarkButtonUI.KEY_SQUARE, true);
b.putClientProperty(DarkButtonUI.KEY_ALT_ARC, true);
b.setIcon(newFolderIcon); b.setIcon(newFolderIcon);
b.setToolTipText(newFolderToolTipText); b.setToolTipText(newFolderToolTipText);
b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
@ -158,11 +166,12 @@ public class DarkFileChooserUI extends DarkFileChooserUIBridge {
// List Button // List Button
listViewButton = new TooltipAwareToggleButton(listViewIcon); listViewButton = new TooltipAwareToggleButton(listViewIcon);
listViewButton.putClientProperty(DarkButtonUI.KEY_NO_SHADOW_OVERWRITE, true); listViewButton.putClientProperty(DarkButtonUI.KEY_NO_SHADOW_OVERWRITE, true);
listViewButton.putClientProperty(DarkButtonUI.KEY_SQUARE, true);
listViewButton.putClientProperty(DarkButtonUI.KEY_ALT_ARC, true);
listViewButton.putClientProperty(DarkButtonUI.KEY_SQUARE, Boolean.TRUE); listViewButton.putClientProperty(DarkButtonUI.KEY_SQUARE, Boolean.TRUE);
listViewButton.setFocusable(false);
listViewButton.setToolTipText(listViewButtonToolTipText); listViewButton.setToolTipText(listViewButtonToolTipText);
listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, listViewButtonAccessibleName);
listViewButtonAccessibleName);
listViewButton.setSelected(true); listViewButton.setSelected(true);
listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT); listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
@ -176,10 +185,11 @@ public class DarkFileChooserUI extends DarkFileChooserUIBridge {
// Details Button // Details Button
detailsViewButton = new TooltipAwareToggleButton(detailsViewIcon); detailsViewButton = new TooltipAwareToggleButton(detailsViewIcon);
detailsViewButton.putClientProperty(DarkButtonUI.KEY_NO_SHADOW_OVERWRITE, true); detailsViewButton.putClientProperty(DarkButtonUI.KEY_NO_SHADOW_OVERWRITE, true);
detailsViewButton.putClientProperty(DarkButtonUI.KEY_SQUARE, Boolean.TRUE); detailsViewButton.putClientProperty(DarkButtonUI.KEY_SQUARE, true);
detailsViewButton.putClientProperty(DarkButtonUI.KEY_ALT_ARC, true);
detailsViewButton.setFocusable(false);
detailsViewButton.setToolTipText(detailsViewButtonToolTipText); detailsViewButton.setToolTipText(detailsViewButtonToolTipText);
detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, detailsViewButtonAccessibleName);
detailsViewButtonAccessibleName);
detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT); detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT); detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
detailsViewButton.setMargin(shrinkwrap); detailsViewButton.setMargin(shrinkwrap);

Loading…
Cancel
Save