Browse Source

formatting and code style.

pull/127/head
weisj 5 years ago
parent
commit
1760744807
  1. 5
      core/src/main/java/com/github/weisj/darklaf/DarkLaf.java
  2. 53
      core/src/main/java/com/github/weisj/darklaf/LafManager.java
  3. 6
      core/src/main/java/com/github/weisj/darklaf/color/ColorWrapper.java
  4. 28
      core/src/main/java/com/github/weisj/darklaf/components/ClosableTabComponent.java
  5. 4
      core/src/main/java/com/github/weisj/darklaf/components/ColorPipetteBase.java
  6. 12
      core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java
  7. 4
      core/src/main/java/com/github/weisj/darklaf/components/JXPopupMenu.java
  8. 4
      core/src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java
  9. 4
      core/src/main/java/com/github/weisj/darklaf/components/ScrollPopupMenu.java
  10. 4
      core/src/main/java/com/github/weisj/darklaf/components/border/BubbleBorder.java
  11. 4
      core/src/main/java/com/github/weisj/darklaf/components/border/DarkBorders.java
  12. 27
      core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java
  13. 8
      core/src/main/java/com/github/weisj/darklaf/components/border/WeakLineBorder.java
  14. 3
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java
  15. 4
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/PanelPopup.java
  16. 64
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java
  17. 4
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFramePopup.java
  18. 4
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/ToggleSplitPane.java
  19. 7
      core/src/main/java/com/github/weisj/darklaf/components/text/LineHighlighter.java
  20. 7
      core/src/main/java/com/github/weisj/darklaf/components/text/NumberingPane.java
  21. 2
      core/src/main/java/com/github/weisj/darklaf/components/text/SearchTextFieldWithHistory.java
  22. 8
      core/src/main/java/com/github/weisj/darklaf/components/text/TextFieldHistoryPopup.java
  23. 13
      core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java
  24. 3
      core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBoxMenuItem.java
  25. 7
      core/src/main/java/com/github/weisj/darklaf/platform/Decorations.java
  26. 56
      core/src/main/java/com/github/weisj/darklaf/theme/Theme.java
  27. 33
      core/src/main/java/com/github/weisj/darklaf/ui/BasicTransferable.java
  28. 2
      core/src/main/java/com/github/weisj/darklaf/ui/DarkPopupFactory.java
  29. 15
      core/src/main/java/com/github/weisj/darklaf/ui/DragRecognitionSupport.java
  30. 12
      core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java
  31. 40
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java
  32. 2
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java
  33. 14
      core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererToggleButton.java
  34. 2
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorPreviewComponent.java
  35. 4
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorValueFormatter.java
  36. 2
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorWheel.java
  37. 6
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorWheelImageProducer.java
  38. 13
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java
  39. 10
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserUI.java
  40. 7
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkSwatchesChooserPanel.java
  41. 902
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/MainSwatchPanel.java
  42. 2
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SlideComponent.java
  43. 10
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SwatchPanel.java
  44. 4
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/ComboBoxConstants.java
  45. 16
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java
  46. 2
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxListener.java
  47. 2
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java
  48. 19
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java
  49. 2
      core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUI.java
  50. 85
      core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUIBridge.java
  51. 10
      core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePane.java
  52. 168
      core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePaneUIBridge.java
  53. 2
      core/src/main/java/com/github/weisj/darklaf/ui/html/DarkHTML.java
  54. 5
      core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameTitlePane.java
  55. 12
      core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java
  56. 2
      core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellFocusBorder.java
  57. 234
      core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java
  58. 2
      core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarBorder.java
  59. 24
      core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java
  60. 20
      core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuUI.java
  61. 11
      core/src/main/java/com/github/weisj/darklaf/ui/numberingpane/DarkNumberingPaneUI.java
  62. 15
      core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneUI.java
  63. 3
      core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuBorder.java
  64. 20
      core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuUI.java
  65. 9
      core/src/main/java/com/github/weisj/darklaf/ui/progressbar/DarkProgressBarUI.java
  66. 2
      core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java
  67. 12
      core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkSubstanceRootLayout.java
  68. 22
      core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarListener.java
  69. 6
      core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollPaneUI.java
  70. 4
      core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollBarUtil.java
  71. 16
      core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java
  72. 10
      core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java
  73. 2
      core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerListener.java
  74. 4
      core/src/main/java/com/github/weisj/darklaf/ui/spinner/SpinnerConstants.java
  75. 14
      core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneDivider.java
  76. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkHandler.java
  77. 5
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabPanel.java
  78. 9
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabSupport.java
  79. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabAreaButton.java
  80. 10
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneLayout.java
  81. 17
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneScrollLayout.java
  82. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java
  83. 40
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java
  84. 5
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/MoreTabsButton.java
  85. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/NewTabButton.java
  86. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabPanel.java
  87. 6
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabSupport.java
  88. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabViewport.java
  89. 4
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneHandler.java
  90. 14
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneLayout.java
  91. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneScrollLayout.java
  92. 27
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneTransferHandler.java
  93. 10
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneUtil.java
  94. 3
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java
  95. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameComponentPopupMenu.java
  96. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java
  97. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameUI.java
  98. 4
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabDragListener.java
  99. 17
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameLayout.java
  100. 13
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameTransferHandler.java
  101. Some files were not shown because too many files have changed in this diff Show More

5
core/src/main/java/com/github/weisj/darklaf/DarkLaf.java

@ -207,7 +207,7 @@ public class DarkLaf extends BasicLookAndFeel {
// (Alloy license problem) // (Alloy license problem)
installCutCopyPasteShortcuts(tableInputMap, true); installCutCopyPasteShortcuts(tableInputMap, true);
} }
final InputMap buttonInputMap = (InputMap) defaults.get("Button.focusInputMap"); final InputMap buttonInputMap = (InputMap) defaults.get("Button.focusInputMap");
if (buttonInputMap != null && !SystemInfo.isMac) { if (buttonInputMap != null && !SystemInfo.isMac) {
buttonInputMap.put(KeyStroke.getKeyStroke("ENTER"), "pressed"); buttonInputMap.put(KeyStroke.getKeyStroke("ENTER"), "pressed");
buttonInputMap.put(KeyStroke.getKeyStroke("released ENTER"), "released"); buttonInputMap.put(KeyStroke.getKeyStroke("released ENTER"), "released");
@ -244,7 +244,8 @@ public class DarkLaf extends BasicLookAndFeel {
private void loadSystemOverwrites(final Properties uiProps, final UIDefaults defaults) { private void loadSystemOverwrites(final Properties uiProps, final UIDefaults defaults) {
Properties overwrites = PropertyLoader.loadProperties(DarkLaf.class, "overwrites", "properties/"); Properties overwrites = PropertyLoader.loadProperties(DarkLaf.class, "overwrites", "properties/");
overwrites.values().removeIf(v -> System.getProperty(SYSTEM_PROPERTY_PREFIX + v.toString()) == null); overwrites.values().removeIf(v -> System.getProperty(SYSTEM_PROPERTY_PREFIX + v.toString()) == null);
overwrites.entrySet().forEach(e -> e.setValue(System.getProperty(SYSTEM_PROPERTY_PREFIX + e.getValue().toString()))); overwrites.entrySet().forEach(
e -> e.setValue(System.getProperty(SYSTEM_PROPERTY_PREFIX + e.getValue().toString())));
PropertyLoader.putProperties(overwrites, uiProps, defaults); PropertyLoader.putProperties(overwrites, uiProps, defaults);
} }

53
core/src/main/java/com/github/weisj/darklaf/LafManager.java

@ -33,6 +33,7 @@ import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.LogManager; import java.util.logging.LogManager;
@ -48,7 +49,7 @@ public final class LafManager {
private static Theme theme; private static Theme theme;
private static boolean logEnabled = false; private static boolean logEnabled = false;
private static boolean decorationsOverwrite = true; private static boolean decorationsOverwrite = true;
private static Properties properties = new Properties(); private static final Properties properties = new Properties();
static { static {
enableLogging(true); enableLogging(true);
@ -65,7 +66,8 @@ public final class LafManager {
LogManager.getLogManager().reset(); LogManager.getLogManager().reset();
} else { } else {
try (InputStream inputStream = DarkLaf.class.getClassLoader() try (InputStream inputStream = DarkLaf.class.getClassLoader()
.getResourceAsStream("com/github/weisj/darklaf/log/logging.properties")) { .getResourceAsStream(
"com/github/weisj/darklaf/log/logging.properties")) {
if (inputStream != null) { if (inputStream != null) {
Logger.getGlobal().fine("Loading logging configuration."); Logger.getGlobal().fine("Loading logging configuration.");
LogManager.getLogManager().readConfiguration(inputStream); LogManager.getLogManager().readConfiguration(inputStream);
@ -79,8 +81,8 @@ public final class LafManager {
} }
/** /**
* Returns whther custom decorations should be used. * Returns whther custom decorations should be used. If this returns true decorations still might not be used if the
* If this returns true decorations still might not be used if the theme or platform don't support them. * theme or platform don't support them.
* *
* @return true if decorations should be used. * @return true if decorations should be used.
*/ */
@ -89,9 +91,8 @@ public final class LafManager {
} }
/** /**
* Set globally whether decorations are enabled. By default this is true. * Set globally whether decorations are enabled. By default this is true. Decorations are used if this value is set
* Decorations are used if this value is set to true and the current platform and theme support * to true and the current platform and theme support custom decorations.
* custom decorations.
* *
* @param enabled true if decorations should be used if available. * @param enabled true if decorations should be used if available.
*/ */
@ -145,8 +146,11 @@ public final class LafManager {
*/ */
public static void reloadIconTheme() { public static void reloadIconTheme() {
try { try {
setTheme(getTheme().getClass().newInstance()); setTheme(getTheme().getClass().getDeclaredConstructor().newInstance());
} catch (InstantiationException | IllegalAccessException e) { } catch (InstantiationException
| IllegalAccessException
| NoSuchMethodException
| InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -171,9 +175,9 @@ public final class LafManager {
UIManager.setLookAndFeel(DarkLaf.class.getCanonicalName()); UIManager.setLookAndFeel(DarkLaf.class.getCanonicalName());
updateLaf(); updateLaf();
} catch (final ClassNotFoundException } catch (final ClassNotFoundException
| InstantiationException | InstantiationException
| IllegalAccessException | IllegalAccessException
| UnsupportedLookAndFeelException e) { | UnsupportedLookAndFeelException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -197,9 +201,8 @@ public final class LafManager {
/** /**
* Set a custom property. * Set a custom property.
* <p> * <p>
* Note: These properties are loaded * Note: These properties are loaded after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be
* after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be used to overwrite the values * used to overwrite the values specified in `[theme]_defaults.properties`.
* specified in `[theme]_defaults.properties`.
* *
* @param key the key. * @param key the key.
* @param value the value. * @param value the value.
@ -211,9 +214,8 @@ public final class LafManager {
/** /**
* Remove a custom property. * Remove a custom property.
* <p> * <p>
* Note: These properties are loaded * Note: These properties are loaded after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be
* after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be used to overwrite the values * used to overwrite the values specified in `[theme]_defaults.properties`.
* specified in `[theme]_defaults.properties`.
* *
* @param key the key. * @param key the key.
*/ */
@ -224,9 +226,8 @@ public final class LafManager {
/** /**
* Remove all custom properties. * Remove all custom properties.
* <p> * <p>
* Note: These properties are loaded * Note: These properties are loaded after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be
* after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be used to overwrite the values * used to overwrite the values specified in `[theme]_defaults.properties`.
* specified in `[theme]_defaults.properties`.
*/ */
public static void clearProperties() { public static void clearProperties() {
properties.clear(); properties.clear();
@ -235,9 +236,8 @@ public final class LafManager {
/** /**
* Get the custom properties. * Get the custom properties.
* <p> * <p>
* Note: These properties are loaded * Note: These properties are loaded after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be
* after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be used to overwrite the values * used to overwrite the values specified in `[theme]_defaults.properties`.
* specified in `[theme]_defaults.properties`.
*/ */
public static Properties getUserProperties() { public static Properties getUserProperties() {
return properties; return properties;
@ -246,9 +246,8 @@ public final class LafManager {
/** /**
* Remove a custom property. * Remove a custom property.
* <p> * <p>
* Note: These properties are loaded * Note: These properties are loaded after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be
* after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be used to overwrite the values * used to overwrite the values specified in `[theme]_defaults.properties`.
* specified in `[theme]_defaults.properties`.
* *
* @param key the key. * @param key the key.
* @return the value associated with `key`. * @return the value associated with `key`.

6
core/src/main/java/com/github/weisj/darklaf/color/ColorWrapper.java

@ -43,7 +43,11 @@ public class ColorWrapper extends Color {
} }
public void setColor(final Color color) { public void setColor(final Color color) {
if (color == null) { this.color = Color.BLACK; } else this.color = color; if (color == null) {
this.color = Color.BLACK;
} else {
this.color = color;
}
} }
@Override @Override

28
core/src/main/java/com/github/weisj/darklaf/components/ClosableTabComponent.java

@ -55,7 +55,7 @@ public class ClosableTabComponent extends JPanel {
protected static class TabLabel extends JLabel { protected static class TabLabel extends JLabel {
private ClosableTabComponent tabComponent; private final ClosableTabComponent tabComponent;
protected TabLabel(final ClosableTabComponent tabComponent) { protected TabLabel(final ClosableTabComponent tabComponent) {
this.tabComponent = tabComponent; this.tabComponent = tabComponent;
@ -76,19 +76,6 @@ public class ClosableTabComponent extends JPanel {
protected static class TabButton extends JButton implements ActionListener { protected static class TabButton extends JButton implements ActionListener {
private final ClosableTabComponent tabComponent; private final ClosableTabComponent tabComponent;
private final MouseListener mouseListener = new MouseAdapter() {
@Override
public void mouseEntered(final MouseEvent e) {
ComponentUI ui = tabComponent.pane.getUI();
if (ui instanceof DarkTabbedPaneUI) {
int i = tabComponent.pane.indexOfTabComponent(tabComponent);
if (i != -1) {
((DarkTabbedPaneUI) ui).setRolloverTab(i);
tabComponent.pane.repaint();
}
}
}
};
protected TabButton(final ClosableTabComponent tabComponent) { protected TabButton(final ClosableTabComponent tabComponent) {
this.tabComponent = tabComponent; this.tabComponent = tabComponent;
@ -99,6 +86,19 @@ public class ClosableTabComponent extends JPanel {
setIcon(UIManager.getIcon("TabbedPane.tabCloseIcon")); setIcon(UIManager.getIcon("TabbedPane.tabCloseIcon"));
setRolloverIcon(UIManager.getIcon("TabbedPane.tabCloseHoverIcon")); setRolloverIcon(UIManager.getIcon("TabbedPane.tabCloseHoverIcon"));
addActionListener(this); addActionListener(this);
MouseListener mouseListener = new MouseAdapter() {
@Override
public void mouseEntered(final MouseEvent e) {
ComponentUI ui = tabComponent.pane.getUI();
if (ui instanceof DarkTabbedPaneUI) {
int i = tabComponent.pane.indexOfTabComponent(tabComponent);
if (i != -1) {
((DarkTabbedPaneUI) ui).setRolloverTab(i);
tabComponent.pane.repaint();
}
}
}
};
addMouseListener(mouseListener); addMouseListener(mouseListener);
} }

4
core/src/main/java/com/github/weisj/darklaf/components/ColorPipetteBase.java

@ -106,8 +106,8 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
Window picker = getOrCreatePickerWindow(); Window picker = getOrCreatePickerWindow();
Toolkit.getDefaultToolkit().addAWTEventListener(this, Toolkit.getDefaultToolkit().addAWTEventListener(this,
AWTEvent.MOUSE_MOTION_EVENT_MASK AWTEvent.MOUSE_MOTION_EVENT_MASK
| AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK
| AWTEvent.KEY_EVENT_MASK); | AWTEvent.KEY_EVENT_MASK);
updateLocation(); updateLocation();
picker.setVisible(true); picker.setVisible(true);
return picker; return picker;

12
core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java

@ -30,11 +30,7 @@ import com.github.weisj.darklaf.util.TimerUtil;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.FocusAdapter; import java.awt.event.*;
import java.awt.event.FocusEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.Ellipse2D; import java.awt.geom.Ellipse2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -47,7 +43,7 @@ public class DefaultColorPipette extends ColorPipetteBase {
private final Rectangle captureRect = new Rectangle(); private final Rectangle captureRect = new Rectangle();
private final Point previousLocation = new Point(); private final Point previousLocation = new Point();
private final Timer timer; private final Timer timer;
protected Color borderColor; protected final Color borderColor;
private Graphics2D zoomGraphics; private Graphics2D zoomGraphics;
private BufferedImage zoomImage; private BufferedImage zoomImage;
@ -213,8 +209,8 @@ public class DefaultColorPipette extends ColorPipetteBase {
if (pipette.isKeyDown() && pipette.getPressedKeyCode() == KeyEvent.VK_SHIFT) { if (pipette.isKeyDown() && pipette.getPressedKeyCode() == KeyEvent.VK_SHIFT) {
Shape oldCLip = g.getClip(); Shape oldCLip = g.getClip();
Ellipse2D.Float circ = new Ellipse2D.Float(icon.getIconWidth() - 4, 2, Ellipse2D.Float circ = new Ellipse2D.Float(icon.getIconWidth() - 4, 2,
getWidth() - icon.getIconWidth() - 2 + 4, getWidth() - icon.getIconWidth() - 2 + 4,
getHeight() - 2 - icon.getIconHeight() + 4); getHeight() - 2 - icon.getIconHeight() + 4);
g.setClip(circ); g.setClip(circ);
g.drawImage(pipette.zoomImage, icon.getIconWidth() - 4, 2, null); g.drawImage(pipette.zoomImage, icon.getIconWidth() - 4, 2, null);
g.setClip(oldCLip); g.setClip(oldCLip);

4
core/src/main/java/com/github/weisj/darklaf/components/JXPopupMenu.java

@ -49,15 +49,15 @@ public class JXPopupMenu extends JPopupMenu {
super(label); super(label);
} }
@SuppressWarnings("unchecked")
@Override @Override
public void show(final Component invoker, final int x, final int y) { public void show(final Component invoker, final int x, final int y) {
Point p = new Point(x, y); Point p = new Point(x, y);
if (invoker != null) { if (invoker != null) {
JXLayer layer = DarkUIUtil.getParentOfType(JXLayer.class, invoker); JXLayer<? extends JComponent> layer = DarkUIUtil.getParentOfType(JXLayer.class, invoker);
if (layer != null && layer.getUI() instanceof TransformUI) { if (layer != null && layer.getUI() instanceof TransformUI) {
TransformUI ui = (TransformUI) layer.getUI(); TransformUI ui = (TransformUI) layer.getUI();
p = SwingUtilities.convertPoint(invoker, p, layer); p = SwingUtilities.convertPoint(invoker, p, layer);
//noinspection unchecked
AffineTransform transform = ui.getPreferredTransform(layer.getSize(), layer); AffineTransform transform = ui.getPreferredTransform(layer.getSize(), layer);
transform.transform(p, p); transform.transform(p, p);
super.show(layer, p.x, p.y); super.show(layer, p.x, p.y);

4
core/src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java

@ -286,11 +286,11 @@ public class OverlayScrollPane extends JLayeredPane {
@Override @Override
public boolean contains(final int x, final int y) { public boolean contains(final int x, final int y) {
if (scrollPane.horizontalScrollBar.isVisible() if (scrollPane.horizontalScrollBar.isVisible()
&& scrollPane.horizontalScrollBar.getBounds().contains(x, y)) { && scrollPane.horizontalScrollBar.getBounds().contains(x, y)) {
return true; return true;
} }
return scrollPane.verticalScrollBar.isVisible() return scrollPane.verticalScrollBar.isVisible()
&& scrollPane.verticalScrollBar.getBounds().contains(x, y); && scrollPane.verticalScrollBar.getBounds().contains(x, y);
} }

4
core/src/main/java/com/github/weisj/darklaf/components/ScrollPopupMenu.java

@ -83,8 +83,8 @@ public class ScrollPopupMenu extends JPopupMenu {
view = new JPanel(new BorderLayout()); view = new JPanel(new BorderLayout());
view.add(this, BorderLayout.CENTER); view.add(this, BorderLayout.CENTER);
OverlayScrollPane overlayScrollPane = OverlayScrollPane overlayScrollPane =
new OverlayScrollPane(view, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, new OverlayScrollPane(view, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
JScrollBar bar = overlayScrollPane.getVerticalScrollBar(); JScrollBar bar = overlayScrollPane.getVerticalScrollBar();
bar.putClientProperty("JScrollBar.thin", Boolean.TRUE); bar.putClientProperty("JScrollBar.thin", Boolean.TRUE);
DarkUIUtil.doNotCancelPopupSetup(bar); DarkUIUtil.doNotCancelPopupSetup(bar);

4
core/src/main/java/com/github/weisj/darklaf/components/border/BubbleBorder.java

@ -52,7 +52,7 @@ public class BubbleBorder extends AbstractBorder {
/** /**
* Create new TextBubbleBorder with given colour. * Create new TextBubbleBorder with given colour.
* *
* @param color color of border * @param color color of border.
*/ */
public BubbleBorder(final Color color) { public BubbleBorder(final Color color) {
this(color, 2, 4, 5); this(color, 2, 4, 5);
@ -66,7 +66,7 @@ public class BubbleBorder extends AbstractBorder {
* @param radius corner radius of border. * @param radius corner radius of border.
* @param pointerSize size of pointer. You can set this size to 0 to achieve no pointer, but it is not desirable. * @param pointerSize size of pointer. You can set this size to 0 to achieve no pointer, but it is not desirable.
* The appropriate method for this is to set using {@link BubbleBorder#setPointerSide(Alignment)} * The appropriate method for this is to set using {@link BubbleBorder#setPointerSide(Alignment)}
* to {@link Alignment#CENTER} * to. {@link Alignment#CENTER}
*/ */
public BubbleBorder(final Color color, final int thickness, public BubbleBorder(final Color color, final int thickness,
final int radius, final int pointerSize) { final int radius, final int pointerSize) {

4
core/src/main/java/com/github/weisj/darklaf/components/border/DarkBorders.java

@ -33,9 +33,9 @@ import java.util.WeakHashMap;
public final class DarkBorders { public final class DarkBorders {
private static Map<WeakLineBorder, WeakReference<WeakLineBorder>> lineBorderMap = private static final Map<WeakLineBorder, WeakReference<WeakLineBorder>> lineBorderMap =
Collections.synchronizedMap(new WeakHashMap<>()); Collections.synchronizedMap(new WeakHashMap<>());
private static Map<WeakLineBorder, WeakReference<WeakLineBorder>> lineWidgetBorderMap = private static final Map<WeakLineBorder, WeakReference<WeakLineBorder>> lineWidgetBorderMap =
Collections.synchronizedMap(new WeakHashMap<>()); Collections.synchronizedMap(new WeakHashMap<>());

27
core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java

@ -77,7 +77,8 @@ public class DropShadowBorder implements Border, Serializable {
public DropShadowBorder(final Color shadowColor, final int shadowSize, public DropShadowBorder(final Color shadowColor, final int shadowSize,
final float shadowOpacity, final int cornerSize, final boolean showTopShadow, final float shadowOpacity, final int cornerSize, final boolean showTopShadow,
final boolean showLeftShadow, final boolean showBottomShadow, final boolean showRightShadow) { final boolean showLeftShadow, final boolean showBottomShadow,
final boolean showRightShadow) {
setShadowColor(shadowColor); setShadowColor(shadowColor);
setShadowSize(shadowSize); setShadowSize(shadowSize);
setShadowOpacity(shadowOpacity); setShadowOpacity(shadowOpacity);
@ -166,8 +167,8 @@ public class DropShadowBorder implements Border, Serializable {
if (showLeftShadow) { if (showLeftShadow) {
assert topLeftShadowPoint != null && bottomLeftShadowPoint != null; assert topLeftShadowPoint != null && bottomLeftShadowPoint != null;
Rectangle leftShadowRect = Rectangle leftShadowRect =
new Rectangle(x, topLeftShadowPoint.y + shadowSize, shadowSize, new Rectangle(x, topLeftShadowPoint.y + shadowSize, shadowSize,
bottomLeftShadowPoint.y - topLeftShadowPoint.y - shadowSize); bottomLeftShadowPoint.y - topLeftShadowPoint.y - shadowSize);
g2.drawImage(images[Position.LEFT.ordinal()], g2.drawImage(images[Position.LEFT.ordinal()],
leftShadowRect.x, leftShadowRect.y, leftShadowRect.x, leftShadowRect.y,
leftShadowRect.width, leftShadowRect.height, null); leftShadowRect.width, leftShadowRect.height, null);
@ -176,9 +177,9 @@ public class DropShadowBorder implements Border, Serializable {
if (showBottomShadow) { if (showBottomShadow) {
assert bottomLeftShadowPoint != null && bottomRightShadowPoint != null; assert bottomLeftShadowPoint != null && bottomRightShadowPoint != null;
Rectangle bottomShadowRect = Rectangle bottomShadowRect =
new Rectangle(bottomLeftShadowPoint.x + shadowSize, y + height - shadowSize, new Rectangle(bottomLeftShadowPoint.x + shadowSize, y + height - shadowSize,
bottomRightShadowPoint.x - bottomLeftShadowPoint.x - shadowSize, bottomRightShadowPoint.x - bottomLeftShadowPoint.x - shadowSize,
shadowSize); shadowSize);
g2.drawImage(images[Position.BOTTOM.ordinal()], g2.drawImage(images[Position.BOTTOM.ordinal()],
bottomShadowRect.x, bottomShadowRect.y, bottomShadowRect.x, bottomShadowRect.y,
bottomShadowRect.width, bottomShadowRect.height, null); bottomShadowRect.width, bottomShadowRect.height, null);
@ -187,8 +188,8 @@ public class DropShadowBorder implements Border, Serializable {
if (showRightShadow) { if (showRightShadow) {
assert topRightShadowPoint != null && bottomRightShadowPoint != null; assert topRightShadowPoint != null && bottomRightShadowPoint != null;
Rectangle rightShadowRect = Rectangle rightShadowRect =
new Rectangle(x + width - shadowSize, topRightShadowPoint.y + shadowSize, shadowSize, new Rectangle(x + width - shadowSize, topRightShadowPoint.y + shadowSize, shadowSize,
bottomRightShadowPoint.y - topRightShadowPoint.y - shadowSize); bottomRightShadowPoint.y - topRightShadowPoint.y - shadowSize);
g2.drawImage(images[Position.RIGHT.ordinal()], g2.drawImage(images[Position.RIGHT.ordinal()],
rightShadowRect.x, rightShadowRect.y, rightShadowRect.x, rightShadowRect.y,
rightShadowRect.width, rightShadowRect.height, null); rightShadowRect.width, rightShadowRect.height, null);
@ -197,8 +198,8 @@ public class DropShadowBorder implements Border, Serializable {
if (showTopShadow) { if (showTopShadow) {
assert topLeftShadowPoint != null && topRightShadowPoint != null; assert topLeftShadowPoint != null && topRightShadowPoint != null;
Rectangle topShadowRect = Rectangle topShadowRect =
new Rectangle(topLeftShadowPoint.x + shadowSize, y, new Rectangle(topLeftShadowPoint.x + shadowSize, y,
topRightShadowPoint.x - topLeftShadowPoint.x - shadowSize, shadowSize); topRightShadowPoint.x - topLeftShadowPoint.x - shadowSize, shadowSize);
g2.drawImage(images[Position.TOP.ordinal()], g2.drawImage(images[Position.TOP.ordinal()],
topShadowRect.x, topShadowRect.y, topShadowRect.x, topShadowRect.y,
topShadowRect.width, topShadowRect.height, null); topShadowRect.width, topShadowRect.height, null);
@ -210,11 +211,13 @@ public class DropShadowBorder implements Border, Serializable {
} }
if (showLeftShadow || showBottomShadow) { if (showLeftShadow || showBottomShadow) {
assert bottomLeftShadowPoint != null; assert bottomLeftShadowPoint != null;
g2.drawImage(images[Position.BOTTOM_LEFT.ordinal()], bottomLeftShadowPoint.x, bottomLeftShadowPoint.y, null); g2.drawImage(images[Position.BOTTOM_LEFT.ordinal()], bottomLeftShadowPoint.x, bottomLeftShadowPoint.y,
null);
} }
if (showRightShadow || showBottomShadow) { if (showRightShadow || showBottomShadow) {
assert bottomRightShadowPoint != null; assert bottomRightShadowPoint != null;
g2.drawImage(images[Position.BOTTOM_RIGHT.ordinal()], bottomRightShadowPoint.x, bottomRightShadowPoint.y, null); g2.drawImage(images[Position.BOTTOM_RIGHT.ordinal()], bottomRightShadowPoint.x,
bottomRightShadowPoint.y, null);
} }
if (showRightShadow || showTopShadow) { if (showRightShadow || showTopShadow) {
assert topRightShadowPoint != null; assert topRightShadowPoint != null;

8
core/src/main/java/com/github/weisj/darklaf/components/border/WeakLineBorder.java

@ -25,10 +25,10 @@ package com.github.weisj.darklaf.components.border;
class WeakLineBorder extends MutableLineBorder { class WeakLineBorder extends MutableLineBorder {
private int left; private final int left;
private int top; private final int top;
private int bottom; private final int bottom;
private int right; private final int right;
public WeakLineBorder(final int top, final int left, final int bottom, final int right) { public WeakLineBorder(final int top, final int left, final int bottom, final int right) {
super(top, left, bottom, right, null); super(top, left, bottom, right, null);

3
core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java

@ -539,7 +539,8 @@ public class JTabFrame extends JComponent {
getPopupComponentAt(a).doLayout(); getPopupComponentAt(a).doLayout();
getPopupComponentAt(a).requestFocus(); getPopupComponentAt(a).requestFocus();
} }
firePropertyChange(TabFramePopup.KEY_VISIBLE_TAB, new TabFramePosition(a, oldIndex), new TabFramePosition(a, index)); firePropertyChange(TabFramePopup.KEY_VISIBLE_TAB, new TabFramePosition(a, oldIndex),
new TabFramePosition(a, index));
} }
/** /**

4
core/src/main/java/com/github/weisj/darklaf/components/tabframe/PanelPopup.java

@ -122,7 +122,7 @@ public class PanelPopup extends JPanel implements TabFramePopup {
@Override @Override
public void close() { public void close() {
if (parent != null && getAlignment() != null && getIndex() >= 0 if (parent != null && getAlignment() != null && getIndex() >= 0
&& parent.isSelected(getAlignment(), getIndex())) { && parent.isSelected(getAlignment(), getIndex())) {
boolean oldOpen = isOpen(); boolean oldOpen = isOpen();
parent.closeTab(getAlignment(), getIndex()); parent.closeTab(getAlignment(), getIndex());
open = false; open = false;
@ -166,7 +166,7 @@ public class PanelPopup extends JPanel implements TabFramePopup {
@Override @Override
public void open() { public void open() {
if (parent != null && getAlignment() != null && getIndex() >= 0 if (parent != null && getAlignment() != null && getIndex() >= 0
&& !parent.isSelected(getAlignment(), getIndex())) { && !parent.isSelected(getAlignment(), getIndex())) {
boolean oldOpen = isOpen(); boolean oldOpen = isOpen();
parent.openTab(getAlignment(), getIndex()); parent.openTab(getAlignment(), getIndex());
open = true; open = true;

64
core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java

@ -189,59 +189,59 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
switch (a) { switch (a) {
case NORTH: case NORTH:
changeStatus( changeStatus(
enabled, Alignment.NORTH_EAST, enabled, Alignment.NORTH_EAST,
topSplit, topSplitter, topSplit, topSplitter,
new LayoutProportions(VERTICAL_PROP_TOP, 1.0, 0.0, 0.0), new LayoutProportions(VERTICAL_PROP_TOP, 1.0, 0.0, 0.0),
new LayoutWeights(0.0, 0.0, 0.0, 1.0)); new LayoutWeights(0.0, 0.0, 0.0, 1.0));
break; break;
case NORTH_EAST: case NORTH_EAST:
changeStatus( changeStatus(
enabled, Alignment.NORTH, enabled, Alignment.NORTH,
topSplit, topSplitter, topSplit, topSplitter,
new LayoutProportions(VERTICAL_PROP_TOP, 0.0, 0.0, 1.0), new LayoutProportions(VERTICAL_PROP_TOP, 0.0, 0.0, 1.0),
new LayoutWeights(0.0, 0.0, 1.0, 0.0)); new LayoutWeights(0.0, 0.0, 1.0, 0.0));
break; break;
case EAST: case EAST:
changeStatus( changeStatus(
enabled, Alignment.SOUTH_EAST, enabled, Alignment.SOUTH_EAST,
rightSplit, rightSplitter, rightSplit, rightSplitter,
new LayoutProportions(HORIZONTAL_PROP_RIGHT, 1.0, 1.0, 0.0), new LayoutProportions(HORIZONTAL_PROP_RIGHT, 1.0, 1.0, 0.0),
new LayoutWeights(1.0, 1.0, 0.0, 1.0)); new LayoutWeights(1.0, 1.0, 0.0, 1.0));
break; break;
case SOUTH_EAST: case SOUTH_EAST:
changeStatus( changeStatus(
enabled, Alignment.EAST, enabled, Alignment.EAST,
rightSplit, rightSplitter, rightSplit, rightSplitter,
new LayoutProportions(HORIZONTAL_PROP_RIGHT, 0.0, 1.0, 1.0), new LayoutProportions(HORIZONTAL_PROP_RIGHT, 0.0, 1.0, 1.0),
new LayoutWeights(1.0, 1.0, 1.0, 0.0)); new LayoutWeights(1.0, 1.0, 1.0, 0.0));
break; break;
case NORTH_WEST: case NORTH_WEST:
changeStatus( changeStatus(
enabled, Alignment.WEST, enabled, Alignment.WEST,
leftSplit, leftSplitter, leftSplit, leftSplitter,
new LayoutProportions(VERTICAL_PROP_TOP, 1.0, 0.0, 0.0), new LayoutProportions(VERTICAL_PROP_TOP, 1.0, 0.0, 0.0),
new LayoutWeights(0.0, 0.0, 0.0, 1.0)); new LayoutWeights(0.0, 0.0, 0.0, 1.0));
break; break;
case WEST: case WEST:
changeStatus( changeStatus(
enabled, Alignment.NORTH_WEST, enabled, Alignment.NORTH_WEST,
leftSplit, leftSplitter, leftSplit, leftSplitter,
new LayoutProportions(VERTICAL_PROP_TOP, 0.0, 0.0, 1.0), new LayoutProportions(VERTICAL_PROP_TOP, 0.0, 0.0, 1.0),
new LayoutWeights(0.0, 0.0, 1.0, 0.0)); new LayoutWeights(0.0, 0.0, 1.0, 0.0));
break; break;
case SOUTH_WEST: case SOUTH_WEST:
changeStatus( changeStatus(
enabled, Alignment.SOUTH, enabled, Alignment.SOUTH,
bottomSplit, bottomSplitter, bottomSplit, bottomSplitter,
new LayoutProportions(VERTICAL_PROP_BOTTOM, 1.0, 1.0, 0.0), new LayoutProportions(VERTICAL_PROP_BOTTOM, 1.0, 1.0, 0.0),
new LayoutWeights(1.0, 1.0, 0.0, 1.0)); new LayoutWeights(1.0, 1.0, 0.0, 1.0));
break; break;
case SOUTH: case SOUTH:
changeStatus( changeStatus(
enabled, Alignment.SOUTH_WEST, enabled, Alignment.SOUTH_WEST,
bottomSplit, bottomSplitter, bottomSplit, bottomSplitter,
new LayoutProportions(VERTICAL_PROP_BOTTOM, 0.0, 1.0, 1.0), new LayoutProportions(VERTICAL_PROP_BOTTOM, 0.0, 1.0, 1.0),
new LayoutWeights(1.0, 1.0, 1.0, 0.0)); new LayoutWeights(1.0, 1.0, 1.0, 0.0));
break; break;
case CENTER: case CENTER:
break; break;

4
core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFramePopup.java

@ -66,7 +66,7 @@ public interface TabFramePopup {
*/ */
default void close() { default void close() {
if (getTabFrame() != null && getAlignment() != null && getIndex() >= 0 if (getTabFrame() != null && getAlignment() != null && getIndex() >= 0
&& getTabFrame().isSelected(getAlignment(), getIndex())) { && getTabFrame().isSelected(getAlignment(), getIndex())) {
getTabFrame().closeTab(getAlignment(), getIndex()); getTabFrame().closeTab(getAlignment(), getIndex());
} }
} }
@ -119,7 +119,7 @@ public interface TabFramePopup {
*/ */
default void open() { default void open() {
if (getTabFrame() != null && getAlignment() != null && getIndex() >= 0 if (getTabFrame() != null && getAlignment() != null && getIndex() >= 0
&& !getTabFrame().isSelected(getAlignment(), getIndex())) { && !getTabFrame().isSelected(getAlignment(), getIndex())) {
getTabFrame().closeTab(getAlignment(), getIndex()); getTabFrame().closeTab(getAlignment(), getIndex());
} }
} }

4
core/src/main/java/com/github/weisj/darklaf/components/tabframe/ToggleSplitPane.java

@ -108,9 +108,9 @@ public class ToggleSplitPane extends JSplitPane {
public void forceSetDividerLocation(final double proportionalLocation) { public void forceSetDividerLocation(final double proportionalLocation) {
if (proportionalLocation < 0.0 || if (proportionalLocation < 0.0 ||
proportionalLocation > 1.0) { proportionalLocation > 1.0) {
throw new IllegalArgumentException("proportional location must " throw new IllegalArgumentException("proportional location must "
+ "be between 0.0 and 1.0."); + "be between 0.0 and 1.0.");
} }
if (getOrientation() == VERTICAL_SPLIT) { if (getOrientation() == VERTICAL_SPLIT) {
super.setDividerLocation((int) ((double) (getHeight()) * proportionalLocation)); super.setDividerLocation((int) ((double) (getHeight()) * proportionalLocation));

7
core/src/main/java/com/github/weisj/darklaf/components/text/LineHighlighter.java

@ -64,7 +64,9 @@ public class LineHighlighter implements Highlighter.HighlightPainter, ChangeList
g.setColor(color); g.setColor(color);
g.fillRect(0, r.y, c.getWidth(), r.height); g.fillRect(0, r.y, c.getWidth(), r.height);
if (lastView == null) { lastView = r; } if (lastView == null) {
lastView = r;
}
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
} }
@ -99,7 +101,8 @@ public class LineHighlighter implements Highlighter.HighlightPainter, ChangeList
component.repaint(0, lastView.y, component.getWidth(), lastView.height); component.repaint(0, lastView.y, component.getWidth(), lastView.height);
lastView = currentView; lastView = currentView;
} }
} catch (BadLocationException ignored) {} } catch (BadLocationException ignored) {
}
}); });
} }
} }

7
core/src/main/java/com/github/weisj/darklaf/components/text/NumberingPane.java

@ -36,8 +36,8 @@ public class NumberingPane extends JComponent {
public static final String KEY_ICONS = "icons"; public static final String KEY_ICONS = "icons";
public static final String KEY_MIN_ICON_WIDTH = "minimumIconWidth"; public static final String KEY_MIN_ICON_WIDTH = "minimumIconWidth";
private JTextComponent textComponent; private JTextComponent textComponent;
private Map<Position, Icon> iconMap; private final Map<Position, Icon> iconMap;
private Map<Position, List<IconListener>> listenerMap; private final Map<Position, List<IconListener>> listenerMap;
private int width; private int width;
public NumberingPane() { public NumberingPane() {
@ -83,7 +83,8 @@ public class NumberingPane extends JComponent {
return addIconAtLine(lineIndex, icon, true); return addIconAtLine(lineIndex, icon, true);
} }
public Position addIconAtLine(final int lineIndex, final Icon icon, final boolean atTextStart) throws BadLocationException { public Position addIconAtLine(final int lineIndex, final Icon icon, final boolean atTextStart)
throws BadLocationException {
int offset = textComponent.getDocument().getDefaultRootElement().getElement(lineIndex).getStartOffset(); int offset = textComponent.getDocument().getDefaultRootElement().getElement(lineIndex).getStartOffset();
if (atTextStart) { if (atTextStart) {
Document doc = textComponent.getDocument(); Document doc = textComponent.getDocument();

2
core/src/main/java/com/github/weisj/darklaf/components/text/SearchTextFieldWithHistory.java

@ -33,7 +33,7 @@ import java.util.List;
*/ */
public class SearchTextFieldWithHistory extends SearchTextField { public class SearchTextFieldWithHistory extends SearchTextField {
protected TextFieldHistoryPopup history; protected final TextFieldHistoryPopup history;
/** /**
* Constructs a new <code>TextField</code>. A default model is created, the initial string is <code>null</code>, * Constructs a new <code>TextField</code>. A default model is created, the initial string is <code>null</code>,

8
core/src/main/java/com/github/weisj/darklaf/components/text/TextFieldHistoryPopup.java

@ -29,14 +29,8 @@ import com.github.weisj.darklaf.util.StringUtil;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.*;
import java.util.Set;
/** /**
* @author Jannis Weis * @author Jannis Weis

13
core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java

@ -224,9 +224,9 @@ public class ToolTipContext {
* *
* <p>Default will be {@link AlignmentStrategy#COMPONENT_BOTH}. * <p>Default will be {@link AlignmentStrategy#COMPONENT_BOTH}.
* *
* @see AlignmentStrategy
* @param alignmentStrategy the alignment strategy. * @param alignmentStrategy the alignment strategy.
* @return this * @return this
* @see AlignmentStrategy
*/ */
public ToolTipContext setAlignmentStrategy(final AlignmentStrategy alignmentStrategy) { public ToolTipContext setAlignmentStrategy(final AlignmentStrategy alignmentStrategy) {
this.alignmentStrategy = alignmentStrategy; this.alignmentStrategy = alignmentStrategy;
@ -282,7 +282,8 @@ public class ToolTipContext {
* @param alignmentStrategy {@link #setAlignmentStrategy(AlignmentStrategy)} * @param alignmentStrategy {@link #setAlignmentStrategy(AlignmentStrategy)}
*/ */
public ToolTipContext(final JComponent target, final Alignment alignment, final AlignmentStrategy alignmentStrategy) { public ToolTipContext(final JComponent target, final Alignment alignment,
final AlignmentStrategy alignmentStrategy) {
this(target, alignment, null, alignmentStrategy, true, null); this(target, alignment, null, alignmentStrategy, true, null);
} }
@ -303,7 +304,7 @@ public class ToolTipContext {
/** /**
* Create a new tooltip context to ease the creation of custom tooltips. * Create a new tooltip context to ease the creation of custom tooltips.
* *
* @param target the component which the tooltip belongs to. * @param target the component which the tooltip belongs to.
* @param alignment {@link #setAlignment(Alignment)} * @param alignment {@link #setAlignment(Alignment)}
* @param alignmentStrategy {@link #setAlignmentStrategy(AlignmentStrategy)} * @param alignmentStrategy {@link #setAlignmentStrategy(AlignmentStrategy)}
* @param alignInside {@link #setAlignInside(boolean)} * @param alignInside {@link #setAlignInside(boolean)}
@ -392,9 +393,9 @@ public class ToolTipContext {
} }
/** /**
* @see #setInsideArea(Area)
* @param insideRect the rectangle to check. * @param insideRect the rectangle to check.
* @return this * @return this
* @see #setInsideArea(Area)
*/ */
public ToolTipContext setInsideArea(final Rectangle insideRect) { public ToolTipContext setInsideArea(final Rectangle insideRect) {
this.hotSpotArea = new Area(insideRect); this.hotSpotArea = new Area(insideRect);
@ -418,8 +419,8 @@ public class ToolTipContext {
} }
/** /**
* Sets whether the border should be ignored when aligning outside. If true the tooltip is aligned w.r.t. to * Sets whether the border should be ignored when aligning outside. If true the tooltip is aligned w.r.t. to the
* the content rect and not the component bounds. * content rect and not the component bounds.
* *
* @param ignoreBorder true if border insets should be ignored. * @param ignoreBorder true if border insets should be ignored.
* @return this. * @return this.

3
core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBoxMenuItem.java

@ -60,8 +60,7 @@ public class TristateCheckBoxMenuItem extends JCheckBoxMenuItem {
} }
/** /**
* Creates a menu item whose properties are taken from the * Creates a menu item whose properties are taken from the Action supplied.
* Action supplied.
* *
* @param a the action of the {@code JCheckBoxMenuItem} * @param a the action of the {@code JCheckBoxMenuItem}
* @since 1.3 * @since 1.3

7
core/src/main/java/com/github/weisj/darklaf/platform/Decorations.java

@ -60,7 +60,8 @@ public final class Decorations {
} }
} }
public static CustomTitlePane createTitlePane(final JRootPane rootPane, final int decorationStyle, final Window window) { public static CustomTitlePane createTitlePane(final JRootPane rootPane, final int decorationStyle,
final Window window) {
return decorationsProvider.createTitlePane(rootPane, decorationStyle, window); return decorationsProvider.createTitlePane(rootPane, decorationStyle, window);
} }
@ -74,8 +75,8 @@ public final class Decorations {
public static boolean isCustomDecorationSupported() { public static boolean isCustomDecorationSupported() {
return decorationsProvider.isCustomDecorationSupported() return decorationsProvider.isCustomDecorationSupported()
&& LafManager.isDecorationsEnabled() && LafManager.isDecorationsEnabled()
&& LafManager.getTheme().useCustomDecorations(); && LafManager.getTheme().useCustomDecorations();
} }
public static void initialize() { public static void initialize() {

56
core/src/main/java/com/github/weisj/darklaf/theme/Theme.java

@ -48,12 +48,12 @@ import java.util.logging.Logger;
public abstract class Theme { public abstract class Theme {
private static final Logger LOGGER = Logger.getLogger(Theme.class.getName()); private static final Logger LOGGER = Logger.getLogger(Theme.class.getName());
private static final String[] UI_PROPERTIES = new String[]{ private static final String[] UI_PROPERTIES = new String[]{
"borders", "button", "checkBox", "colorChooser", "comboBox", "fileChooser", "tristate", "borders", "button", "checkBox", "colorChooser", "comboBox", "fileChooser", "tristate",
"internalFrame", "label", "list", "menu", "menuBar", "menuItem", "numberingPane", "optionPane", "panel", "internalFrame", "label", "list", "menu", "menuBar", "menuItem", "numberingPane", "optionPane", "panel",
"popupMenu", "progressBar", "radioButton", "rootPane", "scrollBar", "scrollPane", "separator", "popupMenu", "progressBar", "radioButton", "rootPane", "scrollBar", "scrollPane", "separator",
"slider", "spinner", "splitPane", "statusBar", "tabbedPane", "tabFrame", "table", "taskPane", "text", "slider", "spinner", "splitPane", "statusBar", "tabbedPane", "tabFrame", "table", "taskPane", "text",
"toggleButton", "toolBar", "toolTip", "tree", "toggleButton", "toolBar", "toolTip", "tree",
}; };
private static final String[] ICON_PROPERTIES = new String[]{ private static final String[] ICON_PROPERTIES = new String[]{
"control", "dialog", "files", "frame", "indicator", "menu", "misc", "navigation" "control", "dialog", "files", "frame", "indicator", "menu", "misc", "navigation"
}; };
@ -74,9 +74,9 @@ public abstract class Theme {
/** /**
* Load the theme defaults. * Load the theme defaults.
* <p> * <p>
* Note: When overwriting a theme you also have overwrite {@link #getLoaderClass()} * Note: When overwriting a theme you also have overwrite {@link #getLoaderClass()} to return the class of the theme
* to return the class of the theme you are overwriting. In this case you should use * you are overwriting. In this case you should use {@link #loadWithClass(String, Class)} instead of {@link
* {@link #loadWithClass(String, Class)} instead of {@link #load(String)}. * #load(String)}.
* *
* @param properties the properties to load the values into. * @param properties the properties to load the values into.
* @param currentDefaults the current ui defaults. * @param currentDefaults the current ui defaults.
@ -89,9 +89,9 @@ public abstract class Theme {
/** /**
* Load the global values. * Load the global values.
* <p> * <p>
* Note: When overwriting a theme you also have overwrite {@link #getLoaderClass()} * Note: When overwriting a theme you also have overwrite {@link #getLoaderClass()} to return the class of the theme
* to return the class of the theme you are overwriting. In this case you should use * you are overwriting. In this case you should use {@link #loadWithClass(String, Class)} instead of {@link
* {@link #loadWithClass(String, Class)} instead of {@link #load(String)}. * #load(String)}.
* *
* @param properties the properties to load the values into. * @param properties the properties to load the values into.
* @param currentDefaults the current ui defaults. * @param currentDefaults the current ui defaults.
@ -104,9 +104,9 @@ public abstract class Theme {
/** /**
* Load the icon defaults. * Load the icon defaults.
* <p> * <p>
* Note: When overwriting a theme you also have overwrite {@link #getLoaderClass()} * Note: When overwriting a theme you also have overwrite {@link #getLoaderClass()} to return the class of the theme
* to return the class of the theme you are overwriting. In this case you should use * you are overwriting. In this case you should use {@link #loadWithClass(String, Class)} instead of {@link
* {@link #loadWithClass(String, Class)} instead of {@link #load(String)}. * #load(String)}.
* *
* @param properties the properties to load the value into. * @param properties the properties to load the value into.
* @param currentDefaults the current ui defaults. * @param currentDefaults the current ui defaults.
@ -122,9 +122,9 @@ public abstract class Theme {
/** /**
* Load the general properties file for the icon themes. * Load the general properties file for the icon themes.
* <p> * <p>
* Note: When overwriting a theme you also have overwrite {@link #getLoaderClass()} * Note: When overwriting a theme you also have overwrite {@link #getLoaderClass()} to return the class of the theme
* to return the class of the theme you are overwriting. In this case you should use * you are overwriting. In this case you should use {@link #loadWithClass(String, Class)} instead of {@link
* {@link #loadWithClass(String, Class)} instead of {@link #load(String)}. * #load(String)}.
* *
* @param properties the properties to load the value into. * @param properties the properties to load the value into.
* @param currentDefaults the current ui defaults. * @param currentDefaults the current ui defaults.
@ -149,8 +149,8 @@ public abstract class Theme {
/** /**
* Load the platform defaults. * Load the platform defaults.
* <p> * <p>
* Note: When overwriting a theme you should use {@link #loadWithClass(String, Class)} * Note: When overwriting a theme you should use {@link #loadWithClass(String, Class)} instead of {@link
* instead of {@link #load(String)}. * #load(String)}.
* *
* @param properties the properties to load the values into. * @param properties the properties to load the values into.
* @param currentDefaults the current ui defaults. * @param currentDefaults the current ui defaults.
@ -167,8 +167,8 @@ public abstract class Theme {
/** /**
* Load the ui defaults. * Load the ui defaults.
* <p> * <p>
* Note: When overwriting a theme you should use {@link #loadWithClass(String, Class)} * Note: When overwriting a theme you should use {@link #loadWithClass(String, Class)} instead of {@link
* instead of {@link #load(String)}. * #load(String)}.
* *
* @param properties the properties to load the values into. * @param properties the properties to load the values into.
* @param currentDefaults the current ui defaults. * @param currentDefaults the current ui defaults.
@ -191,8 +191,8 @@ public abstract class Theme {
* Load custom properties that are located under {@link #getResourcePath()}, with the name {@link * Load custom properties that are located under {@link #getResourcePath()}, with the name {@link
* #getName()}_{propertySuffix}.properties * #getName()}_{propertySuffix}.properties
* <p> * <p>
* Note: When overwriting a theme you should use {@link #loadWithClass(String, Class)} * Note: When overwriting a theme you should use {@link #loadWithClass(String, Class)} instead of {@link
* instead of {@link #load(String)}. * #load(String)}.
* *
* @param propertySuffix the property suffix. * @param propertySuffix the property suffix.
* @param properties the properties to load into. * @param properties the properties to load into.
@ -207,8 +207,7 @@ public abstract class Theme {
/** /**
* Load a .properties file using {@link #getLoaderClass()}} to resolve the file path. * Load a .properties file using {@link #getLoaderClass()}} to resolve the file path.
* <p> * <p>
* Note: When overwriting a theme you should use {@link #loadWithClass(String, Class)} * Note: When overwriting a theme you should use {@link #loadWithClass(String, Class)} instead.
* instead.
* *
* @param name the properties file to load. * @param name the properties file to load.
* @return the properties. * @return the properties.
@ -251,9 +250,8 @@ public abstract class Theme {
public abstract String getName(); public abstract String getName();
/** /**
* The class used to determine the runtime location of resources. * The class used to determine the runtime location of resources. It is advised to explicitly return the class
* It is advised to explicitly return the class instead of using {@link #getClass()} to protect * instead of using {@link #getClass()} to protect against extending the theme.
* against extending the theme.
* *
* @return the loader class. * @return the loader class.
*/ */

33
core/src/main/java/com/github/weisj/darklaf/ui/BasicTransferable.java

@ -28,7 +28,10 @@ import javax.swing.plaf.UIResource;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.*; import java.io.InputStream;
import java.io.Reader;
import java.io.StringBufferInputStream;
import java.io.StringReader;
import java.util.logging.Logger; import java.util.logging.Logger;
/** /**
@ -77,7 +80,7 @@ public class BasicTransferable implements Transferable, UIResource {
* Returns an array of DataFlavor objects indicating the flavors the data can be provided in. The array should be * Returns an array of DataFlavor objects indicating the flavors the data can be provided in. The array should be
* ordered according to preference for providing the data (from most richly descriptive to least descriptive). * ordered according to preference for providing the data (from most richly descriptive to least descriptive).
* *
* @return an array of data flavors in which this data can be transferred * @return an array of data flavors in which this data can be transferred.
*/ */
public DataFlavor[] getTransferDataFlavors() { public DataFlavor[] getTransferDataFlavors() {
DataFlavor[] richerFlavors = getRicherFlavors(); DataFlavor[] richerFlavors = getRicherFlavors();
@ -110,15 +113,15 @@ public class BasicTransferable implements Transferable, UIResource {
} }
/** /**
* Returns whether or not the specified data flavor is supported for this object. * Returns whether the specified data flavor is supported for this object.
* *
* @param flavor the requested flavor for the data * @param flavor the requested flavor for the data
* @return boolean indicating whether or not the data flavor is supported * @return boolean indicating whether the data flavor is supported.
*/ */
public boolean isDataFlavorSupported(final DataFlavor flavor) { public boolean isDataFlavorSupported(final DataFlavor flavor) {
DataFlavor[] flavors = getTransferDataFlavors(); DataFlavor[] flavors = getTransferDataFlavors();
for (int i = 0; i < flavors.length; i++) { for (DataFlavor dataFlavor : flavors) {
if (flavors[i].equals(flavor)) { if (dataFlavor.equals(flavor)) {
return true; return true;
} }
} }
@ -130,12 +133,10 @@ public class BasicTransferable implements Transferable, UIResource {
* the representation class of the flavor. * the representation class of the flavor.
* *
* @param flavor the requested flavor for the data * @param flavor the requested flavor for the data
* @throws IOException if the data is no longer available in the requested flavor.
* @throws UnsupportedFlavorException if the requested data flavor is not supported. * @throws UnsupportedFlavorException if the requested data flavor is not supported.
* @see DataFlavor#getRepresentationClass * @see DataFlavor#getRepresentationClass
*/ */
public Object getTransferData(final DataFlavor flavor) throws UnsupportedFlavorException, IOException { public Object getTransferData(final DataFlavor flavor) throws UnsupportedFlavorException {
DataFlavor[] richerFlavors = getRicherFlavors();
if (isRicherFlavor(flavor)) { if (isRicherFlavor(flavor)) {
return getRicherData(flavor); return getRicherData(flavor);
} else if (isHTMLFlavor(flavor)) { } else if (isHTMLFlavor(flavor)) {
@ -192,7 +193,7 @@ public class BasicTransferable implements Transferable, UIResource {
return null; return null;
} }
protected Object getRicherData(final DataFlavor flavor) throws UnsupportedFlavorException { protected Object getRicherData(final DataFlavor flavor) {
return null; return null;
} }
@ -206,8 +207,8 @@ public class BasicTransferable implements Transferable, UIResource {
*/ */
protected boolean isHTMLFlavor(final DataFlavor flavor) { protected boolean isHTMLFlavor(final DataFlavor flavor) {
DataFlavor[] flavors = htmlFlavors; DataFlavor[] flavors = htmlFlavors;
for (int i = 0; i < flavors.length; i++) { for (DataFlavor dataFlavor : flavors) {
if (flavors[i].equals(flavor)) { if (dataFlavor.equals(flavor)) {
return true; return true;
} }
} }
@ -243,8 +244,8 @@ public class BasicTransferable implements Transferable, UIResource {
*/ */
protected boolean isPlainFlavor(final DataFlavor flavor) { protected boolean isPlainFlavor(final DataFlavor flavor) {
DataFlavor[] flavors = plainFlavors; DataFlavor[] flavors = plainFlavors;
for (int i = 0; i < flavors.length; i++) { for (DataFlavor dataFlavor : flavors) {
if (flavors[i].equals(flavor)) { if (dataFlavor.equals(flavor)) {
return true; return true;
} }
} }
@ -280,8 +281,8 @@ public class BasicTransferable implements Transferable, UIResource {
*/ */
protected boolean isStringFlavor(final DataFlavor flavor) { protected boolean isStringFlavor(final DataFlavor flavor) {
DataFlavor[] flavors = stringFlavors; DataFlavor[] flavors = stringFlavors;
for (int i = 0; i < flavors.length; i++) { for (DataFlavor dataFlavor : flavors) {
if (flavors[i].equals(flavor)) { if (dataFlavor.equals(flavor)) {
return true; return true;
} }
} }

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

@ -40,7 +40,7 @@ public class DarkPopupFactory extends PopupFactory {
boolean isMediumWeight = popup.getClass().getSimpleName().endsWith("MediumWeightPopup"); boolean isMediumWeight = popup.getClass().getSimpleName().endsWith("MediumWeightPopup");
boolean isLightWeight = popup.getClass().getSimpleName().endsWith("LightWeightPopup"); boolean isLightWeight = popup.getClass().getSimpleName().endsWith("LightWeightPopup");
boolean isBalloonTooltip = contents instanceof JToolTip boolean isBalloonTooltip = contents instanceof JToolTip
&& ((JToolTip) contents).getBorder() instanceof DarkTooltipBorder; && ((JToolTip) contents).getBorder() instanceof DarkTooltipBorder;
boolean isPopupMenu = contents instanceof JPopupMenu; boolean isPopupMenu = contents instanceof JPopupMenu;
if (isMediumWeight || isLightWeight) { if (isMediumWeight || isLightWeight) {
if (isBalloonTooltip) { if (isBalloonTooltip) {

15
core/src/main/java/com/github/weisj/darklaf/ui/DragRecognitionSupport.java

@ -37,7 +37,8 @@ import java.awt.event.MouseEvent;
* press followed by movement by <code>DragSource.getDragThreshold()</code> pixels. An instance of this class is * press followed by movement by <code>DragSource.getDragThreshold()</code> pixels. An instance of this class is
* maintained per AppContext, and the public static methods call into the appropriate instance. * maintained per AppContext, and the public static methods call into the appropriate instance.
* *
* <p>This is a c and p of core (package private) needed for BasicXListUI. It differs from core in that references to sun * <p>This is a c and p of core (package private) needed for BasicXListUI. It differs from core in that references to
* sun
* packages have been replaced. * packages have been replaced.
* <ul> * <ul>
* <li> a static method of SunDragSourceContextPeer has been copied into SwingXUtilities * <li> a static method of SunDragSourceContextPeer has been copied into SwingXUtilities
@ -71,7 +72,7 @@ public class DragRecognitionSupport {
component = (JComponent) me.getSource(); component = (JComponent) me.getSource();
if (mapDragOperationFromModifiers(me, component.getTransferHandler()) if (mapDragOperationFromModifiers(me, component.getTransferHandler())
!= TransferHandler.NONE) { != TransferHandler.NONE) {
motionThreshold = DragSource.getDragThreshold(); motionThreshold = DragSource.getDragThreshold();
dndArmedEvent = me; dndArmedEvent = me;
@ -96,7 +97,7 @@ public class DragRecognitionSupport {
// } // }
DragRecognitionSupport support = (DragRecognitionSupport) DragRecognitionSupport support = (DragRecognitionSupport)
UIManager.get("sharedInstance.dragRecognitionSupport"); UIManager.get("sharedInstance.dragRecognitionSupport");
if (support == null) { if (support == null) {
support = new DragRecognitionSupport(); support = new DragRecognitionSupport();
UIManager.put("sharedInstance.dragRecognitionSupport", support); UIManager.put("sharedInstance.dragRecognitionSupport", support);
@ -112,8 +113,8 @@ public class DragRecognitionSupport {
} }
// PENDING JW: c'p from SunDragSourceContextPeer // PENDING JW: c'p from SunDragSourceContextPeer
return SwingXUtilities. return SwingXUtilities.
convertModifiersToDropAction(me.getModifiersEx(), convertModifiersToDropAction(me.getModifiersEx(),
th.getSourceActions(component)); th.getSourceActions(component));
} }
private void clearState() { private void clearState() {
@ -125,12 +126,12 @@ public class DragRecognitionSupport {
* If a dnd recognition has been going on, return the MouseEvent that started the recognition. Otherwise, return * If a dnd recognition has been going on, return the MouseEvent that started the recognition. Otherwise, return
* null. * null.
* *
* @param me the MouseEvent. * @param me the MouseEvent.
* @return true if mouse has been released. * @return true if mouse has been released.
*/ */
public static MouseEvent mouseReleased(final MouseEvent me) { public static MouseEvent mouseReleased(final MouseEvent me) {
return getDragRecognitionSupport(). return getDragRecognitionSupport().
mouseReleasedImpl(me); mouseReleasedImpl(me);
} }
/** /**

12
core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java

@ -48,17 +48,17 @@ public interface ButtonConstants {
static boolean chooseAlternativeArc(final Component c) { static boolean chooseAlternativeArc(final Component c) {
return c instanceof AbstractButton return c instanceof AbstractButton
&& Boolean.TRUE.equals(((AbstractButton) c).getClientProperty(KEY_ALT_ARC)); && Boolean.TRUE.equals(((AbstractButton) c).getClientProperty(KEY_ALT_ARC));
} }
static boolean isLabelButton(final Component c) { static boolean isLabelButton(final Component c) {
return c instanceof AbstractButton return c instanceof AbstractButton
&& VARIANT_ONLY_LABEL.equals(((AbstractButton) c).getClientProperty(KEY_VARIANT)); && VARIANT_ONLY_LABEL.equals(((AbstractButton) c).getClientProperty(KEY_VARIANT));
} }
static boolean isNoArc(final Component c) { static boolean isNoArc(final Component c) {
return c instanceof AbstractButton return c instanceof AbstractButton
&& Boolean.TRUE.equals(((AbstractButton) c).getClientProperty(KEY_NO_ARC)); && Boolean.TRUE.equals(((AbstractButton) c).getClientProperty(KEY_NO_ARC));
} }
static boolean isSquare(final Component c) { static boolean isSquare(final Component c) {
@ -84,7 +84,7 @@ public interface ButtonConstants {
static boolean isFullShadow(final Component c) { static boolean isFullShadow(final Component c) {
return c instanceof AbstractButton return c instanceof AbstractButton
&& VARIANT_FULL_SHADOW.equals(((AbstractButton) c).getClientProperty(KEY_VARIANT)); && VARIANT_FULL_SHADOW.equals(((AbstractButton) c).getClientProperty(KEY_VARIANT));
} }
static boolean doConvertToShadow(final AbstractButton b) { static boolean doConvertToShadow(final AbstractButton b) {
@ -93,8 +93,8 @@ public interface ButtonConstants {
static boolean convertIconButtonToShadow(final AbstractButton b) { static boolean convertIconButtonToShadow(final AbstractButton b) {
return !(b instanceof UIResource) return !(b instanceof UIResource)
&& UIManager.getBoolean("Button.convertIconOnlyToShadow") && UIManager.getBoolean("Button.convertIconOnlyToShadow")
&& !Boolean.TRUE.equals(b.getClientProperty(KEY_NO_SHADOW_OVERWRITE)); && !Boolean.TRUE.equals(b.getClientProperty(KEY_NO_SHADOW_OVERWRITE));
} }
static boolean isIconOnly(final AbstractButton b) { static boolean isIconOnly(final AbstractButton b) {

40
core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java

@ -41,19 +41,19 @@ import java.awt.geom.RoundRectangle2D;
*/ */
public class DarkButtonBorder implements Border, UIResource { public class DarkButtonBorder implements Border, UIResource {
private Color shadowColor; private final Color shadowColor;
private Color focusBorderColor; private final Color focusBorderColor;
private Color defaultBorderColor; private final Color defaultBorderColor;
private Color borderColor; private final Color borderColor;
private Color inactiveBorderColor; private final Color inactiveBorderColor;
private int arc; private final int arc;
private int focusArc; private final int focusArc;
private int squareFocusArc; private final int squareFocusArc;
private int squareArc; private final int squareArc;
private int minimumArc; private final int minimumArc;
private int borderSize; private final int borderSize;
private int shadowSize; private final int shadowSize;
private Insets insets; private Insets insets;
private Insets thinInsets; private Insets thinInsets;
private Insets squareInsets; private Insets squareInsets;
@ -94,13 +94,13 @@ public class DarkButtonBorder implements Border, UIResource {
public static boolean showDropShadow(final AlignmentExt a) { public static boolean showDropShadow(final AlignmentExt a) {
return a == null return a == null
|| a == AlignmentExt.SOUTH || a == AlignmentExt.SOUTH
|| a == AlignmentExt.SOUTH_EAST || a == AlignmentExt.SOUTH_EAST
|| a == AlignmentExt.SOUTH_WEST || a == AlignmentExt.SOUTH_WEST
|| a == AlignmentExt.LEFT || a == AlignmentExt.LEFT
|| a == AlignmentExt.RIGHT || a == AlignmentExt.RIGHT
|| a == AlignmentExt.BOTTOM || a == AlignmentExt.BOTTOM
|| a == AlignmentExt.MIDDLE_HORIZONTAL; || a == AlignmentExt.MIDDLE_HORIZONTAL;
} }
protected int getArc(final Component c) { protected int getArc(final Component c) {
@ -275,7 +275,7 @@ public class DarkButtonBorder implements Border, UIResource {
Insets pad = ButtonConstants.isThin(c) ? square ? squareThinInsets Insets pad = ButtonConstants.isThin(c) ? square ? squareThinInsets
: thinInsets : thinInsets
: square ? squareInsets : square ? squareInsets
: insets; : insets;
return maskInsets(new InsetsUIResource(pad.top, pad.left, pad.bottom, pad.right), c, shadow); return maskInsets(new InsetsUIResource(pad.top, pad.left, pad.bottom, pad.right), c, shadow);
} }

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

@ -317,7 +317,7 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
boolean defaultButton = ButtonConstants.isDefaultButton(c); boolean defaultButton = ButtonConstants.isDefaultButton(c);
AbstractButton b = (AbstractButton) c; AbstractButton b = (AbstractButton) c;
boolean rollOver = (b.isRolloverEnabled() || ButtonConstants.doConvertToShadow(b)) boolean rollOver = (b.isRolloverEnabled() || ButtonConstants.doConvertToShadow(b))
&& (((JButton) c).getModel().isRollover()); && (((JButton) c).getModel().isRollover());
boolean clicked = b.getModel().isArmed(); boolean clicked = b.getModel().isArmed();
if (c.isEnabled()) { if (c.isEnabled()) {
if (defaultButton) { if (defaultButton) {

14
core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererToggleButton.java

@ -25,9 +25,9 @@ package com.github.weisj.darklaf.ui.cell;
import com.github.weisj.darklaf.components.SelectableTreeNode; import com.github.weisj.darklaf.components.SelectableTreeNode;
import com.github.weisj.darklaf.decorators.CellRenderer; import com.github.weisj.darklaf.decorators.CellRenderer;
import com.github.weisj.darklaf.ui.togglebutton.DarkToggleButtonUI;
import com.github.weisj.darklaf.ui.table.DarkTableCellFocusBorder; import com.github.weisj.darklaf.ui.table.DarkTableCellFocusBorder;
import com.github.weisj.darklaf.ui.table.DarkTableUI; import com.github.weisj.darklaf.ui.table.DarkTableUI;
import com.github.weisj.darklaf.ui.togglebutton.DarkToggleButtonUI;
import com.github.weisj.darklaf.ui.tree.DarkTreeCellRenderer; import com.github.weisj.darklaf.ui.tree.DarkTreeCellRenderer;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
@ -42,7 +42,7 @@ import java.awt.*;
* @author Jannis Weis * @author Jannis Weis
*/ */
public class DarkCellRendererToggleButton<T extends JToggleButton & CellEditorToggleButton> public class DarkCellRendererToggleButton<T extends JToggleButton & CellEditorToggleButton>
implements TableCellRenderer, TreeCellRenderer, SwingConstants { implements TableCellRenderer, TreeCellRenderer, SwingConstants {
private final T toggleButton; private final T toggleButton;
@ -62,13 +62,13 @@ public class DarkCellRendererToggleButton<T extends JToggleButton & CellEditorTo
toggleButton.setHasFocus(focus); toggleButton.setHasFocus(focus);
boolean isLeadSelectionCell = DarkUIUtil.hasFocus(table) boolean isLeadSelectionCell = DarkUIUtil.hasFocus(table)
&& focus && !DarkTableCellFocusBorder.isRowFocusBorder(table); && focus && !DarkTableCellFocusBorder.isRowFocusBorder(table);
boolean paintSelected = isSelected && !isLeadSelectionCell && !table.isEditing(); boolean paintSelected = isSelected && !isLeadSelectionCell && !table.isEditing();
CellUtil.setupForeground(toggleButton, table, paintSelected, CellUtil.setupForeground(toggleButton, table, paintSelected,
"Table.selectionForeground","Table.selectionForegroundInactive"); "Table.selectionForeground", "Table.selectionForegroundInactive");
CellUtil.setupBackground(toggleButton, table, paintSelected, row,DarkTableUI.KEY_ALTERNATE_ROW_COLOR, CellUtil.setupBackground(toggleButton, table, paintSelected, row, DarkTableUI.KEY_ALTERNATE_ROW_COLOR,
"Table.background","Table.alternateRowBackground"); "Table.background", "Table.alternateRowBackground");
return toggleButton; return toggleButton;
} }
@ -89,7 +89,7 @@ public class DarkCellRendererToggleButton<T extends JToggleButton & CellEditorTo
toggleButton.setHasFocus(false); toggleButton.setHasFocus(false);
CellUtil.setupForeground(toggleButton, tree, selected, CellUtil.setupForeground(toggleButton, tree, selected,
"Tree.selectionForeground","Tree.selectionForegroundInactive"); "Tree.selectionForeground", "Tree.selectionForegroundInactive");
return toggleButton; return toggleButton;
} }

2
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorPreviewComponent.java

@ -30,7 +30,7 @@ import java.awt.*;
* @author Jannis Weis * @author Jannis Weis
*/ */
final class ColorPreviewComponent extends JComponent { final class ColorPreviewComponent extends JComponent {
protected Color borderColor; protected final Color borderColor;
private Color myColor; private Color myColor;
ColorPreviewComponent() { ColorPreviewComponent() {

4
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorValueFormatter.java

@ -43,7 +43,7 @@ import static java.util.Locale.ENGLISH;
* @author Jannis Weis * @author Jannis Weis
*/ */
public final class ColorValueFormatter extends JFormattedTextField.AbstractFormatter implements FocusListener, public final class ColorValueFormatter extends JFormattedTextField.AbstractFormatter implements FocusListener,
ActionListener { ActionListener {
private final int fieldIndex; private final int fieldIndex;
private final int radix; private final int radix;
@ -68,7 +68,7 @@ public final class ColorValueFormatter extends JFormattedTextField.AbstractForma
public void insertString(final FilterBypass fb, final int offset, public void insertString(final FilterBypass fb, final int offset,
final String text, final AttributeSet set) throws BadLocationException { final String text, final AttributeSet set) throws BadLocationException {
if (isValid(fb.getDocument().getLength() + text.length()) if (isValid(fb.getDocument().getLength() + text.length())
&& isValid(text)) { && isValid(text)) {
StringBuilder newText = new StringBuilder(fb.getDocument().getText(0, fb.getDocument().getLength())); StringBuilder newText = new StringBuilder(fb.getDocument().getText(0, fb.getDocument().getLength()));
newText.insert(offset, text); newText.insert(offset, text);
if (hex || isValidValue(newText.toString())) { if (hex || isValidValue(newText.toString())) {

2
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorWheel.java

@ -162,7 +162,7 @@ public class ColorWheel extends JComponent {
if (myImage == null) { if (myImage == null) {
myImage = createImage(new ColorWheelImageProducer( myImage = createImage(new ColorWheelImageProducer(
_size - BORDER_SIZE * 2, _size - BORDER_SIZE * 2, myBrightness)); _size - BORDER_SIZE * 2, _size - BORDER_SIZE * 2, myBrightness));
myWheel = new Rectangle(BORDER_SIZE, BORDER_SIZE, _size - BORDER_SIZE * 2, myWheel = new Rectangle(BORDER_SIZE, BORDER_SIZE, _size - BORDER_SIZE * 2,
_size - BORDER_SIZE * 2); _size - BORDER_SIZE * 2);
} }

6
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorWheelImageProducer.java

@ -36,7 +36,7 @@ public class ColorWheelImageProducer extends MemoryImageSource {
private final int[] myPixels; private final int[] myPixels;
private final int myWidth; private final int myWidth;
private final int myHeight; private final int myHeight;
private float myBrightness; private final float myBrightness;
private float[] myHues; private float[] myHues;
private float[] mySat; private float[] mySat;
@ -76,8 +76,8 @@ public class ColorWheelImageProducer extends MemoryImageSource {
int index = x + y * myWidth; int index = x + y * myWidth;
mySat[index] = (float) Math.sqrt(squarekx + ky mySat[index] = (float) Math.sqrt(squarekx + ky
* ky) * ky)
/ radius; / radius;
if (mySat[index] <= 1f) { if (mySat[index] <= 1f) {
myAlphas[index] = 0xff000000; myAlphas[index] = 0xff000000;
} else { } else {

13
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java

@ -49,7 +49,7 @@ import java.awt.event.KeyEvent;
public class DarkColorChooserPanel extends AbstractColorChooserPanel implements ColorListener { public class DarkColorChooserPanel extends AbstractColorChooserPanel implements ColorListener {
public static final String TRANSPARENCY_ENABLED_PROPERTY public static final String TRANSPARENCY_ENABLED_PROPERTY
= "TransparencyEnabled"; = "TransparencyEnabled";
private final ColorPipette pipette; private final ColorPipette pipette;
private final ColorWheelPanel colorWheelPanel; private final ColorWheelPanel colorWheelPanel;
@ -275,12 +275,13 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements
int alpha = isColorTransparencySelectionEnabled() int alpha = isColorTransparencySelectionEnabled()
? Integer.valueOf(hexStr.substring(6, 8), 16) : 255; ? Integer.valueOf(hexStr.substring(6, 8), 16) : 255;
Color c = new Color( Color c = new Color(
Integer.valueOf(hexStr.substring(0, 2), 16), Integer.valueOf(hexStr.substring(0, 2), 16),
Integer.valueOf(hexStr.substring(2, 4), 16), Integer.valueOf(hexStr.substring(2, 4), 16),
Integer.valueOf(hexStr.substring(4, 6), 16), Integer.valueOf(hexStr.substring(4, 6), 16),
alpha); alpha);
colorWheelPanel.setColor(c, textHex); colorWheelPanel.setColor(c, textHex);
} catch (NumberFormatException | IndexOutOfBoundsException ignore) {} } catch (NumberFormatException | IndexOutOfBoundsException ignore) {
}
} }
}); });
} }

10
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserUI.java

@ -80,12 +80,12 @@ public class DarkColorChooserUI extends BasicColorChooserUI {
@Override @Override
protected AbstractColorChooserPanel[] createDefaultChoosers() { protected AbstractColorChooserPanel[] createDefaultChoosers() {
return new AbstractColorChooserPanel[]{ return new AbstractColorChooserPanel[]{
new DarkColorChooserPanel(new DarkColorModel(), new DarkColorChooserPanel(new DarkColorModel(),
new DarkColorModelHSL(), new DarkColorModelHSL(),
// new DarkColorModelHSB(), // new DarkColorModelHSB(),
new DarkColorModelCMYK()), new DarkColorModelCMYK()),
new DarkSwatchesChooserPanel(), new DarkSwatchesChooserPanel(),
}; };
} }
@Override @Override

7
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkSwatchesChooserPanel.java

@ -31,12 +31,7 @@ import javax.swing.border.LineBorder;
import javax.swing.colorchooser.AbstractColorChooserPanel; import javax.swing.colorchooser.AbstractColorChooserPanel;
import javax.swing.colorchooser.ColorSelectionModel; import javax.swing.colorchooser.ColorSelectionModel;
import java.awt.*; import java.awt.*;
import java.awt.event.KeyAdapter; import java.awt.event.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.Serializable; import java.io.Serializable;
/** /**

902
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/MainSwatchPanel.java

@ -50,456 +50,456 @@ class MainSwatchPanel extends SwatchPanel {
private int[] initRawValues() { private int[] initRawValues() {
return new int[]{ return new int[]{
0, 0, 0, 0, 0, 0,
31, 0, 0, 31, 0, 0,
31, 6, 0, 31, 6, 0,
31, 12, 0, 31, 12, 0,
31, 18, 0, 31, 18, 0,
31, 24, 0, 31, 24, 0,
31, 31, 0, 31, 31, 0,
24, 31, 0, 24, 31, 0,
18, 31, 0, 18, 31, 0,
12, 31, 0, 12, 31, 0,
6, 31, 0, 6, 31, 0,
0, 31, 0, 0, 31, 0,
0, 31, 6, 0, 31, 6,
0, 31, 12, 0, 31, 12,
0, 31, 18, 0, 31, 18,
0, 31, 24, 0, 31, 24,
0, 31, 31, 0, 31, 31,
0, 24, 31, 0, 24, 31,
0, 18, 31, 0, 18, 31,
0, 12, 31, 0, 12, 31,
0, 6, 31, 0, 6, 31,
0, 0, 31, 0, 0, 31,
6, 0, 31, 6, 0, 31,
12, 0, 31, 12, 0, 31,
18, 0, 31, 18, 0, 31,
24, 0, 31, 24, 0, 31,
31, 0, 31, 31, 0, 31,
31, 0, 24, 31, 0, 24,
31, 0, 18, 31, 0, 18,
31, 0, 12, 31, 0, 12,
18, 18, 18, 18, 18, 18,
61, 0, 0, 61, 0, 0,
61, 12, 0, 61, 12, 0,
61, 24, 0, 61, 24, 0,
61, 37, 0, 61, 37, 0,
61, 49, 0, 61, 49, 0,
61, 61, 0, 61, 61, 0,
49, 61, 0, 49, 61, 0,
37, 61, 0, 37, 61, 0,
24, 61, 0, 24, 61, 0,
12, 61, 0, 12, 61, 0,
0, 61, 0, 0, 61, 0,
0, 61, 12, 0, 61, 12,
0, 61, 24, 0, 61, 24,
0, 61, 37, 0, 61, 37,
0, 61, 49, 0, 61, 49,
0, 61, 61, 0, 61, 61,
0, 49, 61, 0, 49, 61,
0, 37, 61, 0, 37, 61,
0, 24, 61, 0, 24, 61,
0, 12, 61, 0, 12, 61,
0, 0, 61, 0, 0, 61,
11, 0, 61, 11, 0, 61,
24, 0, 61, 24, 0, 61,
37, 0, 61, 37, 0, 61,
49, 0, 61, 49, 0, 61,
61, 0, 61, 61, 0, 61,
61, 0, 49, 61, 0, 49,
61, 0, 37, 61, 0, 37,
61, 0, 24, 61, 0, 24,
36, 36, 36, 36, 36, 36,
92, 0, 0, 92, 0, 0,
92, 18, 0, 92, 18, 0,
92, 37, 0, 92, 37, 0,
92, 55, 0, 92, 55, 0,
92, 73, 0, 92, 73, 0,
92, 92, 0, 92, 92, 0,
73, 92, 0, 73, 92, 0,
55, 92, 0, 55, 92, 0,
37, 92, 0, 37, 92, 0,
18, 92, 0, 18, 92, 0,
0, 92, 0, 0, 92, 0,
0, 92, 18, 0, 92, 18,
0, 92, 37, 0, 92, 37,
0, 92, 55, 0, 92, 55,
0, 92, 73, 0, 92, 73,
0, 92, 92, 0, 92, 92,
0, 73, 92, 0, 73, 92,
0, 55, 92, 0, 55, 92,
0, 37, 92, 0, 37, 92,
0, 18, 92, 0, 18, 92,
0, 0, 92, 0, 0, 92,
17, 0, 92, 17, 0, 92,
37, 0, 92, 37, 0, 92,
55, 0, 92, 55, 0, 92,
73, 0, 92, 73, 0, 92,
92, 0, 92, 92, 0, 92,
92, 0, 73, 92, 0, 73,
92, 0, 55, 92, 0, 55,
92, 0, 37, 92, 0, 37,
54, 54, 54, 54, 54, 54,
128, 0, 0, 128, 0, 0,
128, 26, 0, 128, 26, 0,
128, 51, 0, 128, 51, 0,
128, 77, 0, 128, 77, 0,
128, 102, 0, 128, 102, 0,
128, 128, 0, 128, 128, 0,
102, 128, 0, 102, 128, 0,
77, 128, 0, 77, 128, 0,
51, 128, 0, 51, 128, 0,
26, 128, 0, 26, 128, 0,
0, 128, 0, 0, 128, 0,
0, 128, 25, 0, 128, 25,
0, 128, 51, 0, 128, 51,
0, 128, 77, 0, 128, 77,
0, 128, 102, 0, 128, 102,
0, 128, 128, 0, 128, 128,
0, 102, 128, 0, 102, 128,
0, 77, 128, 0, 77, 128,
0, 51, 128, 0, 51, 128,
0, 26, 128, 0, 26, 128,
0, 0, 128, 0, 0, 128,
23, 0, 128, 23, 0, 128,
51, 0, 128, 51, 0, 128,
77, 0, 128, 77, 0, 128,
102, 0, 128, 102, 0, 128,
128, 0, 128, 128, 0, 128,
128, 0, 102, 128, 0, 102,
128, 0, 76, 128, 0, 76,
128, 0, 51, 128, 0, 51,
72, 72, 72, 72, 72, 72,
158, 0, 0, 158, 0, 0,
158, 32, 0, 158, 32, 0,
158, 63, 0, 158, 63, 0,
158, 95, 0, 158, 95, 0,
158, 126, 0, 158, 126, 0,
158, 158, 0, 158, 158, 0,
126, 158, 0, 126, 158, 0,
95, 158, 0, 95, 158, 0,
63, 158, 0, 63, 158, 0,
32, 158, 0, 32, 158, 0,
0, 158, 0, 0, 158, 0,
0, 158, 32, 0, 158, 32,
0, 158, 63, 0, 158, 63,
0, 158, 95, 0, 158, 95,
0, 158, 126, 0, 158, 126,
0, 158, 158, 0, 158, 158,
0, 126, 158, 0, 126, 158,
0, 95, 158, 0, 95, 158,
0, 63, 158, 0, 63, 158,
0, 32, 158, 0, 32, 158,
0, 0, 158, 0, 0, 158,
29, 0, 158, 29, 0, 158,
63, 0, 158, 63, 0, 158,
95, 0, 158, 95, 0, 158,
126, 0, 158, 126, 0, 158,
158, 0, 158, 158, 0, 158,
158, 0, 126, 158, 0, 126,
158, 0, 95, 158, 0, 95,
158, 0, 63, 158, 0, 63,
91, 91, 91, 91, 91, 91,
189, 0, 0, 189, 0, 0,
189, 38, 0, 189, 38, 0,
189, 75, 0, 189, 75, 0,
189, 113, 0, 189, 113, 0,
189, 151, 0, 189, 151, 0,
189, 189, 0, 189, 189, 0,
151, 189, 0, 151, 189, 0,
113, 189, 0, 113, 189, 0,
75, 189, 0, 75, 189, 0,
38, 189, 0, 38, 189, 0,
0, 189, 0, 0, 189, 0,
0, 189, 38, 0, 189, 38,
0, 189, 75, 0, 189, 75,
0, 189, 113, 0, 189, 113,
0, 189, 151, 0, 189, 151,
0, 189, 189, 0, 189, 189,
0, 151, 189, 0, 151, 189,
0, 113, 189, 0, 113, 189,
0, 75, 189, 0, 75, 189,
0, 38, 189, 0, 38, 189,
0, 0, 189, 0, 0, 189,
35, 0, 189, 35, 0, 189,
75, 0, 189, 75, 0, 189,
113, 0, 189, 113, 0, 189,
151, 0, 189, 151, 0, 189,
189, 0, 189, 189, 0, 189,
189, 0, 151, 189, 0, 151,
189, 0, 113, 189, 0, 113,
189, 0, 75, 189, 0, 75,
109, 109, 109, 109, 109, 109,
219, 0, 0, 219, 0, 0,
219, 44, 0, 219, 44, 0,
219, 88, 0, 219, 88, 0,
219, 132, 0, 219, 132, 0,
219, 175, 0, 219, 175, 0,
219, 219, 0, 219, 219, 0,
175, 219, 0, 175, 219, 0,
132, 219, 0, 132, 219, 0,
88, 219, 0, 88, 219, 0,
44, 219, 0, 44, 219, 0,
0, 219, 0, 0, 219, 0,
0, 219, 44, 0, 219, 44,
0, 219, 88, 0, 219, 88,
0, 219, 132, 0, 219, 132,
0, 219, 175, 0, 219, 175,
0, 219, 219, 0, 219, 219,
0, 175, 219, 0, 175, 219,
0, 132, 219, 0, 132, 219,
0, 88, 219, 0, 88, 219,
0, 44, 219, 0, 44, 219,
0, 0, 219, 0, 0, 219,
40, 0, 219, 40, 0, 219,
88, 0, 219, 88, 0, 219,
132, 0, 219, 132, 0, 219,
175, 0, 219, 175, 0, 219,
219, 0, 219, 219, 0, 219,
219, 0, 175, 219, 0, 175,
219, 0, 132, 219, 0, 132,
219, 0, 88, 219, 0, 88,
127, 127, 127, 127, 127, 127,
255, 0, 0, 255, 0, 0,
255, 51, 0, 255, 51, 0,
255, 102, 0, 255, 102, 0,
255, 153, 0, 255, 153, 0,
255, 204, 0, 255, 204, 0,
255, 255, 0, 255, 255, 0,
204, 255, 0, 204, 255, 0,
153, 255, 0, 153, 255, 0,
102, 255, 0, 102, 255, 0,
51, 255, 0, 51, 255, 0,
0, 255, 0, 0, 255, 0,
0, 255, 51, 0, 255, 51,
0, 255, 102, 0, 255, 102,
0, 255, 153, 0, 255, 153,
0, 255, 204, 0, 255, 204,
0, 255, 255, 0, 255, 255,
0, 204, 255, 0, 204, 255,
0, 153, 255, 0, 153, 255,
0, 102, 255, 0, 102, 255,
0, 51, 255, 0, 51, 255,
0, 0, 255, 0, 0, 255,
47, 0, 255, 47, 0, 255,
102, 0, 255, 102, 0, 255,
153, 0, 255, 153, 0, 255,
204, 0, 255, 204, 0, 255,
255, 0, 255, 255, 0, 255,
255, 0, 204, 255, 0, 204,
255, 0, 153, 255, 0, 153,
255, 0, 102, 255, 0, 102,
145, 145, 145, 145, 145, 145,
255, 31, 31, 255, 31, 31,
255, 75, 31, 255, 75, 31,
255, 120, 31, 255, 120, 31,
255, 165, 31, 255, 165, 31,
255, 210, 31, 255, 210, 31,
255, 255, 31, 255, 255, 31,
210, 255, 31, 210, 255, 31,
165, 255, 31, 165, 255, 31,
120, 255, 31, 120, 255, 31,
75, 255, 31, 75, 255, 31,
31, 255, 31, 31, 255, 31,
31, 255, 75, 31, 255, 75,
31, 255, 120, 31, 255, 120,
31, 255, 165, 31, 255, 165,
31, 255, 210, 31, 255, 210,
31, 255, 255, 31, 255, 255,
31, 210, 255, 31, 210, 255,
31, 165, 255, 31, 165, 255,
31, 120, 255, 31, 120, 255,
31, 75, 255, 31, 75, 255,
31, 31, 255, 31, 31, 255,
72, 31, 255, 72, 31, 255,
120, 31, 255, 120, 31, 255,
165, 31, 255, 165, 31, 255,
210, 31, 255, 210, 31, 255,
255, 31, 255, 255, 31, 255,
255, 31, 210, 255, 31, 210,
255, 31, 165, 255, 31, 165,
255, 31, 120, 255, 31, 120,
163, 163, 163, 163, 163, 163,
255, 61, 61, 255, 61, 61,
255, 100, 61, 255, 100, 61,
255, 139, 61, 255, 139, 61,
255, 177, 61, 255, 177, 61,
255, 216, 61, 255, 216, 61,
255, 255, 61, 255, 255, 61,
216, 255, 61, 216, 255, 61,
177, 255, 61, 177, 255, 61,
139, 255, 61, 139, 255, 61,
100, 255, 61, 100, 255, 61,
61, 255, 61, 61, 255, 61,
61, 255, 100, 61, 255, 100,
61, 255, 139, 61, 255, 139,
61, 255, 177, 61, 255, 177,
61, 255, 216, 61, 255, 216,
61, 255, 255, 61, 255, 255,
61, 216, 255, 61, 216, 255,
61, 177, 255, 61, 177, 255,
61, 139, 255, 61, 139, 255,
61, 100, 255, 61, 100, 255,
61, 61, 255, 61, 61, 255,
97, 61, 255, 97, 61, 255,
139, 61, 255, 139, 61, 255,
177, 61, 255, 177, 61, 255,
216, 61, 255, 216, 61, 255,
255, 61, 255, 255, 61, 255,
255, 61, 216, 255, 61, 216,
255, 61, 177, 255, 61, 177,
255, 61, 139, 255, 61, 139,
182, 182, 182, 182, 182, 182,
255, 92, 92, 255, 92, 92,
255, 124, 92, 255, 124, 92,
255, 157, 92, 255, 157, 92,
255, 190, 92, 255, 190, 92,
255, 222, 92, 255, 222, 92,
255, 255, 92, 255, 255, 92,
222, 255, 92, 222, 255, 92,
190, 255, 92, 190, 255, 92,
157, 255, 92, 157, 255, 92,
124, 255, 92, 124, 255, 92,
92, 255, 92, 92, 255, 92,
92, 255, 124, 92, 255, 124,
92, 255, 157, 92, 255, 157,
92, 255, 190, 92, 255, 190,
92, 255, 222, 92, 255, 222,
92, 255, 255, 92, 255, 255,
92, 222, 255, 92, 222, 255,
92, 190, 255, 92, 190, 255,
92, 157, 255, 92, 157, 255,
92, 124, 255, 92, 124, 255,
92, 92, 255, 92, 92, 255,
122, 92, 255, 122, 92, 255,
157, 92, 255, 157, 92, 255,
190, 92, 255, 190, 92, 255,
222, 92, 255, 222, 92, 255,
255, 92, 255, 255, 92, 255,
255, 92, 222, 255, 92, 222,
255, 92, 190, 255, 92, 190,
255, 92, 157, 255, 92, 157,
200, 200, 200, 200, 200, 200,
255, 128, 128, 255, 128, 128,
255, 153, 128, 255, 153, 128,
255, 179, 128, 255, 179, 128,
255, 204, 128, 255, 204, 128,
255, 230, 128, 255, 230, 128,
255, 255, 128, 255, 255, 128,
229, 255, 128, 229, 255, 128,
204, 255, 128, 204, 255, 128,
179, 255, 128, 179, 255, 128,
153, 255, 128, 153, 255, 128,
128, 255, 128, 128, 255, 128,
128, 255, 153, 128, 255, 153,
128, 255, 179, 128, 255, 179,
128, 255, 204, 128, 255, 204,
128, 255, 229, 128, 255, 229,
128, 255, 255, 128, 255, 255,
128, 229, 255, 128, 229, 255,
128, 204, 255, 128, 204, 255,
128, 179, 255, 128, 179, 255,
128, 153, 255, 128, 153, 255,
128, 128, 255, 128, 128, 255,
151, 128, 255, 151, 128, 255,
178, 128, 255, 178, 128, 255,
204, 128, 255, 204, 128, 255,
230, 128, 255, 230, 128, 255,
255, 128, 255, 255, 128, 255,
255, 128, 229, 255, 128, 229,
255, 128, 204, 255, 128, 204,
255, 128, 179, 255, 128, 179,
218, 218, 218, 218, 218, 218,
255, 158, 158, 255, 158, 158,
255, 177, 158, 255, 177, 158,
255, 197, 158, 255, 197, 158,
255, 216, 158, 255, 216, 158,
255, 236, 158, 255, 236, 158,
255, 255, 158, 255, 255, 158,
236, 255, 158, 236, 255, 158,
216, 255, 158, 216, 255, 158,
197, 255, 158, 197, 255, 158,
177, 255, 158, 177, 255, 158,
158, 255, 158, 158, 255, 158,
158, 255, 177, 158, 255, 177,
158, 255, 197, 158, 255, 197,
158, 255, 216, 158, 255, 216,
158, 255, 236, 158, 255, 236,
158, 255, 255, 158, 255, 255,
158, 236, 255, 158, 236, 255,
158, 216, 255, 158, 216, 255,
158, 197, 255, 158, 197, 255,
158, 177, 255, 158, 177, 255,
158, 158, 255, 158, 158, 255,
176, 158, 255, 176, 158, 255,
197, 158, 255, 197, 158, 255,
216, 158, 255, 216, 158, 255,
236, 158, 255, 236, 158, 255,
255, 158, 255, 255, 158, 255,
255, 158, 236, 255, 158, 236,
255, 158, 216, 255, 158, 216,
255, 158, 197, 255, 158, 197,
236, 236, 236, 236, 236, 236,
255, 189, 189, 255, 189, 189,
255, 202, 189, 255, 202, 189,
255, 215, 189, 255, 215, 189,
255, 228, 189, 255, 228, 189,
255, 242, 189, 255, 242, 189,
255, 255, 189, 255, 255, 189,
242, 255, 189, 242, 255, 189,
228, 255, 189, 228, 255, 189,
215, 255, 189, 215, 255, 189,
202, 255, 189, 202, 255, 189,
189, 255, 189, 189, 255, 189,
189, 255, 202, 189, 255, 202,
189, 255, 215, 189, 255, 215,
189, 255, 228, 189, 255, 228,
189, 255, 242, 189, 255, 242,
189, 255, 255, 189, 255, 255,
189, 242, 255, 189, 242, 255,
189, 228, 255, 189, 228, 255,
189, 215, 255, 189, 215, 255,
189, 202, 255, 189, 202, 255,
189, 189, 255, 189, 189, 255,
201, 189, 255, 201, 189, 255,
215, 189, 255, 215, 189, 255,
228, 189, 255, 228, 189, 255,
242, 189, 255, 242, 189, 255,
255, 189, 255, 255, 189, 255,
255, 189, 242, 255, 189, 242,
255, 189, 228, 255, 189, 228,
255, 189, 215, 255, 189, 215,
255, 255, 255, 255, 255, 255,
255, 219, 219, 255, 219, 219,
255, 226, 219, 255, 226, 219,
255, 234, 219, 255, 234, 219,
255, 241, 219, 255, 241, 219,
255, 248, 219, 255, 248, 219,
255, 255, 219, 255, 255, 219,
248, 255, 219, 248, 255, 219,
241, 255, 219, 241, 255, 219,
234, 255, 219, 234, 255, 219,
226, 255, 219, 226, 255, 219,
219, 255, 219, 219, 255, 219,
219, 255, 226, 219, 255, 226,
219, 255, 234, 219, 255, 234,
219, 255, 241, 219, 255, 241,
219, 255, 248, 219, 255, 248,
219, 255, 255, 219, 255, 255,
219, 248, 255, 219, 248, 255,
219, 241, 255, 219, 241, 255,
219, 234, 255, 219, 234, 255,
219, 226, 255, 219, 226, 255,
219, 219, 255, 219, 219, 255,
226, 219, 255, 226, 219, 255,
234, 219, 255, 234, 219, 255,
241, 219, 255, 241, 219, 255,
248, 219, 255, 248, 219, 255,
255, 219, 255, 255, 219, 255,
255, 219, 248, 255, 219, 248,
255, 219, 241, 255, 219, 241,
255, 219, 234, 255, 219, 234,
}; };
} }
} }

2
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SlideComponent.java

@ -53,7 +53,7 @@ class SlideComponent extends JComponent implements ColorListener {
protected Color borderColor; protected Color borderColor;
protected Color shadowColor; protected Color shadowColor;
protected Color knobFill; protected Color knobFill;
private boolean isOpacity; private final boolean isOpacity;
private int pointerValue = 0; private int pointerValue = 0;
private int value = 0; private int value = 0;
private Unit unitType = Unit.LEVEL; private Unit unitType = Unit.LEVEL;

10
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SwatchPanel.java

@ -42,9 +42,9 @@ abstract class SwatchPanel extends JPanel {
protected Dimension numSwatches; protected Dimension numSwatches;
protected Dimension gap; protected Dimension gap;
private final ToolTipContext toolTipContext = new ToolTipContext(this) private final ToolTipContext toolTipContext = new ToolTipContext(this)
.setAlignment(Alignment.CENTER) .setAlignment(Alignment.CENTER)
.setToolTipRectSupplier(this::getSwatchBounds) .setToolTipRectSupplier(this::getSwatchBounds)
.setHideOnExit(true); .setHideOnExit(true);
private int selRow; private int selRow;
private int selCol; private int selCol;
@ -86,14 +86,14 @@ abstract class SwatchPanel extends JPanel {
selCol--; selCol--;
repaint(); repaint();
} else if (selCol < numSwatches.width - 1 } else if (selCol < numSwatches.width - 1
&& !SwatchPanel.this.getComponentOrientation().isLeftToRight()) { && !SwatchPanel.this.getComponentOrientation().isLeftToRight()) {
selCol++; selCol++;
repaint(); repaint();
} }
break; break;
case KeyEvent.VK_RIGHT: case KeyEvent.VK_RIGHT:
if (selCol < numSwatches.width - 1 if (selCol < numSwatches.width - 1
&& SwatchPanel.this.getComponentOrientation().isLeftToRight()) { && SwatchPanel.this.getComponentOrientation().isLeftToRight()) {
selCol++; selCol++;
repaint(); repaint();
} else if (selCol > 0 && !SwatchPanel.this.getComponentOrientation().isLeftToRight()) { } else if (selCol > 0 && !SwatchPanel.this.getComponentOrientation().isLeftToRight()) {

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

@ -36,11 +36,11 @@ public interface ComboBoxConstants {
static boolean isTreeCellEditor(final Component c) { static boolean isTreeCellEditor(final Component c) {
return c instanceof JComponent return c instanceof JComponent
&& Boolean.TRUE.equals(((JComponent) c).getClientProperty(KEY_IS_TREE_EDITOR)); && Boolean.TRUE.equals(((JComponent) c).getClientProperty(KEY_IS_TREE_EDITOR));
} }
static boolean isTableCellEditor(final Component c) { static boolean isTableCellEditor(final Component c) {
return c instanceof JComponent return c instanceof JComponent
&& Boolean.TRUE.equals(((JComponent) c).getClientProperty(KEY_IS_TABLE_EDITOR)); && Boolean.TRUE.equals(((JComponent) c).getClientProperty(KEY_IS_TABLE_EDITOR));
} }
} }

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

@ -39,14 +39,14 @@ public class DarkComboBoxBorder implements Border, UIResource {
protected final DarkComboBoxUI ui; protected final DarkComboBoxUI ui;
protected Insets boxPadding; protected Insets boxPadding;
protected Insets cellPadding; protected Insets cellPadding;
protected int borderSize; protected final int borderSize;
protected int arcSize; protected final int arcSize;
protected Color focusBorderColor; protected final Color focusBorderColor;
protected Color inactiveBackground; protected final Color inactiveBackground;
protected Color arrowBackground; protected final Color arrowBackground;
protected Color background; protected final Color background;
protected Color borderColor; protected final Color borderColor;
protected Color inactiveBorderColor; protected final Color inactiveBorderColor;
public DarkComboBoxBorder(final DarkComboBoxUI ui) { public DarkComboBoxBorder(final DarkComboBoxUI ui) {
this.ui = ui; this.ui = ui;

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

@ -33,7 +33,7 @@ import java.beans.PropertyChangeListener;
public class DarkComboBoxListener extends MouseAdapter implements PropertyChangeListener, ComboBoxConstants { public class DarkComboBoxListener extends MouseAdapter implements PropertyChangeListener, ComboBoxConstants {
protected JComboBox<?> comboBox; protected final JComboBox<?> comboBox;
public DarkComboBoxListener(final JComboBox<?> comboBox) { public DarkComboBoxListener(final JComboBox<?> comboBox) {
this.comboBox = comboBox; this.comboBox = comboBox;

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

@ -265,7 +265,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements ComboBoxConstants
int buttonWidth = squareButton int buttonWidth = squareButton
? buttonHeight ? buttonHeight
: arrowButton.getPreferredSize().width : arrowButton.getPreferredSize().width
+ arrowButton.getInsets().left + arrowButton.getInsets().right; + arrowButton.getInsets().left + arrowButton.getInsets().right;
//adjust the size based on the button width //adjust the size based on the button width
size.height += insets.top + insets.bottom; size.height += insets.top + insets.bottom;
size.width += insets.left + insets.right + buttonWidth; size.width += insets.left + insets.right + buttonWidth;

19
core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java

@ -58,7 +58,7 @@ public class DarkComboPopup extends BasicComboPopup {
* *
* @param combo an instance of {@code JComboBox} * @param combo an instance of {@code JComboBox}
*/ */
public DarkComboPopup(final JComboBox combo) { public DarkComboPopup(final JComboBox<Object> combo) {
super(combo); super(combo);
} }
@ -114,11 +114,6 @@ public class DarkComboPopup extends BasicComboPopup {
setFocusable(false); setFocusable(false);
} }
@Override
protected void configureList() {
super.configureList();
}
@Override @Override
protected void togglePopup() { protected void togglePopup() {
if (comboBox.getItemCount() == 0) return; if (comboBox.getItemCount() == 0) return;
@ -131,18 +126,6 @@ public class DarkComboPopup extends BasicComboPopup {
} }
} }
@Override
public void show() {
super.show();
}
@Override
public void hide() {
super.hide();
}
protected void reset() { protected void reset() {
lastEvent = 0; lastEvent = 0;
if (visible) { if (visible) {

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

@ -145,7 +145,7 @@ public class DarkFileChooserUI extends DarkFileChooserUIBridge {
} }
} }
} }
); );
if (fileChooser.isMultiSelectionEnabled()) { if (fileChooser.isMultiSelectionEnabled()) {
setFileName(fileNameString(fileChooser.getSelectedFiles())); setFileName(fileNameString(fileChooser.getSelectedFiles()));
} else { } else {

85
core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUIBridge.java

@ -68,18 +68,18 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
protected static final Dimension vstrut5 = new Dimension(1, 5); protected static final Dimension vstrut5 = new Dimension(1, 5);
static final int space = 10; static final int space = 10;
// Preferred and Minimum sizes for the dialog box // Preferred and Minimum sizes for the dialog box
protected static int PREF_WIDTH = 500; protected static final int PREF_WIDTH = 500;
protected static int PREF_HEIGHT = 326; protected static final int PREF_HEIGHT = 326;
protected static Dimension PREF_SIZE = new Dimension(PREF_WIDTH, PREF_HEIGHT); protected static final Dimension PREF_SIZE = new Dimension(PREF_WIDTH, PREF_HEIGHT);
protected static int MIN_WIDTH = 500; protected static final int MIN_WIDTH = 500;
protected static int MIN_HEIGHT = 326; protected static final int MIN_HEIGHT = 326;
protected static int LIST_PREF_WIDTH = 405; protected static final int LIST_PREF_WIDTH = 405;
protected static int LIST_PREF_HEIGHT = 135; protected static final int LIST_PREF_HEIGHT = 135;
protected static Dimension LIST_PREF_SIZE = new Dimension(LIST_PREF_WIDTH, LIST_PREF_HEIGHT); protected static final Dimension LIST_PREF_SIZE = new Dimension(LIST_PREF_WIDTH, LIST_PREF_HEIGHT);
protected JLabel lookInLabel; protected JLabel lookInLabel;
protected JComboBox<Object> directoryComboBox; protected JComboBox<Object> directoryComboBox;
protected DirectoryComboBoxModel directoryComboBoxModel; protected DirectoryComboBoxModel directoryComboBoxModel;
protected Action directoryComboBoxAction = new DirectoryComboBoxAction(); protected final Action directoryComboBoxAction = new DirectoryComboBoxAction();
protected FilterComboBoxModel filterComboBoxModel; protected FilterComboBoxModel filterComboBoxModel;
protected JTextField fileNameTextField; protected JTextField fileNameTextField;
protected DarkFilePaneUIBridge filePane; protected DarkFilePaneUIBridge filePane;
@ -273,7 +273,7 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
File f = (File) e.getNewValue(); File f = (File) e.getNewValue();
JFileChooser fc = getFileChooser(); JFileChooser fc = getFileChooser();
if (f != null if (f != null
&& ((fc.isFileSelectionEnabled() && !f.isDirectory()) && ((fc.isFileSelectionEnabled() && !f.isDirectory())
|| (f.isDirectory() && fc.isDirectorySelectionEnabled()))) { || (f.isDirectory() && fc.isDirectorySelectionEnabled()))) {
setFileName(fileNameString(f)); setFileName(fileNameString(f));
@ -284,8 +284,8 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
File[] files = (File[]) e.getNewValue(); File[] files = (File[]) e.getNewValue();
JFileChooser fc = getFileChooser(); JFileChooser fc = getFileChooser();
if (files != null if (files != null
&& files.length > 0 && files.length > 0
&& (files.length > 1 || fc.isDirectorySelectionEnabled() || !files[0].isDirectory())) { && (files.length > 1 || fc.isDirectorySelectionEnabled() || !files[0].isDirectory())) {
setFileName(fileNameString(files)); setFileName(fileNameString(files));
} }
} }
@ -322,9 +322,9 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
JFileChooser fc = getFileChooser(); JFileChooser fc = getFileChooser();
File currentDirectory = fc.getCurrentDirectory(); File currentDirectory = fc.getCurrentDirectory();
if (currentDirectory != null if (currentDirectory != null
&& fc.isDirectorySelectionEnabled() && fc.isDirectorySelectionEnabled()
&& !fc.isFileSelectionEnabled() && !fc.isFileSelectionEnabled()
&& fc.getFileSystemView().isFileSystem(currentDirectory)) { && fc.getFileSystemView().isFileSystem(currentDirectory)) {
setFileName(currentDirectory.getPath()); setFileName(currentDirectory.getPath());
} else { } else {
@ -545,8 +545,8 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
} else { } else {
JFileChooser fc = getFileChooser(); JFileChooser fc = getFileChooser();
if ((fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) || if ((fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) ||
(fc.isDirectorySelectionEnabled() && fc.isFileSelectionEnabled() (fc.isDirectorySelectionEnabled() && fc.isFileSelectionEnabled()
&& fc.getFileSystemView().isFileSystemRoot(file))) { && fc.getFileSystemView().isFileSystemRoot(file))) {
return file.getPath(); return file.getPath();
} else { } else {
return file.getName(); return file.getName();
@ -592,8 +592,8 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
} }
protected static void groupLabels(final AlignedLabel[] group) { protected static void groupLabels(final AlignedLabel[] group) {
for (int i = 0; i < group.length; i++) { for (AlignedLabel alignedLabel : group) {
group[i].group = group; alignedLabel.group = group;
} }
} }
@ -631,8 +631,8 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
int prefWidth = PREF_SIZE.width; int prefWidth = PREF_SIZE.width;
Dimension d = c.getLayout().preferredLayoutSize(c); Dimension d = c.getLayout().preferredLayoutSize(c);
if (d != null) { if (d != null) {
return new Dimension(d.width < prefWidth ? prefWidth : d.width, return new Dimension(Math.max(d.width, prefWidth),
d.height < PREF_SIZE.height ? PREF_SIZE.height : d.height); Math.max(d.height, PREF_SIZE.height));
} else { } else {
return new Dimension(prefWidth, PREF_SIZE.height); return new Dimension(prefWidth, PREF_SIZE.height);
} }
@ -699,7 +699,7 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
* right, flushed right. The widths of all components will be set to the largest preferred size width. * right, flushed right. The widths of all components will be set to the largest preferred size width.
*/ */
protected static class ButtonAreaLayout implements LayoutManager { protected static class ButtonAreaLayout implements LayoutManager {
protected int hGap = 5; protected final int hGap = 5;
protected int topMargin = 17; protected int topMargin = 17;
public void addLayoutComponent(final String string, final Component comp) { public void addLayoutComponent(final String string, final Component comp) {
@ -724,13 +724,13 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
int extraWidth = cInsets.left + cInsets.right; int extraWidth = cInsets.left + cInsets.right;
int maxWidth = 0; int maxWidth = 0;
for (int counter = 0; counter < numChildren; counter++) { for (Component child : children) {
Dimension aSize = children[counter].getPreferredSize(); Dimension aSize = child.getPreferredSize();
height = Math.max(height, aSize.height); height = Math.max(height, aSize.height);
maxWidth = Math.max(maxWidth, aSize.width); maxWidth = Math.max(maxWidth, aSize.width);
} }
return new Dimension(extraWidth + numChildren * maxWidth + return new Dimension(extraWidth + numChildren * maxWidth +
(numChildren - 1) * hGap, (numChildren - 1) * hGap,
extraHeight + height); extraHeight + height);
} }
} }
@ -820,7 +820,7 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
* *
* @deprecated As of JDK version 9. Obsolete class. * @deprecated As of JDK version 9. Obsolete class.
*/ */
protected class SingleClickListener extends MouseAdapter { protected static class SingleClickListener extends MouseAdapter {
/** /**
* Constructs an instance of {@code SingleClickListener}. * Constructs an instance of {@code SingleClickListener}.
* *
@ -836,16 +836,16 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
* @deprecated As of JDK version 9. Obsolete class. * @deprecated As of JDK version 9. Obsolete class.
*/ */
@SuppressWarnings("serial") // Superclass is not serializable across versions @SuppressWarnings("serial") // Superclass is not serializable across versions
protected class FileRenderer extends DefaultListCellRenderer { protected static class FileRenderer extends DefaultListCellRenderer {
} }
// //
// Renderer for DirectoryComboBox // Renderer for DirectoryComboBox
// //
@SuppressWarnings("serial") @SuppressWarnings("serial")
// Superclass is not serializable across versions // Superclass is not serializable across versions
class DirectoryComboBoxRenderer extends DefaultListCellRenderer { class DirectoryComboBoxRenderer extends DefaultListCellRenderer {
IndentIcon ii = new IndentIcon(); final IndentIcon ii = new IndentIcon();
public Component getListCellRendererComponent(final JList<?> list, final Object value, public Component getListCellRendererComponent(final JList<?> list, final Object value,
final int index, final boolean isSelected, final int index, final boolean isSelected,
@ -859,8 +859,7 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
} }
File directory = (File) value; File directory = (File) value;
setText(getFileChooser().getName(directory)); setText(getFileChooser().getName(directory));
Icon icon = getFileChooser().getIcon(directory); ii.icon = getFileChooser().getIcon(directory);
ii.icon = icon;
ii.depth = directoryComboBoxModel.getDepth(index); ii.depth = directoryComboBoxModel.getDepth(index);
setIcon(ii); setIcon(ii);
@ -868,7 +867,7 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
} }
} }
class IndentIcon implements Icon { static class IndentIcon implements Icon {
Icon icon = null; Icon icon = null;
int depth = 0; int depth = 0;
@ -896,11 +895,11 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
*/ */
@SuppressWarnings("serial") // Superclass is not serializable across versions @SuppressWarnings("serial") // Superclass is not serializable across versions
protected class DirectoryComboBoxModel extends AbstractListModel<Object> implements ComboBoxModel<Object> { protected class DirectoryComboBoxModel extends AbstractListModel<Object> implements ComboBoxModel<Object> {
Vector<File> directories = new Vector<File>(); final Vector<File> directories = new Vector<>();
int[] depths = null; int[] depths = null;
File selectedDirectory = null; File selectedDirectory = null;
JFileChooser chooser = getFileChooser(); final JFileChooser chooser = getFileChooser();
FileSystemView fsv = chooser.getFileSystemView(); final FileSystemView fsv = chooser.getFileSystemView();
/** /**
* Constructs an instance of {@code DirectoryComboBoxModel}. * Constructs an instance of {@code DirectoryComboBoxModel}.
@ -951,7 +950,7 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
File sf = useShellFolder ? ShellFolder.getShellFolder(canonical) File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
: canonical; : canonical;
File f = sf; File f = sf;
Vector<File> path = new Vector<File>(10); Vector<File> path = new Vector<>(10);
do { do {
path.addElement(f); path.addElement(f);
} while ((f = f.getParentFile()) != null); } while ((f = f.getParentFile()) != null);
@ -1027,7 +1026,8 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
* Data model for a type-face selection combo-box. * Data model for a type-face selection combo-box.
*/ */
@SuppressWarnings("serial") // Same-version serialization only @SuppressWarnings("serial") // Same-version serialization only
protected class FilterComboBoxModel extends AbstractListModel<Object> implements ComboBoxModel<Object>, PropertyChangeListener { protected class FilterComboBoxModel extends AbstractListModel<Object>
implements ComboBoxModel<Object>, PropertyChangeListener {
/** /**
* An array of file filters. * An array of file filters.
@ -1071,6 +1071,7 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
for (FileFilter filter : filters) { for (FileFilter filter : filters) {
if (filter == currentFilter) { if (filter == currentFilter) {
found = true; found = true;
break;
} }
} }
if (!found) { if (!found) {
@ -1124,7 +1125,7 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
} }
@SuppressWarnings("serial") // Superclass is not serializable across versions @SuppressWarnings("serial") // Superclass is not serializable across versions
protected class AlignedLabel extends JLabel { protected static class AlignedLabel extends JLabel {
protected AlignedLabel[] group; protected AlignedLabel[] group;
protected int maxWidth = 0; protected int maxWidth = 0;
@ -1148,11 +1149,11 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI {
protected int getMaxWidth() { protected int getMaxWidth() {
if (maxWidth == 0 && group != null) { if (maxWidth == 0 && group != null) {
int max = 0; int max = 0;
for (int i = 0; i < group.length; i++) { for (AlignedLabel label : group) {
max = Math.max(group[i].getSuperPreferredWidth(), max); max = Math.max(label.getSuperPreferredWidth(), max);
} }
for (int i = 0; i < group.length; i++) { for (AlignedLabel alignedLabel : group) {
group[i].maxWidth = max; alignedLabel.maxWidth = max;
} }
} }
return maxWidth; return maxWidth;

10
core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePane.java

@ -194,7 +194,7 @@ public class DarkFilePane extends DarkFilePaneUIBridge {
detailsTable.setFont(font); detailsTable.setFont(font);
TableCellRenderer headerRenderer = TableCellRenderer headerRenderer =
new AlignableTableHeaderRenderer(detailsTable.getTableHeader().getDefaultRenderer()); new AlignableTableHeaderRenderer(detailsTable.getTableHeader().getDefaultRenderer());
detailsTable.getTableHeader().setDefaultRenderer(headerRenderer); detailsTable.getTableHeader().setDefaultRenderer(headerRenderer);
TableCellRenderer cellRenderer = new DetailsTableCellRenderer(chooser); TableCellRenderer cellRenderer = new DetailsTableCellRenderer(chooser);
detailsTable.setDefaultRenderer(Object.class, cellRenderer); detailsTable.setDefaultRenderer(Object.class, cellRenderer);
@ -301,7 +301,7 @@ public class DarkFilePane extends DarkFilePaneUIBridge {
int editX = icon == null ? 20 : icon.getIconWidth() + 4; int editX = icon == null ? 20 : icon.getIconWidth() + 4;
int gap = 0; int gap = 0;
ListCellRenderer renderer = list.getCellRenderer(); ListCellRenderer<?> renderer = list.getCellRenderer();
if (renderer instanceof JLabel) { if (renderer instanceof JLabel) {
gap = ((JLabel) renderer).getIconTextGap() - 1; gap = ((JLabel) renderer).getIconTextGap() - 1;
} }
@ -446,9 +446,9 @@ public class DarkFilePane extends DarkFilePaneUIBridge {
// For single click, we handle editing file name // For single click, we handle editing file name
if (evt.getClickCount() == 1 && source instanceof JList) { if (evt.getClickCount() == 1 && source instanceof JList) {
if ((!fc.isMultiSelectionEnabled() || fc.getSelectedFiles().length <= 1) if ((!fc.isMultiSelectionEnabled() || fc.getSelectedFiles().length <= 1)
&& listSelectionModel.isSelectedIndex(index) && listSelectionModel.isSelectedIndex(index)
&& getEditIndex() == index && editFile == null && getEditIndex() == index && editFile == null
&& DarkUIUtil.isOverText(evt, index, list)) { && DarkUIUtil.isOverText(evt, index, list)) {
editFileName(index); editFileName(index);
} else { } else {
setEditIndex(index); setEditIndex(index);

168
core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePaneUIBridge.java

@ -80,10 +80,10 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
public static final int VIEWTYPE_DETAILS = 1; public static final int VIEWTYPE_DETAILS = 1;
protected static final int VIEWTYPE_COUNT = 2; protected static final int VIEWTYPE_COUNT = 2;
protected static final Cursor waitCursor = protected static final Cursor waitCursor =
Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
protected static final int COLUMN_FILENAME = 0; protected static final int COLUMN_FILENAME = 0;
protected static final int COLUMN_SIZE = 1; protected static final int COLUMN_SIZE = 1;
protected static FocusListener repaintListener = new FocusListener() { protected static final FocusListener repaintListener = new FocusListener() {
public void focusGained(final FocusEvent fe) { public void focusGained(final FocusEvent fe) {
repaintSelection(fe.getSource()); repaintSelection(fe.getSource());
} }
@ -94,7 +94,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
protected void repaintSelection(final Object source) { protected void repaintSelection(final Object source) {
if (source instanceof JList) { if (source instanceof JList) {
repaintListSelection((JList) source); repaintListSelection((JList<?>) source);
} else if (source instanceof JTable) { } else if (source instanceof JTable) {
repaintTableSelection((JTable) source); repaintTableSelection((JTable) source);
} }
@ -125,7 +125,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
}; };
protected Action[] actions; protected Action[] actions;
protected int viewType = -1; protected int viewType = -1;
protected JPanel[] viewPanels = new JPanel[VIEWTYPE_COUNT]; protected final JPanel[] viewPanels = new JPanel[VIEWTYPE_COUNT];
protected JPanel currentViewPanel; protected JPanel currentViewPanel;
protected String[] viewTypeActionNames; protected String[] viewTypeActionNames;
protected String filesListAccessibleName = null; protected String filesListAccessibleName = null;
@ -141,7 +141,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
protected String renameErrorTitleText; protected String renameErrorTitleText;
protected String renameErrorText; protected String renameErrorText;
protected String renameErrorFileExistsText; protected String renameErrorFileExistsText;
protected boolean smallIconsView = false; protected final boolean smallIconsView = false;
protected Border listViewBorder; protected Border listViewBorder;
protected Color listViewBackground; protected Color listViewBackground;
protected boolean listViewWindowsStyle; protected boolean listViewWindowsStyle;
@ -155,7 +155,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
// be selected when it appears in the model. // be selected when it appears in the model.
protected File newFolderFile; protected File newFolderFile;
// Used for accessing methods in the corresponding UI class // Used for accessing methods in the corresponding UI class
protected FileChooserUIAccessor fileChooserUIAccessor; protected final FileChooserUIAccessor fileChooserUIAccessor;
protected DetailsTableModel detailsTableModel; protected DetailsTableModel detailsTableModel;
protected DetailsTableRowSorter rowSorter; protected DetailsTableRowSorter rowSorter;
protected final KeyListener detailsKeyListener = new KeyAdapter() { protected final KeyListener detailsKeyListener = new KeyAdapter() {
@ -184,7 +184,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
int rowCount = model.getSize(); int rowCount = model.getSize();
if (detailsTable == null || rowCount == 0 || if (detailsTable == null || rowCount == 0 ||
e.isAltDown() || e.isControlDown() || e.isMetaDown()) { e.isAltDown() || e.isControlDown() || e.isMetaDown()) {
return; return;
} }
@ -240,7 +240,9 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
if (index >= 0) { if (index >= 0) {
detailsTable.getSelectionModel().setSelectionInterval(index, index); detailsTable.getSelectionModel().setSelectionInterval(index, index);
Rectangle cellRect = detailsTable.getCellRect(index, detailsTable.convertColumnIndexToView(COLUMN_FILENAME), false); Rectangle cellRect = detailsTable.getCellRect(index,
detailsTable.convertColumnIndexToView(COLUMN_FILENAME),
false);
detailsTable.scrollRectToVisible(cellRect); detailsTable.scrollRectToVisible(cellRect);
} }
} }
@ -272,7 +274,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
int lastIndex = -1; int lastIndex = -1;
File editFile = null; File editFile = null;
JTextField editCell = null; JTextField editCell = null;
protected FocusListener editorFocusListener = new FocusAdapter() { protected final FocusListener editorFocusListener = new FocusAdapter() {
public void focusLost(final FocusEvent e) { public void focusLost(final FocusEvent e) {
if (!e.isTemporary()) { if (!e.isTemporary()) {
applyEdit(); applyEdit();
@ -348,7 +350,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
Boolean prop = (Boolean) chooser.getClientProperty("FileChooser.useShellFolder"); Boolean prop = (Boolean) chooser.getClientProperty("FileChooser.useShellFolder");
return prop == null ? chooser.getFileSystemView().equals(FileSystemView.getFileSystemView()) return prop == null ? chooser.getFileSystemView().equals(FileSystemView.getFileSystemView())
: prop.booleanValue(); : prop;
} }
public void uninstallUI() { public void uninstallUI() {
@ -458,17 +460,17 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
UIDefaults metal = MetalUIDefaults.DEFAULTS; UIDefaults metal = MetalUIDefaults.DEFAULTS;
viewMenuLabelText = viewMenuLabelText =
metal.getString("FileChooser.viewMenuLabelText", l); metal.getString("FileChooser.viewMenuLabelText", l);
refreshActionLabelText = refreshActionLabelText =
metal.getString("FileChooser.refreshActionLabelText", l); metal.getString("FileChooser.refreshActionLabelText", l);
newFolderActionLabelText = newFolderActionLabelText =
metal.getString("FileChooser.newFolderActionLabelText", l); metal.getString("FileChooser.newFolderActionLabelText", l);
viewTypeActionNames = new String[VIEWTYPE_COUNT]; viewTypeActionNames = new String[VIEWTYPE_COUNT];
viewTypeActionNames[VIEWTYPE_LIST] = viewTypeActionNames[VIEWTYPE_LIST] =
metal.getString("FileChooser.listViewActionLabelText", l); metal.getString("FileChooser.listViewActionLabelText", l);
viewTypeActionNames[VIEWTYPE_DETAILS] = viewTypeActionNames[VIEWTYPE_DETAILS] =
metal.getString("FileChooser.detailsViewActionLabelText", l); metal.getString("FileChooser.detailsViewActionLabelText", l);
kiloByteString = UIManager.getString("FileChooser.fileSizeKiloBytes", l); kiloByteString = UIManager.getString("FileChooser.fileSizeKiloBytes", l);
megaByteString = UIManager.getString("FileChooser.fileSizeMegaBytes", l); megaByteString = UIManager.getString("FileChooser.fileSizeMegaBytes", l);
@ -491,7 +493,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
public Action[] getActions() { public Action[] getActions() {
if (actions == null) { if (actions == null) {
@SuppressWarnings("serial") @SuppressWarnings("serial")
// JDK-implementation class // JDK-implementation class
class FilePaneAction extends AbstractAction { class FilePaneAction extends AbstractAction {
FilePaneAction(final String name) { FilePaneAction(final String name) {
this(name, name); this(name, name);
@ -515,8 +517,8 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
JFileChooser fc = getFileChooser(); JFileChooser fc = getFileChooser();
int index = listSelectionModel.getMinSelectionIndex(); int index = listSelectionModel.getMinSelectionIndex();
if (index >= 0 && editFile == null && if (index >= 0 && editFile == null &&
(!fc.isMultiSelectionEnabled() || (!fc.isMultiSelectionEnabled() ||
fc.getSelectedFiles().length <= 1)) { fc.getSelectedFiles().length <= 1)) {
editFileName(index); editFileName(index);
} }
@ -622,7 +624,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
// Install cell editor for editing file name // Install cell editor for editing file name
if (!readOnly && columnModel.getColumnCount() > COLUMN_FILENAME) { if (!readOnly && columnModel.getColumnCount() > COLUMN_FILENAME) {
columnModel.getColumn(COLUMN_FILENAME). columnModel.getColumn(COLUMN_FILENAME).
setCellEditor(getDetailsTableCellEditor()); setCellEditor(getDetailsTableCellEditor());
} }
table.setColumnModel(columnModel); table.setColumnModel(columnModel);
@ -785,7 +787,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
// Remove files that shouldn't be selected and add files which should be selected // Remove files that shouldn't be selected and add files which should be selected
// Note: Assume files are already sorted in compareTo order. // Note: Assume files are already sorted in compareTo order.
while (shouldIndex < files.length && while (shouldIndex < files.length &&
actuallyIndex < selectedObjects.length) { actuallyIndex < selectedObjects.length) {
int comparison = files[shouldIndex].compareTo((File) selectedObjects[actuallyIndex]); int comparison = files[shouldIndex].compareTo((File) selectedObjects[actuallyIndex]);
if (comparison < 0) { if (comparison < 0) {
doSelectFile(files[shouldIndex++]); doSelectFile(files[shouldIndex++]);
@ -810,7 +812,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
// restore the anchor and lead // restore the anchor and lead
if (listSelectionModel instanceof DefaultListSelectionModel) { if (listSelectionModel instanceof DefaultListSelectionModel) {
((DefaultListSelectionModel) listSelectionModel). ((DefaultListSelectionModel) listSelectionModel).
moveLeadSelectionIndex(lead); moveLeadSelectionIndex(lead);
listSelectionModel.setAnchorSelectionIndex(anchor); listSelectionModel.setAnchorSelectionIndex(anchor);
} }
} finally { } finally {
@ -846,7 +848,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
protected void doDeselectFile(final Object fileToDeselect) { protected void doDeselectFile(final Object fileToDeselect) {
int index = getRowSorter().convertRowIndexToView( int index = getRowSorter().convertRowIndexToView(
getModel().indexOf(fileToDeselect)); getModel().indexOf(fileToDeselect));
listSelectionModel.removeSelectionInterval(index, index); listSelectionModel.removeSelectionInterval(index, index);
} }
@ -855,7 +857,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
File f = (File) e.getNewValue(); File f = (File) e.getNewValue();
JFileChooser fc = getFileChooser(); JFileChooser fc = getFileChooser();
if (f != null if (f != null
&& ((fc.isFileSelectionEnabled() && !f.isDirectory()) && ((fc.isFileSelectionEnabled() && !f.isDirectory())
|| (f.isDirectory() && fc.isDirectorySelectionEnabled()))) { || (f.isDirectory() && fc.isDirectorySelectionEnabled()))) {
setFileSelected(); setFileSelected();
@ -867,8 +869,8 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
File[] files = (File[]) e.getNewValue(); File[] files = (File[]) e.getNewValue();
JFileChooser fc = getFileChooser(); JFileChooser fc = getFileChooser();
if (files != null if (files != null
&& files.length > 0 && files.length > 0
&& (files.length > 1 || fc.isDirectorySelectionEnabled() || !files[0].isDirectory())) { && (files.length > 1 || fc.isDirectorySelectionEnabled() || !files[0].isDirectory())) {
setFileSelected(); setFileSelected();
} }
} }
@ -926,32 +928,42 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
} }
String s = e.getPropertyName(); String s = e.getPropertyName();
if (s.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) { switch (s) {
doSelectedFileChanged(e); case JFileChooser.SELECTED_FILE_CHANGED_PROPERTY:
} else if (s.equals(JFileChooser.SELECTED_FILES_CHANGED_PROPERTY)) { doSelectedFileChanged(e);
doSelectedFilesChanged(e); break;
} else if (s.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) { case JFileChooser.SELECTED_FILES_CHANGED_PROPERTY:
doDirectoryChanged(e); doSelectedFilesChanged(e);
} else if (s.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) { break;
doFilterChanged(e); case JFileChooser.DIRECTORY_CHANGED_PROPERTY:
} else if (s.equals(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY)) { doDirectoryChanged(e);
doFileSelectionModeChanged(e); break;
} else if (s.equals(JFileChooser.MULTI_SELECTION_ENABLED_CHANGED_PROPERTY)) { case JFileChooser.FILE_FILTER_CHANGED_PROPERTY:
doMultiSelectionChanged(e); doFilterChanged(e);
} else if (s.equals(JFileChooser.CANCEL_SELECTION)) { break;
applyEdit(); case JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY:
} else if (s.equals("busy")) { doFileSelectionModeChanged(e);
setCursor((Boolean) e.getNewValue() ? waitCursor : null); break;
} else if (s.equals(PropertyKey.COMPONENT_ORIENTATION)) { case JFileChooser.MULTI_SELECTION_ENABLED_CHANGED_PROPERTY:
ComponentOrientation o = (ComponentOrientation) e.getNewValue(); doMultiSelectionChanged(e);
JFileChooser cc = (JFileChooser) e.getSource(); break;
if (o != e.getOldValue()) { case JFileChooser.CANCEL_SELECTION:
cc.applyComponentOrientation(o); applyEdit();
} break;
if (detailsTable != null) { case "busy":
detailsTable.setComponentOrientation(o); setCursor((Boolean) e.getNewValue() ? waitCursor : null);
detailsTable.getParent().getParent().setComponentOrientation(o); break;
} case PropertyKey.COMPONENT_ORIENTATION:
ComponentOrientation o = (ComponentOrientation) e.getNewValue();
JFileChooser cc = (JFileChooser) e.getSource();
if (o != e.getOldValue()) {
cc.applyComponentOrientation(o);
}
if (detailsTable != null) {
detailsTable.setComponentOrientation(o);
detailsTable.getParent().getParent().setComponentOrientation(o);
}
break;
} }
} }
@ -1076,7 +1088,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
@SuppressWarnings("serial") @SuppressWarnings("serial")
// JDK-implementation class // JDK-implementation class
protected class ViewTypeAction extends AbstractAction { protected class ViewTypeAction extends AbstractAction {
protected int viewType; protected final int viewType;
ViewTypeAction(final int viewType) { ViewTypeAction(final int viewType) {
super(viewTypeActionNames[viewType]); super(viewTypeActionNames[viewType]);
@ -1106,7 +1118,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
*/ */
@SuppressWarnings("serial") // JDK-implementation class @SuppressWarnings("serial") // JDK-implementation class
protected class SortableListModel extends AbstractListModel<Object> protected class SortableListModel extends AbstractListModel<Object>
implements TableModelListener, RowSorterListener { implements TableModelListener, RowSorterListener {
public SortableListModel() { public SortableListModel() {
getDetailsTableModel().addTableModelListener(this); getDetailsTableModel().addTableModelListener(this);
@ -1132,10 +1144,10 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
} }
@SuppressWarnings("serial") @SuppressWarnings("serial")
// JDK-implementation class // JDK-implementation class
class DetailsTableModel extends AbstractTableModel implements ListDataListener { class DetailsTableModel extends AbstractTableModel implements ListDataListener {
JFileChooser chooser; final JFileChooser chooser;
BasicDirectoryModel directoryModel; final BasicDirectoryModel directoryModel;
ShellFolderColumnInfo[] columns; ShellFolderColumnInfo[] columns;
int[] columnMap; int[] columnMap;
@ -1242,7 +1254,8 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
final File f2 = fsv.createFileObject(f.getParentFile(), newFileName); final File f2 = fsv.createFileObject(f.getParentFile(), newFileName);
if (f2.exists()) { if (f2.exists()) {
JOptionPane.showMessageDialog(chooser, MessageFormat.format(renameErrorFileExistsText, JOptionPane.showMessageDialog(chooser, MessageFormat.format(renameErrorFileExistsText,
oldFileName), renameErrorTitleText, oldFileName),
renameErrorTitleText,
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
} else { } else {
if (DarkFilePaneUIBridge.this.getModel().renameFile(f, f2)) { if (DarkFilePaneUIBridge.this.getModel().renameFile(f, f2)) {
@ -1262,7 +1275,8 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
// chooser.setSelectedFile(null); // chooser.setSelectedFile(null);
} }
} else { } else {
JOptionPane.showMessageDialog(chooser, MessageFormat.format(renameErrorText, oldFileName), JOptionPane.showMessageDialog(chooser,
MessageFormat.format(renameErrorText, oldFileName),
renameErrorTitleText, JOptionPane.ERROR_MESSAGE); renameErrorTitleText, JOptionPane.ERROR_MESSAGE);
} }
} }
@ -1367,8 +1381,8 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
* comparator. * comparator.
*/ */
protected class DirectoriesFirstComparatorWrapper implements Comparator<File> { protected class DirectoriesFirstComparatorWrapper implements Comparator<File> {
protected Comparator<Object> comparator; protected final Comparator<Object> comparator;
protected int column; protected final int column;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public DirectoriesFirstComparatorWrapper(final int column, final Comparator<?> comparator) { public DirectoriesFirstComparatorWrapper(final int column, final Comparator<?> comparator) {
@ -1390,9 +1404,9 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
} }
if (detailsTableModel.getColumns()[column].isCompareByColumn()) { if (detailsTableModel.getColumns()[column].isCompareByColumn()) {
return comparator.compare( return comparator.compare(
getDetailsTableModel().getFileColumnValue(f1, column), getDetailsTableModel().getFileColumnValue(f1, column),
getDetailsTableModel().getFileColumnValue(f2, column) getDetailsTableModel().getFileColumnValue(f2, column)
); );
} }
// For this column we need to pass the file itself (not a // For this column we need to pass the file itself (not a
// column value) to the comparator // column value) to the comparator
@ -1427,8 +1441,8 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
@SuppressWarnings("serial") @SuppressWarnings("serial")
// JDK-implementation class // JDK-implementation class
public class DetailsTableCellRenderer extends DarkTableCellRenderer { public class DetailsTableCellRenderer extends DarkTableCellRenderer {
JFileChooser chooser; final JFileChooser chooser;
DateFormat df; final DateFormat df;
public DetailsTableCellRenderer(final JFileChooser chooser) { public DetailsTableCellRenderer(final JFileChooser chooser) {
this.chooser = chooser; this.chooser = chooser;
@ -1441,7 +1455,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
final int row, final int column) { final int row, final int column) {
if ((table.convertColumnIndexToModel(column) != COLUMN_FILENAME || if ((table.convertColumnIndexToModel(column) != COLUMN_FILENAME ||
(listViewWindowsStyle && !table.isFocusOwner())) && !fullRowSelection) { (listViewWindowsStyle && !table.isFocusOwner())) && !fullRowSelection) {
isSelected = false; isSelected = false;
} }
@ -1502,18 +1516,18 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
} }
protected class AlignableTableHeaderRenderer implements TableCellRenderer { protected class AlignableTableHeaderRenderer implements TableCellRenderer {
TableCellRenderer wrappedRenderer; final TableCellRenderer wrappedRenderer;
public AlignableTableHeaderRenderer(final TableCellRenderer wrappedRenderer) { public AlignableTableHeaderRenderer(final TableCellRenderer wrappedRenderer) {
this.wrappedRenderer = wrappedRenderer; this.wrappedRenderer = wrappedRenderer;
} }
public Component getTableCellRendererComponent( public Component getTableCellRendererComponent(
final JTable table, final Object value, final boolean isSelected, final JTable table, final Object value, final boolean isSelected,
final boolean hasFocus, final int row, final int column) { final boolean hasFocus, final int row, final int column) {
Component c = wrappedRenderer.getTableCellRendererComponent( Component c = wrappedRenderer.getTableCellRendererComponent(
table, value, isSelected, hasFocus, row, column); table, value, isSelected, hasFocus, row, column);
int modelColumn = table.convertColumnIndexToModel(column); int modelColumn = table.convertColumnIndexToModel(column);
ShellFolderColumnInfo columnInfo = detailsTableModel.getColumns()[modelColumn]; ShellFolderColumnInfo columnInfo = detailsTableModel.getColumns()[modelColumn];
@ -1548,7 +1562,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
setFileSelected(); setFileSelected();
if (editFile != null) { if (editFile != null) {
editFileName(getRowSorter().convertRowIndexToView( editFileName(getRowSorter().convertRowIndexToView(
getModel().indexOf(editFile))); getModel().indexOf(editFile)));
editFile = null; editFile = null;
} }
} }
@ -1606,8 +1620,8 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
index = table.rowAtPoint(p); index = table.rowAtPoint(p);
boolean pointOutsidePrefSize = boolean pointOutsidePrefSize =
SwingUtilities2.pointOutsidePrefSize( SwingUtilities2.pointOutsidePrefSize(
table, index, table.columnAtPoint(p), p); table, index, table.columnAtPoint(p), p);
if (pointOutsidePrefSize && !fullRowSelection) { if (pointOutsidePrefSize && !fullRowSelection) {
return; return;
@ -1615,7 +1629,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
// Translate point from table to list // Translate point from table to list
if (index >= 0 && list != null && if (index >= 0 && list != null &&
listSelectionModel.isSelectedIndex(index)) { listSelectionModel.isSelectedIndex(index)) {
// Make a new event with the list as source, placing the // Make a new event with the list as source, placing the
// click in the corresponding list cell. // click in the corresponding list cell.
@ -1642,8 +1656,8 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
// For single click, we handle editing file name // For single click, we handle editing file name
if (evt.getClickCount() == 1 && source instanceof JList) { if (evt.getClickCount() == 1 && source instanceof JList) {
if ((!fc.isMultiSelectionEnabled() || fc.getSelectedFiles().length <= 1) if ((!fc.isMultiSelectionEnabled() || fc.getSelectedFiles().length <= 1)
&& listSelectionModel.isSelectedIndex(index) && listSelectionModel.isSelectedIndex(index)
&& getEditIndex() == index && editFile == null) { && getEditIndex() == index && editFile == null) {
editFileName(index); editFileName(index);
} else { } else {
@ -1717,7 +1731,7 @@ public abstract class DarkFilePaneUIBridge extends JPanel implements PropertyCha
// Lazy creation of Basic's listener // Lazy creation of Basic's listener
if (doubleClickListener == null && list != null) { if (doubleClickListener == null && list != null) {
doubleClickListener = doubleClickListener =
fileChooserUIAccessor.createDoubleClickListener(list); fileChooserUIAccessor.createDoubleClickListener(list);
} }
return doubleClickListener; return doubleClickListener;
} }

2
core/src/main/java/com/github/weisj/darklaf/ui/html/DarkHTML.java

@ -67,7 +67,7 @@ public class DarkHTML extends BasicHTML {
rect = bounds.getBounds(); rect = bounds.getBounds();
} }
return rect.y + (int) (rect.height * return rect.y + (int) (rect.height *
child.getAlignment(View.Y_AXIS)); child.getAlignment(View.Y_AXIS));
} }
return getBaseline(child, bounds); return getBaseline(child, bounds);
} }

5
core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameTitlePane.java

@ -66,11 +66,6 @@ public class DarkInternalFrameTitlePane extends BasicInternalFrameTitlePane {
super(f); super(f);
} }
@Override
protected void installTitlePane() {
super.installTitlePane();
}
@Override @Override
protected void addSubComponents() { protected void addSubComponents() {
super.addSubComponents(); super.addSubComponents();

12
core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java

@ -47,8 +47,8 @@ public class DarkLabelUI extends BasicLabelUI implements PropertyChangeListener
private Color inactiveForeground; private Color inactiveForeground;
private Color cellForegroundNoFocus; private Color cellForegroundNoFocus;
protected Rectangle paintIconR = new Rectangle(); protected final Rectangle paintIconR = new Rectangle();
protected Rectangle paintTextR = new Rectangle(); protected final Rectangle paintTextR = new Rectangle();
public DarkLabelUI() { public DarkLabelUI() {
installUI(null); installUI(null);
@ -107,10 +107,10 @@ public class DarkLabelUI extends BasicLabelUI implements PropertyChangeListener
final int textX, final int textY) { final int textX, final int textY) {
int mnemIndex = l.getDisplayedMnemonicIndex(); int mnemIndex = l.getDisplayedMnemonicIndex();
boolean focus = DarkUIUtil.hasFocus(l) boolean focus = DarkUIUtil.hasFocus(l)
|| DarkUIUtil.hasFocus(DarkUIUtil.getParentOfType(JTree.class, l)) || DarkUIUtil.hasFocus(DarkUIUtil.getParentOfType(JTree.class, l))
|| DarkUIUtil.hasFocus(DarkUIUtil.getParentOfType(JTable.class, l)) || DarkUIUtil.hasFocus(DarkUIUtil.getParentOfType(JTable.class, l))
|| DarkUIUtil.hasFocus(DarkUIUtil.getParentOfType(JList.class, l)) || DarkUIUtil.hasFocus(DarkUIUtil.getParentOfType(JList.class, l))
|| DarkUIUtil.getParentOfType(JPopupMenu.class, l) != null; || DarkUIUtil.getParentOfType(JPopupMenu.class, l) != null;
if (DarkUIUtil.isInCell(l) && !focus) { if (DarkUIUtil.isInCell(l) && !focus) {
g.setColor(cellForegroundNoFocus); g.setColor(cellForegroundNoFocus);
} else { } else {

2
core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellFocusBorder.java

@ -31,7 +31,7 @@ import java.awt.*;
public class DarkListCellFocusBorder extends DarkCellBorder { public class DarkListCellFocusBorder extends DarkCellBorder {
protected Color borderColor; protected final Color borderColor;
public DarkListCellFocusBorder() { public DarkListCellFocusBorder() {
borderColor = UIManager.getColor("List.focusBorderColor"); borderColor = UIManager.getColor("List.focusBorderColor");

234
core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java

@ -62,7 +62,7 @@ public class DarkListUIBridge extends BasicListUI {
* The constant BASELINE_COMPONENT_KEY. * The constant BASELINE_COMPONENT_KEY.
*/ */
protected static final StringBuilder BASELINE_COMPONENT_KEY = protected static final StringBuilder BASELINE_COMPONENT_KEY =
new StringBuilder("List.baselineComponent"); new StringBuilder("List.baselineComponent");
/** /**
* The bit relates to model changed property. * The bit relates to model changed property.
*/ */
@ -295,20 +295,19 @@ public class DarkListUIBridge extends BasicListUI {
* @param leadIndex a lead index * @param leadIndex a lead index
* @see #paint * @see #paint
*/ */
protected void paintCell( protected void paintCell(final Graphics g,
final Graphics g, final int row,
final int row, final Rectangle rowBounds,
final Rectangle rowBounds, final ListCellRenderer cellRenderer,
final ListCellRenderer cellRenderer, final ListModel dataModel,
final ListModel dataModel, final ListSelectionModel selModel,
final ListSelectionModel selModel, final int leadIndex) {
final int leadIndex) {
Object value = dataModel.getElementAt(row); Object value = dataModel.getElementAt(row);
boolean cellHasFocus = list.hasFocus() && (row == leadIndex); boolean cellHasFocus = list.hasFocus() && (row == leadIndex);
boolean isSelected = selModel.isSelectedIndex(row); boolean isSelected = selModel.isSelectedIndex(row);
Component rendererComponent = Component rendererComponent =
cellRenderer.getListCellRendererComponent(list, value, row, isSelected, cellHasFocus); cellRenderer.getListCellRendererComponent(list, value, row, isSelected, cellHasFocus);
int cx = rowBounds.x; int cx = rowBounds.x;
int cy = rowBounds.y; int cy = rowBounds.y;
@ -356,11 +355,10 @@ public class DarkListUIBridge extends BasicListUI {
int rowHeight = list.getFixedCellHeight(); int rowHeight = list.getFixedCellHeight();
UIDefaults lafDefaults = UIManager.getLookAndFeelDefaults(); UIDefaults lafDefaults = UIManager.getLookAndFeelDefaults();
Component renderer = (Component) lafDefaults.get( Component renderer = (Component) lafDefaults.get(
BASELINE_COMPONENT_KEY); BASELINE_COMPONENT_KEY);
if (renderer == null) { if (renderer == null) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
ListCellRenderer<Object> lcr = (ListCellRenderer) UIManager.get( ListCellRenderer<Object> lcr = (ListCellRenderer<Object>) UIManager.get("List.cellRenderer");
"List.cellRenderer");
// fix for 6711072 some LAFs like Nimbus do not provide this // fix for 6711072 some LAFs like Nimbus do not provide this
// UIManager key and we should not through a NPE here because of it // UIManager key and we should not through a NPE here because of it
@ -368,7 +366,7 @@ public class DarkListUIBridge extends BasicListUI {
lcr = new DefaultListCellRenderer(); lcr = new DefaultListCellRenderer();
} }
renderer = lcr.getListCellRendererComponent( renderer = lcr.getListCellRendererComponent(
list, "a", -1, false, false); list, "a", -1, false, false);
lafDefaults.put(BASELINE_COMPONENT_KEY, renderer); lafDefaults.put(BASELINE_COMPONENT_KEY, renderer);
} }
renderer.setFont(list.getFont()); renderer.setFont(list.getFont());
@ -383,7 +381,7 @@ public class DarkListUIBridge extends BasicListUI {
rowHeight = renderer.getPreferredSize().height; rowHeight = renderer.getPreferredSize().height;
} }
return renderer.getBaseline(Integer.MAX_VALUE, rowHeight) + return renderer.getBaseline(Integer.MAX_VALUE, rowHeight) +
list.getInsets().top; list.getInsets().top;
} }
/** /**
@ -394,7 +392,7 @@ public class DarkListUIBridge extends BasicListUI {
* @since 1.6 * @since 1.6
*/ */
public Component.BaselineResizeBehavior getBaselineResizeBehavior( public Component.BaselineResizeBehavior getBaselineResizeBehavior(
final JComponent c) { final JComponent c) {
super.getBaselineResizeBehavior(c); super.getBaselineResizeBehavior(c);
return Component.BaselineResizeBehavior.CONSTANT_ASCENT; return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
} }
@ -652,7 +650,7 @@ public class DarkListUIBridge extends BasicListUI {
if (list.getCellRenderer() == null) { if (list.getCellRenderer() == null) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
ListCellRenderer<Object> tmp = (ListCellRenderer) (UIManager.get("List.cellRenderer")); ListCellRenderer<Object> tmp = (ListCellRenderer<Object>) (UIManager.get("List.cellRenderer"));
list.setCellRenderer(tmp); list.setCellRenderer(tmp);
} }
@ -716,7 +714,7 @@ public class DarkListUIBridge extends BasicListUI {
*/ */
public void installUI(final JComponent c) { public void installUI(final JComponent c) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
JList<Object> tmp = (JList) c; JList<Object> tmp = (JList<Object>) c;
list = tmp; list = tmp;
layoutOrientation = list.getLayoutOrientation(); layoutOrientation = list.getLayoutOrientation();
@ -755,12 +753,12 @@ public class DarkListUIBridge extends BasicListUI {
InputMap getInputMap(final int condition) { InputMap getInputMap(final int condition) {
if (condition == JComponent.WHEN_FOCUSED) { if (condition == JComponent.WHEN_FOCUSED) {
InputMap keyMap = (InputMap) DefaultLookup.get( InputMap keyMap = (InputMap) DefaultLookup.get(
list, this, "List.focusInputMap"); list, this, "List.focusInputMap");
InputMap rtlKeyMap; InputMap rtlKeyMap;
if (isLeftToRight || if (isLeftToRight ||
((rtlKeyMap = (InputMap) DefaultLookup.get(list, this, ((rtlKeyMap = (InputMap) DefaultLookup.get(list, this,
"List.focusInputMap.RightToLeft")) == null)) { "List.focusInputMap.RightToLeft")) == null)) {
return keyMap; return keyMap;
} else { } else {
rtlKeyMap.setParent(keyMap); rtlKeyMap.setParent(keyMap);
@ -1204,10 +1202,10 @@ public class DarkListUIBridge extends BasicListUI {
switch (layoutOrientation) { switch (layoutOrientation) {
case JList.VERTICAL_WRAP: case JList.VERTICAL_WRAP:
return Math.min(list.getModel().getSize() - 1, rowsPerColumn * return Math.min(list.getModel().getSize() - 1, rowsPerColumn *
column + Math.min(row, rowsPerColumn - 1)); column + Math.min(row, rowsPerColumn - 1));
case JList.HORIZONTAL_WRAP: case JList.HORIZONTAL_WRAP:
return Math.min(list.getModel().getSize() - 1, row * columnCount + return Math.min(list.getModel().getSize() - 1, row * columnCount +
column); column);
default: default:
return row; return row;
} }
@ -1262,7 +1260,7 @@ public class DarkListUIBridge extends BasicListUI {
rowsPerColumn = visRows; rowsPerColumn = visRows;
columnCount = Math.max(1, dataModelSize / rowsPerColumn); columnCount = Math.max(1, dataModelSize / rowsPerColumn);
if (dataModelSize > 0 && dataModelSize > rowsPerColumn && if (dataModelSize > 0 && dataModelSize > rowsPerColumn &&
dataModelSize % rowsPerColumn != 0) { dataModelSize % rowsPerColumn != 0) {
columnCount++; columnCount++;
} }
if (layoutOrientation == JList.HORIZONTAL_WRAP) { if (layoutOrientation == JList.HORIZONTAL_WRAP) {
@ -1275,23 +1273,23 @@ public class DarkListUIBridge extends BasicListUI {
} }
} else if (layoutOrientation == JList.VERTICAL_WRAP && height != 0) { } else if (layoutOrientation == JList.VERTICAL_WRAP && height != 0) {
rowsPerColumn = Math.max(1, (listHeight - insets.top - rowsPerColumn = Math.max(1, (listHeight - insets.top -
insets.bottom) / height); insets.bottom) / height);
columnCount = Math.max(1, dataModelSize / rowsPerColumn); columnCount = Math.max(1, dataModelSize / rowsPerColumn);
if (dataModelSize > 0 && dataModelSize > rowsPerColumn && if (dataModelSize > 0 && dataModelSize > rowsPerColumn &&
dataModelSize % rowsPerColumn != 0) { dataModelSize % rowsPerColumn != 0) {
columnCount++; columnCount++;
} }
} else if (layoutOrientation == JList.HORIZONTAL_WRAP && cellWidth > 0 && } else if (layoutOrientation == JList.HORIZONTAL_WRAP && cellWidth > 0 &&
listWidth > 0) { listWidth > 0) {
columnCount = Math.max(1, (listWidth - insets.left - columnCount = Math.max(1, (listWidth - insets.left -
insets.right) / cellWidth); insets.right) / cellWidth);
rowsPerColumn = dataModelSize / columnCount; rowsPerColumn = dataModelSize / columnCount;
if (dataModelSize % columnCount > 0) { if (dataModelSize % columnCount > 0) {
rowsPerColumn++; rowsPerColumn++;
} }
} }
preferredHeight = rowsPerColumn * cellHeight + insets.top + preferredHeight = rowsPerColumn * cellHeight + insets.top +
insets.bottom; insets.bottom;
} }
/** /**
@ -1336,11 +1334,11 @@ public class DarkListUIBridge extends BasicListUI {
startColumn = convertLocationToColumn(paintBounds.x, startColumn = convertLocationToColumn(paintBounds.x,
paintBounds.y); paintBounds.y);
endColumn = convertLocationToColumn(paintBounds.x + endColumn = convertLocationToColumn(paintBounds.x +
paintBounds.width, paintBounds.width,
paintBounds.y); paintBounds.y);
} else { } else {
startColumn = convertLocationToColumn(paintBounds.x + startColumn = convertLocationToColumn(paintBounds.x +
paintBounds.width, paintBounds.width,
paintBounds.y); paintBounds.y);
endColumn = convertLocationToColumn(paintBounds.x, endColumn = convertLocationToColumn(paintBounds.x,
paintBounds.y); paintBounds.y);
@ -1364,7 +1362,7 @@ public class DarkListUIBridge extends BasicListUI {
return; return;
} }
while (row < rowCount && rowBounds.y < maxY && while (row < rowCount && rowBounds.y < maxY &&
index < size) { index < size) {
rowBounds.height = getHeight(colCounter, row); rowBounds.height = getHeight(colCounter, row);
g.setClip(rowBounds.x, rowBounds.y, rowBounds.width, g.setClip(rowBounds.x, rowBounds.y, rowBounds.width,
rowBounds.height); rowBounds.height);
@ -1431,22 +1429,19 @@ public class DarkListUIBridge extends BasicListUI {
return -1; return -1;
} }
if (layoutOrientation == JList.VERTICAL || if (layoutOrientation == JList.VERTICAL ||
(column == 0 && columnCount == 1)) { (column == 0 && columnCount == 1)) {
return list.getModel().getSize(); return list.getModel().getSize();
} }
if (column >= columnCount) {
return -1;
}
if (layoutOrientation == JList.VERTICAL_WRAP) { if (layoutOrientation == JList.VERTICAL_WRAP) {
if (column < (columnCount - 1)) { if (column < (columnCount - 1)) {
return rowsPerColumn; return rowsPerColumn;
} }
return list.getModel().getSize() - (columnCount - 1) * return list.getModel().getSize() - (columnCount - 1) *
rowsPerColumn; rowsPerColumn;
} }
// JList.HORIZONTAL_WRAP // JList.HORIZONTAL_WRAP
int diff = columnCount - (columnCount * rowsPerColumn - int diff = columnCount - (columnCount * rowsPerColumn -
list.getModel().getSize()); list.getModel().getSize());
if (column >= diff) { if (column >= diff) {
return Math.max(0, rowsPerColumn - 1); return Math.max(0, rowsPerColumn - 1);
@ -1527,7 +1522,7 @@ public class DarkListUIBridge extends BasicListUI {
if (index == size) { if (index == size) {
decr = true; decr = true;
} else if (index != 0 && convertModelToRow(index) } else if (index != 0 && convertModelToRow(index)
!= convertModelToRow(index - 1)) { != convertModelToRow(index - 1)) {
Rectangle prev = getCellBounds(list, index - 1); Rectangle prev = getCellBounds(list, index - 1);
Rectangle me = getCellBounds(list, index); Rectangle me = getCellBounds(list, index);
@ -1537,16 +1532,16 @@ public class DarkListUIBridge extends BasicListUI {
decr = Point2D.distance(prev.x + prev.width, decr = Point2D.distance(prev.x + prev.width,
prev.y + (int) (prev.height / 2.0), prev.y + (int) (prev.height / 2.0),
p.x, p.y) p.x, p.y)
< Point2D.distance(me.x, < Point2D.distance(me.x,
me.y + (int) (me.height / 2.0), me.y + (int) (me.height / 2.0),
p.x, p.y); p.x, p.y);
} else { } else {
decr = Point2D.distance(prev.x, decr = Point2D.distance(prev.x,
prev.y + (int) (prev.height / 2.0), prev.y + (int) (prev.height / 2.0),
p.x, p.y) p.x, p.y)
< Point2D.distance(me.x + me.width, < Point2D.distance(me.x + me.width,
me.y + (int) (prev.height / 2.0), me.y + (int) (prev.height / 2.0),
p.x, p.y); p.x, p.y);
} }
} }
@ -1578,7 +1573,7 @@ public class DarkListUIBridge extends BasicListUI {
rect = getCellBounds(list, index); rect = getCellBounds(list, index);
rect.y += rect.height; rect.y += rect.height;
} else if (index != 0 && convertModelToColumn(index) } else if (index != 0 && convertModelToColumn(index)
!= convertModelToColumn(index - 1)) { != convertModelToColumn(index - 1)) {
Rectangle prev = getCellBounds(list, index - 1); Rectangle prev = getCellBounds(list, index - 1);
Rectangle me = getCellBounds(list, index); Rectangle me = getCellBounds(list, index);
@ -1586,9 +1581,9 @@ public class DarkListUIBridge extends BasicListUI {
if (Point2D.distance(prev.x + (int) (prev.width / 2.0), if (Point2D.distance(prev.x + (int) (prev.width / 2.0),
prev.y + prev.height, prev.y + prev.height,
p.x, p.y) p.x, p.y)
< Point2D.distance(me.x + (int) (me.width / 2.0), < Point2D.distance(me.x + (int) (me.width / 2.0),
me.y, me.y,
p.x, p.y)) { p.x, p.y)) {
index--; index--;
rect = getCellBounds(list, index); rect = getCellBounds(list, index);
@ -1638,7 +1633,7 @@ public class DarkListUIBridge extends BasicListUI {
} }
if (layoutOrientation != JList.VERTICAL && columnCount > 1 && if (layoutOrientation != JList.VERTICAL && columnCount > 1 &&
rowsPerColumn > 0) { rowsPerColumn > 0) {
if (layoutOrientation == JList.VERTICAL_WRAP) { if (layoutOrientation == JList.VERTICAL_WRAP) {
return index % rowsPerColumn; return index % rowsPerColumn;
} }
@ -1713,7 +1708,7 @@ public class DarkListUIBridge extends BasicListUI {
} }
if (layoutOrientation != JList.VERTICAL && rowsPerColumn > 0 && if (layoutOrientation != JList.VERTICAL && rowsPerColumn > 0 &&
columnCount > 1) { columnCount > 1) {
if (layoutOrientation == JList.VERTICAL_WRAP) { if (layoutOrientation == JList.VERTICAL_WRAP) {
return index / rowsPerColumn; return index / rowsPerColumn;
} }
@ -1742,7 +1737,7 @@ public class DarkListUIBridge extends BasicListUI {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
protected Transferable createTransferable(final JComponent c) { protected Transferable createTransferable(final JComponent c) {
if (c instanceof JList) { if (c instanceof JList) {
JList<?> list = (JList) c; JList<?> list = (JList<Object>) c;
Object[] values = list.getSelectedValues(); Object[] values = list.getSelectedValues();
if (values == null || values.length == 0) { if (values == null || values.length == 0) {
@ -1754,8 +1749,7 @@ public class DarkListUIBridge extends BasicListUI {
htmlStr.append("<html>\n<body>\n<ul>\n"); htmlStr.append("<html>\n<body>\n<ul>\n");
for (int i = 0; i < values.length; i++) { for (Object obj : values) {
Object obj = values[i];
String val = ((obj == null) ? "" : obj.toString()); String val = ((obj == null) ? "" : obj.toString());
plainStr.append(val).append('\n'); plainStr.append(val).append('\n');
htmlStr.append(" <li>").append(val).append('\n'); htmlStr.append(" <li>").append(val).append('\n');
@ -1775,46 +1769,46 @@ public class DarkListUIBridge extends BasicListUI {
private static class Actions extends UIAction { private static class Actions extends UIAction {
private static final String SELECT_PREVIOUS_COLUMN = private static final String SELECT_PREVIOUS_COLUMN =
"selectPreviousColumn"; "selectPreviousColumn";
private static final String SELECT_PREVIOUS_COLUMN_EXTEND = private static final String SELECT_PREVIOUS_COLUMN_EXTEND =
"selectPreviousColumnExtendSelection"; "selectPreviousColumnExtendSelection";
private static final String SELECT_PREVIOUS_COLUMN_CHANGE_LEAD = private static final String SELECT_PREVIOUS_COLUMN_CHANGE_LEAD =
"selectPreviousColumnChangeLead"; "selectPreviousColumnChangeLead";
private static final String SELECT_NEXT_COLUMN = "selectNextColumn"; private static final String SELECT_NEXT_COLUMN = "selectNextColumn";
private static final String SELECT_NEXT_COLUMN_EXTEND = private static final String SELECT_NEXT_COLUMN_EXTEND =
"selectNextColumnExtendSelection"; "selectNextColumnExtendSelection";
private static final String SELECT_NEXT_COLUMN_CHANGE_LEAD = private static final String SELECT_NEXT_COLUMN_CHANGE_LEAD =
"selectNextColumnChangeLead"; "selectNextColumnChangeLead";
private static final String SELECT_PREVIOUS_ROW = "selectPreviousRow"; private static final String SELECT_PREVIOUS_ROW = "selectPreviousRow";
private static final String SELECT_PREVIOUS_ROW_EXTEND = private static final String SELECT_PREVIOUS_ROW_EXTEND =
"selectPreviousRowExtendSelection"; "selectPreviousRowExtendSelection";
private static final String SELECT_PREVIOUS_ROW_CHANGE_LEAD = private static final String SELECT_PREVIOUS_ROW_CHANGE_LEAD =
"selectPreviousRowChangeLead"; "selectPreviousRowChangeLead";
private static final String SELECT_NEXT_ROW = "selectNextRow"; private static final String SELECT_NEXT_ROW = "selectNextRow";
private static final String SELECT_NEXT_ROW_EXTEND = private static final String SELECT_NEXT_ROW_EXTEND =
"selectNextRowExtendSelection"; "selectNextRowExtendSelection";
private static final String SELECT_NEXT_ROW_CHANGE_LEAD = private static final String SELECT_NEXT_ROW_CHANGE_LEAD =
"selectNextRowChangeLead"; "selectNextRowChangeLead";
private static final String SELECT_FIRST_ROW = "selectFirstRow"; private static final String SELECT_FIRST_ROW = "selectFirstRow";
private static final String SELECT_FIRST_ROW_EXTEND = private static final String SELECT_FIRST_ROW_EXTEND =
"selectFirstRowExtendSelection"; "selectFirstRowExtendSelection";
private static final String SELECT_FIRST_ROW_CHANGE_LEAD = private static final String SELECT_FIRST_ROW_CHANGE_LEAD =
"selectFirstRowChangeLead"; "selectFirstRowChangeLead";
private static final String SELECT_LAST_ROW = "selectLastRow"; private static final String SELECT_LAST_ROW = "selectLastRow";
private static final String SELECT_LAST_ROW_EXTEND = private static final String SELECT_LAST_ROW_EXTEND =
"selectLastRowExtendSelection"; "selectLastRowExtendSelection";
private static final String SELECT_LAST_ROW_CHANGE_LEAD = private static final String SELECT_LAST_ROW_CHANGE_LEAD =
"selectLastRowChangeLead"; "selectLastRowChangeLead";
private static final String SCROLL_UP = "scrollUp"; private static final String SCROLL_UP = "scrollUp";
private static final String SCROLL_UP_EXTEND = private static final String SCROLL_UP_EXTEND =
"scrollUpExtendSelection"; "scrollUpExtendSelection";
private static final String SCROLL_UP_CHANGE_LEAD = private static final String SCROLL_UP_CHANGE_LEAD =
"scrollUpChangeLead"; "scrollUpChangeLead";
private static final String SCROLL_DOWN = "scrollDown"; private static final String SCROLL_DOWN = "scrollDown";
private static final String SCROLL_DOWN_EXTEND = private static final String SCROLL_DOWN_EXTEND =
"scrollDownExtendSelection"; "scrollDownExtendSelection";
private static final String SCROLL_DOWN_CHANGE_LEAD = private static final String SCROLL_DOWN_CHANGE_LEAD =
"scrollDownChangeLead"; "scrollDownChangeLead";
private static final String SELECT_ALL = "selectAll"; private static final String SELECT_ALL = "selectAll";
private static final String CLEAR_SELECTION = "clearSelection"; private static final String CLEAR_SELECTION = "clearSelection";
@ -1920,7 +1914,7 @@ public class DarkListUIBridge extends BasicListUI {
clearSelection(list); clearSelection(list);
} else if (Objects.equals(name, ADD_TO_SELECTION)) { } else if (Objects.equals(name, ADD_TO_SELECTION)) {
int index = adjustIndex( int index = adjustIndex(
list.getSelectionModel().getLeadSelectionIndex(), list); list.getSelectionModel().getLeadSelectionIndex(), list);
if (!list.isSelectedIndex(index)) { if (!list.isSelectedIndex(index)) {
int oldAnchor = list.getSelectionModel().getAnchorSelectionIndex(); int oldAnchor = list.getSelectionModel().getAnchorSelectionIndex();
@ -1931,7 +1925,7 @@ public class DarkListUIBridge extends BasicListUI {
} }
} else if (Objects.equals(name, TOGGLE_AND_ANCHOR)) { } else if (Objects.equals(name, TOGGLE_AND_ANCHOR)) {
int index = adjustIndex( int index = adjustIndex(
list.getSelectionModel().getLeadSelectionIndex(), list); list.getSelectionModel().getLeadSelectionIndex(), list);
if (list.isSelectedIndex(index)) { if (list.isSelectedIndex(index)) {
list.removeSelectionInterval(index, index); list.removeSelectionInterval(index, index);
@ -1940,14 +1934,14 @@ public class DarkListUIBridge extends BasicListUI {
} }
} else if (Objects.equals(name, EXTEND_TO)) { } else if (Objects.equals(name, EXTEND_TO)) {
changeSelection( changeSelection(
list, EXTEND_SELECTION, list, EXTEND_SELECTION,
adjustIndex(list.getSelectionModel().getLeadSelectionIndex(), list), adjustIndex(list.getSelectionModel().getLeadSelectionIndex(), list),
0); 0);
} else if (Objects.equals(name, MOVE_SELECTION_TO)) { } else if (Objects.equals(name, MOVE_SELECTION_TO)) {
changeSelection( changeSelection(
list, CHANGE_SELECTION, list, CHANGE_SELECTION,
adjustIndex(list.getSelectionModel().getLeadSelectionIndex(), list), adjustIndex(list.getSelectionModel().getLeadSelectionIndex(), list),
0); 0);
} }
} }
@ -1958,8 +1952,8 @@ public class DarkListUIBridge extends BasicListUI {
// CHANGE_LEAD is only valid with multiple interval selection // CHANGE_LEAD is only valid with multiple interval selection
if (type == CHANGE_LEAD && if (type == CHANGE_LEAD &&
list.getSelectionMode() list.getSelectionMode()
!= ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) {
type = CHANGE_SELECTION; type = CHANGE_SELECTION;
} }
@ -2056,13 +2050,13 @@ public class DarkListUIBridge extends BasicListUI {
ListSelectionModel lsm = list.getSelectionModel(); ListSelectionModel lsm = list.getSelectionModel();
int lead = adjustIndex(lsm.getLeadSelectionIndex(), list); int lead = adjustIndex(lsm.getLeadSelectionIndex(), list);
Rectangle leadRect = Rectangle leadRect =
(lead == -1) ? new Rectangle() : list.getCellBounds(lead, lead); (lead == -1) ? new Rectangle() : list.getCellBounds(lead, lead);
if (leadRect == null) { if (leadRect == null) {
return index; return index;
} }
if (list.getLayoutOrientation() == JList.VERTICAL_WRAP && if (list.getLayoutOrientation() == JList.VERTICAL_WRAP &&
list.getVisibleRowCount() <= 0) { list.getVisibleRowCount() <= 0) {
if (!list.getComponentOrientation().isLeftToRight()) { if (!list.getComponentOrientation().isLeftToRight()) {
direction = -direction; direction = -direction;
} }
@ -2158,8 +2152,8 @@ public class DarkListUIBridge extends BasicListUI {
// go up one cell if last visible cell doesn't fit // go up one cell if last visible cell doesn't fit
// into visible rectangle // into visible rectangle
if (cellBounds != null && if (cellBounds != null &&
cellBounds.y + cellBounds.height > cellBounds.y + cellBounds.height >
visRect.y + visRect.height) { visRect.y + visRect.height) {
p.y = cellBounds.y - 1; p.y = cellBounds.y - 1;
index = list.locationToIndex(p); index = list.locationToIndex(p);
if (index == -1) { if (index == -1) {
@ -2182,8 +2176,8 @@ public class DarkListUIBridge extends BasicListUI {
// go one cell up if last visible cell doesn't fit // go one cell up if last visible cell doesn't fit
// into adjasted visible rectangle // into adjasted visible rectangle
if (cellBounds != null && if (cellBounds != null &&
cellBounds.y + cellBounds.height > cellBounds.y + cellBounds.height >
visRect.y + visRect.height) { visRect.y + visRect.height) {
p.y = cellBounds.y - 1; p.y = cellBounds.y - 1;
index = list.locationToIndex(p); index = list.locationToIndex(p);
if (index == -1) { if (index == -1) {
@ -2250,7 +2244,7 @@ public class DarkListUIBridge extends BasicListUI {
Rectangle visRect = list.getVisibleRect(); Rectangle visRect = list.getVisibleRect();
if (cellBounds != null && !visRect.contains(cellBounds)) { if (cellBounds != null && !visRect.contains(cellBounds)) {
if (list.getLayoutOrientation() == JList.VERTICAL_WRAP && if (list.getLayoutOrientation() == JList.VERTICAL_WRAP &&
list.getVisibleRowCount() <= 0) { list.getVisibleRowCount() <= 0) {
// horizontal // horizontal
if (list.getComponentOrientation().isLeftToRight()) { if (list.getComponentOrientation().isLeftToRight()) {
if (direction > 0) { if (direction > 0) {
@ -2258,17 +2252,17 @@ public class DarkListUIBridge extends BasicListUI {
int x = Math.max(0, int x = Math.max(0,
cellBounds.x + cellBounds.width - visRect.width); cellBounds.x + cellBounds.width - visRect.width);
int startIndex = int startIndex =
list.locationToIndex(new Point(x, cellBounds.y)); list.locationToIndex(new Point(x, cellBounds.y));
if (startIndex == -1) { if (startIndex == -1) {
return; return;
} }
Rectangle startRect = list.getCellBounds(startIndex, Rectangle startRect = list.getCellBounds(startIndex,
startIndex); startIndex);
if (startRect != null && if (startRect != null &&
startRect.x < x && startRect.x < cellBounds.x) { startRect.x < x && startRect.x < cellBounds.x) {
startRect.x += startRect.width; startRect.x += startRect.width;
startIndex = startIndex =
list.locationToIndex(startRect.getLocation()); list.locationToIndex(startRect.getLocation());
if (startIndex == -1) { if (startIndex == -1) {
return; return;
} }
@ -2285,7 +2279,7 @@ public class DarkListUIBridge extends BasicListUI {
// left for right-to-left // left for right-to-left
int x = cellBounds.x + visRect.width; int x = cellBounds.x + visRect.width;
int rightIndex = int rightIndex =
list.locationToIndex(new Point(x, cellBounds.y)); list.locationToIndex(new Point(x, cellBounds.y));
if (rightIndex == -1) { if (rightIndex == -1) {
return; return;
} }
@ -2293,7 +2287,7 @@ public class DarkListUIBridge extends BasicListUI {
rightIndex); rightIndex);
if (rightRect != null) { if (rightRect != null) {
if (rightRect.x + rightRect.width > x && if (rightRect.x + rightRect.width > x &&
rightRect.x > cellBounds.x) { rightRect.x > cellBounds.x) {
rightRect.width = 0; rightRect.width = 0;
} }
cellBounds.x = Math.max(0, cellBounds.x = Math.max(0,
@ -2311,29 +2305,29 @@ public class DarkListUIBridge extends BasicListUI {
} else { } else {
// vertical // vertical
if (direction > 0 && if (direction > 0 &&
(cellBounds.y < visRect.y || (cellBounds.y < visRect.y ||
cellBounds.y + cellBounds.height cellBounds.y + cellBounds.height
> visRect.y + visRect.height)) { > visRect.y + visRect.height)) {
//down //down
int y = Math.max(0, int y = Math.max(0,
cellBounds.y + cellBounds.height - visRect.height); cellBounds.y + cellBounds.height - visRect.height);
int startIndex = int startIndex =
list.locationToIndex(new Point(cellBounds.x, y)); list.locationToIndex(new Point(cellBounds.x, y));
if (startIndex == -1) { if (startIndex == -1) {
return; return;
} }
Rectangle startRect = list.getCellBounds(startIndex, Rectangle startRect = list.getCellBounds(startIndex,
startIndex); startIndex);
if (startRect != null && if (startRect != null &&
startRect.y < y && startRect.y < cellBounds.y) { startRect.y < y && startRect.y < cellBounds.y) {
startRect.y += startRect.height; startRect.y += startRect.height;
startIndex = startIndex =
list.locationToIndex(startRect.getLocation()); list.locationToIndex(startRect.getLocation());
if (startIndex == -1) { if (startIndex == -1) {
return; return;
} }
startRect = startRect =
list.getCellBounds(startIndex, startIndex); list.getCellBounds(startIndex, startIndex);
} }
cellBounds = startRect; cellBounds = startRect;
if (cellBounds != null) { if (cellBounds != null) {
@ -2359,18 +2353,18 @@ public class DarkListUIBridge extends BasicListUI {
public boolean accept(final Object c) { public boolean accept(final Object c) {
Object name = getName(); Object name = getName();
if (name == SELECT_PREVIOUS_COLUMN_CHANGE_LEAD || if (name == SELECT_PREVIOUS_COLUMN_CHANGE_LEAD ||
name == SELECT_NEXT_COLUMN_CHANGE_LEAD || name == SELECT_NEXT_COLUMN_CHANGE_LEAD ||
name == SELECT_PREVIOUS_ROW_CHANGE_LEAD || name == SELECT_PREVIOUS_ROW_CHANGE_LEAD ||
name == SELECT_NEXT_ROW_CHANGE_LEAD || name == SELECT_NEXT_ROW_CHANGE_LEAD ||
name == SELECT_FIRST_ROW_CHANGE_LEAD || name == SELECT_FIRST_ROW_CHANGE_LEAD ||
name == SELECT_LAST_ROW_CHANGE_LEAD || name == SELECT_LAST_ROW_CHANGE_LEAD ||
name == SCROLL_UP_CHANGE_LEAD || name == SCROLL_UP_CHANGE_LEAD ||
name == SCROLL_DOWN_CHANGE_LEAD) { name == SCROLL_DOWN_CHANGE_LEAD) {
// discontinuous selection actions are only enabled for // discontinuous selection actions are only enabled for
// DefaultListSelectionModel // DefaultListSelectionModel
return c != null && ((JList) c).getSelectionModel() return c != null && ((JList<Object>) c).getSelectionModel()
instanceof DefaultListSelectionModel; instanceof DefaultListSelectionModel;
} }
return true; return true;
@ -2526,9 +2520,9 @@ public class DarkListUIBridge extends BasicListUI {
* The type Handler. * The type Handler.
*/ */
protected class Handler implements FocusListener, KeyListener, protected class Handler implements FocusListener, KeyListener,
ListDataListener, ListSelectionListener, ListDataListener, ListSelectionListener,
MouseInputListener, PropertyChangeListener, MouseInputListener, PropertyChangeListener,
DragRecognitionSupport.BeforeDrag { DragRecognitionSupport.BeforeDrag {
/** /**
* The Prefix. * The Prefix.
*/ */
@ -2562,12 +2556,12 @@ public class DarkListUIBridge extends BasicListUI {
* letters followed by first typed another letter. * letters followed by first typed another letter.
*/ */
public void keyTyped(final KeyEvent e) { public void keyTyped(final KeyEvent e) {
JList<?> src = (JList) e.getSource(); JList<?> src = (JList<?>) e.getSource();
ListModel<?> model = src.getModel(); ListModel<?> model = src.getModel();
if (model.getSize() == 0 || e.isAltDown() || if (model.getSize() == 0 || e.isAltDown() ||
DarkUIUtil.isMenuShortcutKeyDown(e) || DarkUIUtil.isMenuShortcutKeyDown(e) ||
isNavigationKey(e)) { isNavigationKey(e)) {
// Nothing to select // Nothing to select
return; return;
} }
@ -2657,8 +2651,8 @@ public class DarkListUIBridge extends BasicListUI {
* listDataListener from the old model and add it to the new one. * listDataListener from the old model and add it to the new one.
*/ */
if (Objects.equals(propertyName, "model")) { if (Objects.equals(propertyName, "model")) {
ListModel<?> oldModel = (ListModel) e.getOldValue(); ListModel<?> oldModel = (ListModel<?>) e.getOldValue();
ListModel<?> newModel = (ListModel) e.getNewValue(); ListModel<?> newModel = (ListModel<?>) e.getNewValue();
if (oldModel != null) { if (oldModel != null) {
oldModel.removeListDataListener(listDataListener); oldModel.removeListDataListener(listDataListener);
} }
@ -2687,7 +2681,7 @@ public class DarkListUIBridge extends BasicListUI {
updateLayoutStateNeeded |= cellRendererChanged; updateLayoutStateNeeded |= cellRendererChanged;
redrawList(); redrawList();
} else if (Objects.equals(propertyName, PropertyKey.FONT) } else if (Objects.equals(propertyName, PropertyKey.FONT)
|| DarkSwingUtil.isScaleChanged(e)) { || DarkSwingUtil.isScaleChanged(e)) {
updateLayoutStateNeeded |= fontChanged; updateLayoutStateNeeded |= fontChanged;
redrawList(); redrawList();
} else if (Objects.equals(propertyName, "prototypeCellValue")) { } else if (Objects.equals(propertyName, "prototypeCellValue")) {
@ -2880,8 +2874,8 @@ public class DarkListUIBridge extends BasicListUI {
// If shift is down in multi-select, we should do nothing. // If shift is down in multi-select, we should do nothing.
// For single select or non-shift-click, clear the selection // For single select or non-shift-click, clear the selection
if (isFileList && e.getID() == MouseEvent.MOUSE_PRESSED && if (isFileList && e.getID() == MouseEvent.MOUSE_PRESSED &&
(!e.isShiftDown() || (!e.isShiftDown() ||
list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION)) { list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION)) {
list.clearSelection(); list.clearSelection();
} }
} else { } else {

2
core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarBorder.java

@ -34,7 +34,7 @@ import java.awt.*;
*/ */
public class DarkMenuBarBorder implements Border, UIResource { public class DarkMenuBarBorder implements Border, UIResource {
protected Color borderColor; protected final Color borderColor;
public DarkMenuBarBorder() { public DarkMenuBarBorder() {
borderColor = UIManager.getColor("MenuBar.borderColor"); borderColor = UIManager.getColor("MenuBar.borderColor");

24
core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java

@ -23,11 +23,7 @@
*/ */
package com.github.weisj.darklaf.ui.menu; package com.github.weisj.darklaf.ui.menu;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.*;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import com.github.weisj.darklaf.util.LazyActionMap;
import com.github.weisj.darklaf.util.StringUtil;
import sun.swing.MenuItemLayoutHelper; import sun.swing.MenuItemLayoutHelper;
import sun.swing.SwingUtilities2; import sun.swing.SwingUtilities2;
import sun.swing.UIAction; import sun.swing.UIAction;
@ -79,7 +75,7 @@ public class DarkMenuItemUIBase extends BasicMenuItemUI {
ButtonModel model = lh.getMenuItem().getModel(); ButtonModel model = lh.getMenuItem().getModel();
if (model.isEnabled()) { if (model.isEnabled()) {
accRect.x = lh.getViewRect().x + lh.getViewRect().width accRect.x = lh.getViewRect().x + lh.getViewRect().width
- lh.getMenuItem().getIconTextGap() - lr.getAccRect().width; - lh.getMenuItem().getIconTextGap() - lr.getAccRect().width;
} }
} }
@ -98,9 +94,11 @@ public class DarkMenuItemUIBase extends BasicMenuItemUI {
DarkUIUtil.applyInsets(viewRect, mi.getInsets()); DarkUIUtil.applyInsets(viewRect, mi.getInsets());
MenuItemLayoutHelper lh = new MenuItemLayoutHelper(mi, checkIcon, MenuItemLayoutHelper lh = new MenuItemLayoutHelper(mi, checkIcon,
arrowIcon, viewRect, defaultTextIconGap, acceleratorDelimiter, arrowIcon, viewRect, defaultTextIconGap,
acceleratorDelimiter,
mi.getComponentOrientation().isLeftToRight(), mi.getFont(), mi.getComponentOrientation().isLeftToRight(), mi.getFont(),
acceleratorFont, MenuItemLayoutHelper.useCheckAndArrow(menuItem), acceleratorFont,
MenuItemLayoutHelper.useCheckAndArrow(menuItem),
getPropertyPrefix()); getPropertyPrefix());
MenuItemLayoutHelper.LayoutResult lr = lh.layoutMenuItem(); MenuItemLayoutHelper.LayoutResult lr = lh.layoutMenuItem();
@ -123,7 +121,7 @@ public class DarkMenuItemUIBase extends BasicMenuItemUI {
if (lh.getCheckIcon() != null) { if (lh.getCheckIcon() != null) {
ButtonModel model = lh.getMenuItem().getModel(); ButtonModel model = lh.getMenuItem().getModel();
if (model.isArmed() || (lh.getMenuItem() instanceof JMenu if (model.isArmed() || (lh.getMenuItem() instanceof JMenu
&& model.isSelected())) { && model.isSelected())) {
g.setColor(foreground); g.setColor(foreground);
} else { } else {
g.setColor(holdc); g.setColor(holdc);
@ -163,7 +161,7 @@ public class DarkMenuItemUIBase extends BasicMenuItemUI {
} else { } else {
// *** paint the accText normally // *** paint the accText normally
if (model.isArmed() if (model.isArmed()
|| (lh.getMenuItem() instanceof JMenu || (lh.getMenuItem() instanceof JMenu
&& model.isSelected())) { && model.isSelected())) {
g.setColor(acceleratorSelectionForeground); g.setColor(acceleratorSelectionForeground);
} else { } else {
@ -171,7 +169,7 @@ public class DarkMenuItemUIBase extends BasicMenuItemUI {
} }
SwingUtilities2.drawString(lh.getMenuItem(), g, lh.getAccText(), SwingUtilities2.drawString(lh.getMenuItem(), g, lh.getAccText(),
lr.getAccRect().x, lr.getAccRect().y + lr.getAccRect().x, lr.getAccRect().y +
lh.getAccFontMetrics().getAscent()); lh.getAccFontMetrics().getAscent());
} }
} }
config.restore(); config.restore();
@ -222,7 +220,7 @@ public class DarkMenuItemUIBase extends BasicMenuItemUI {
if (lh.getArrowIcon() != null) { if (lh.getArrowIcon() != null) {
ButtonModel model = lh.getMenuItem().getModel(); ButtonModel model = lh.getMenuItem().getModel();
if (model.isArmed() || (lh.getMenuItem() instanceof JMenu if (model.isArmed() || (lh.getMenuItem() instanceof JMenu
&& model.isSelected())) { && model.isSelected())) {
g.setColor(foreground); g.setColor(foreground);
} }
if (lh.useCheckAndArrow()) { if (lh.useCheckAndArrow()) {
@ -250,7 +248,7 @@ public class DarkMenuItemUIBase extends BasicMenuItemUI {
} }
g.setColor(oldColor); g.setColor(oldColor);
} else if (model.isArmed() || (menuItem instanceof JMenu && } else if (model.isArmed() || (menuItem instanceof JMenu &&
model.isSelected())) { model.isSelected())) {
g.setColor(bgColor); g.setColor(bgColor);
g.fillRect(0, 0, menuWidth, menuHeight); g.fillRect(0, 0, menuWidth, menuHeight);
g.setColor(oldColor); g.setColor(oldColor);

20
core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuUI.java

@ -122,7 +122,7 @@ public class DarkMenuUI extends BasicMenuUI {
protected Icon getArrowIcon() { protected Icon getArrowIcon() {
boolean hover = menuItem.getModel().isArmed() boolean hover = menuItem.getModel().isArmed()
|| (menuItem instanceof JMenu && menuItem.getModel().isSelected()); || (menuItem instanceof JMenu && menuItem.getModel().isSelected());
return hover ? arrowIconHover : arrowIcon; return hover ? arrowIconHover : arrowIcon;
} }
@ -137,7 +137,7 @@ public class DarkMenuUI extends BasicMenuUI {
ButtonModel model = lh.getMenuItem().getModel(); ButtonModel model = lh.getMenuItem().getModel();
if (model.isEnabled()) { if (model.isEnabled()) {
accRect.x = lh.getViewRect().x + lh.getViewRect().width accRect.x = lh.getViewRect().x + lh.getViewRect().width
- lh.getMenuItem().getIconTextGap() - lr.getAccRect().width; - lh.getMenuItem().getIconTextGap() - lr.getAccRect().width;
} }
} }
@ -156,9 +156,11 @@ public class DarkMenuUI extends BasicMenuUI {
DarkUIUtil.applyInsets(viewRect, mi.getInsets()); DarkUIUtil.applyInsets(viewRect, mi.getInsets());
MenuItemLayoutHelper lh = new MenuItemLayoutHelper(mi, checkIcon, MenuItemLayoutHelper lh = new MenuItemLayoutHelper(mi, checkIcon,
arrowIcon, viewRect, defaultTextIconGap, acceleratorDelimiter, arrowIcon, viewRect, defaultTextIconGap,
acceleratorDelimiter,
mi.getComponentOrientation().isLeftToRight(), mi.getFont(), mi.getComponentOrientation().isLeftToRight(), mi.getFont(),
acceleratorFont, MenuItemLayoutHelper.useCheckAndArrow(menuItem), acceleratorFont,
MenuItemLayoutHelper.useCheckAndArrow(menuItem),
getPropertyPrefix()); getPropertyPrefix());
MenuItemLayoutHelper.LayoutResult lr = lh.layoutMenuItem(); MenuItemLayoutHelper.LayoutResult lr = lh.layoutMenuItem();
@ -181,7 +183,7 @@ public class DarkMenuUI extends BasicMenuUI {
if (lh.getCheckIcon() != null) { if (lh.getCheckIcon() != null) {
ButtonModel model = lh.getMenuItem().getModel(); ButtonModel model = lh.getMenuItem().getModel();
if (model.isArmed() || (lh.getMenuItem() instanceof JMenu if (model.isArmed() || (lh.getMenuItem() instanceof JMenu
&& model.isSelected())) { && model.isSelected())) {
g.setColor(foreground); g.setColor(foreground);
} else { } else {
g.setColor(holdc); g.setColor(holdc);
@ -221,7 +223,7 @@ public class DarkMenuUI extends BasicMenuUI {
} else { } else {
// *** paint the accText normally // *** paint the accText normally
if (model.isArmed() if (model.isArmed()
|| (lh.getMenuItem() instanceof JMenu || (lh.getMenuItem() instanceof JMenu
&& model.isSelected())) { && model.isSelected())) {
g.setColor(acceleratorSelectionForeground); g.setColor(acceleratorSelectionForeground);
} else { } else {
@ -229,7 +231,7 @@ public class DarkMenuUI extends BasicMenuUI {
} }
SwingUtilities2.drawString(lh.getMenuItem(), g, lh.getAccText(), SwingUtilities2.drawString(lh.getMenuItem(), g, lh.getAccText(),
lr.getAccRect().x, lr.getAccRect().y + lr.getAccRect().x, lr.getAccRect().y +
lh.getAccFontMetrics().getAscent()); lh.getAccFontMetrics().getAscent());
} }
} }
config.restore(); config.restore();
@ -280,7 +282,7 @@ public class DarkMenuUI extends BasicMenuUI {
if (lh.getArrowIcon() != null) { if (lh.getArrowIcon() != null) {
ButtonModel model = lh.getMenuItem().getModel(); ButtonModel model = lh.getMenuItem().getModel();
if (model.isArmed() || (lh.getMenuItem() instanceof JMenu if (model.isArmed() || (lh.getMenuItem() instanceof JMenu
&& model.isSelected())) { && model.isSelected())) {
g.setColor(foreground); g.setColor(foreground);
} }
if (lh.useCheckAndArrow()) { if (lh.useCheckAndArrow()) {
@ -308,7 +310,7 @@ public class DarkMenuUI extends BasicMenuUI {
} }
g.setColor(oldColor); g.setColor(oldColor);
} else if (model.isArmed() || (menuItem instanceof JMenu && } else if (model.isArmed() || (menuItem instanceof JMenu &&
model.isSelected())) { model.isSelected())) {
g.setColor(bgColor); g.setColor(bgColor);
g.fillRect(0, 0, menuWidth, menuHeight); g.fillRect(0, 0, menuWidth, menuHeight);
g.setColor(oldColor); g.setColor(oldColor);

11
core/src/main/java/com/github/weisj/darklaf/ui/numberingpane/DarkNumberingPaneUI.java

@ -202,14 +202,16 @@ public class DarkNumberingPaneUI extends ComponentUI {
g.setColor(lineRect.y == yCur ? foregroundHighlight : numberingPane.getForeground()); g.setColor(lineRect.y == yCur ? foregroundHighlight : numberingPane.getForeground());
g.drawString(String.format("%1$" + digits + "d", i), OUTER_PAD, g.drawString(String.format("%1$" + digits + "d", i), OUTER_PAD,
lineRect.y + lineRect.height - descent); lineRect.y + lineRect.height - descent);
} catch (BadLocationException ignored) { } } catch (BadLocationException ignored) {
}
} }
config.restore(); config.restore();
} }
protected void paintIcons(final Graphics g, final int startLine, final int endLine, final Element root) { protected void paintIcons(final Graphics g, final int startLine, final int endLine, final Element root) {
List<Map.Entry<Position, Icon>> icons = numberingPane.getIconsInRange(root.getElement(startLine).getStartOffset(), List<Map.Entry<Position, Icon>> icons = numberingPane.getIconsInRange(
root.getElement(endLine).getEndOffset()); root.getElement(startLine).getStartOffset(),
root.getElement(endLine).getEndOffset());
for (Map.Entry<Position, Icon> icon : icons) { for (Map.Entry<Position, Icon> icon : icons) {
Rectangle lineRect; Rectangle lineRect;
try { try {
@ -264,7 +266,8 @@ public class DarkNumberingPaneUI extends ComponentUI {
listener.iconClicked(e); listener.iconClicked(e);
} }
} }
} catch (BadLocationException ignored) { } } catch (BadLocationException ignored) {
}
} }
IndexListener[] list = numberingPane.getIndexListeners(); IndexListener[] list = numberingPane.getIndexListeners();
for (IndexListener listener : list) { for (IndexListener listener : list) {

15
core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneUI.java

@ -38,11 +38,6 @@ public class DarkOptionPaneUI extends BasicOptionPaneUI {
return new DarkOptionPaneUI(); return new DarkOptionPaneUI();
} }
@Override
protected LayoutManager createLayoutManager() {
return super.createLayoutManager();
}
@Override @Override
protected Container createButtonArea() { protected Container createButtonArea() {
JPanel bottom = new JPanel(); JPanel bottom = new JPanel();
@ -228,12 +223,12 @@ public class DarkOptionPaneUI extends BasicOptionPaneUI {
x = insets.left; x = insets.left;
if (getSyncAllWidths()) { if (getSyncAllWidths()) {
xOffset = (container.getWidth() - insets.left - xOffset = (container.getWidth() - insets.left -
insets.right - totalButtonWidth) / insets.right - totalButtonWidth) /
(numChildren - 1) + maxWidth; (numChildren - 1) + maxWidth;
} else { } else {
xOffset = (container.getWidth() - insets.left - xOffset = (container.getWidth() - insets.left -
insets.right - totalButtonWidth) / insets.right - totalButtonWidth) /
(numChildren - 1); (numChildren - 1);
} }
} }
break; break;
@ -280,7 +275,7 @@ public class DarkOptionPaneUI extends BasicOptionPaneUI {
maxWidth = Math.max(maxWidth, aSize.width); maxWidth = Math.max(maxWidth, aSize.width);
} }
return new Dimension(extraWidth + (maxWidth * numChildren) + return new Dimension(extraWidth + (maxWidth * numChildren) +
(numChildren - 1) * padding, (numChildren - 1) * padding,
extraHeight + height); extraHeight + height);
} else { } else {
int totalWidth = 0; int totalWidth = 0;

3
core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuBorder.java

@ -40,7 +40,8 @@ public class DarkPopupMenuBorder extends MutableLineBorder implements UIResource
} }
@Override @Override
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) { public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width,
final int height) {
setColor(UIManager.getDefaults().getColor("PopupMenu.borderColor")); setColor(UIManager.getDefaults().getColor("PopupMenu.borderColor"));
super.paintBorder(c, g, x, y, width, height); super.paintBorder(c, g, x, y, width, height);
} }

20
core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuUI.java

@ -112,7 +112,7 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI {
} }
public static class MouseGrabber implements ChangeListener, public static class MouseGrabber implements ChangeListener,
AWTEventListener, ComponentListener, WindowListener { AWTEventListener, ComponentListener, WindowListener {
Window grabbedWindow; Window grabbedWindow;
MenuElement[] lastPathSelected; MenuElement[] lastPathSelected;
@ -133,13 +133,13 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI {
(PrivilegedAction<Object>) () -> { (PrivilegedAction<Object>) () -> {
tk.addAWTEventListener(MouseGrabber.this, tk.addAWTEventListener(MouseGrabber.this,
AWTEvent.MOUSE_EVENT_MASK AWTEvent.MOUSE_EVENT_MASK
| AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK
| AWTEvent.MOUSE_WHEEL_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK
| AWTEvent.WINDOW_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK
| SunToolkit.GRAB_EVENT_MASK); | SunToolkit.GRAB_EVENT_MASK);
return null; return null;
} }
); );
Component invoker = newPath[0].getComponent(); Component invoker = newPath[0].getComponent();
if (invoker instanceof JPopupMenu) { if (invoker instanceof JPopupMenu) {
@ -174,7 +174,7 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI {
tk.removeAWTEventListener(MouseGrabber.this); tk.removeAWTEventListener(MouseGrabber.this);
return null; return null;
} }
); );
realUngrabWindow(); realUngrabWindow();
} }
@ -308,7 +308,7 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI {
} else if (c instanceof JPopupMenu) { } else if (c instanceof JPopupMenu) {
return true; return true;
} else if (c instanceof JComponent } else if (c instanceof JComponent
&& Boolean.TRUE.equals(((JComponent) c).getClientProperty(KEY_DO_NOT_CANCEL_ON_SCROLL))) { && Boolean.TRUE.equals(((JComponent) c).getClientProperty(KEY_DO_NOT_CANCEL_ON_SCROLL))) {
/* /*
* Change here: allows scrollable components that contain the popupMenu. * Change here: allows scrollable components that contain the popupMenu.
*/ */

9
core/src/main/java/com/github/weisj/darklaf/ui/progressbar/DarkProgressBarUI.java

@ -146,13 +146,15 @@ public class DarkProgressBarUI extends BasicProgressBarUI implements PropertyCha
shape = getShapedRect(r.x, yOffset, r.width, pHeight, pHeight); shape = getShapedRect(r.x, yOffset, r.width, pHeight, pHeight);
yOffset = r.y + pHeight / 2; yOffset = r.y + pHeight / 2;
g2.setPaint(new GradientPaint(r.x + getAnimationIndex() * step * 2, yOffset, startColor, g2.setPaint(new GradientPaint(r.x + getAnimationIndex() * step * 2, yOffset, startColor,
r.x + getFrameCount() * step + getAnimationIndex() * step * 2, yOffset, r.x + getFrameCount() * step + getAnimationIndex() * step * 2,
yOffset,
endColor, true)); endColor, true));
} else { } else {
shape = getShapedRect(xOffset, r.y, pWidth, r.height, pWidth); shape = getShapedRect(xOffset, r.y, pWidth, r.height, pWidth);
xOffset = r.x + pWidth / 2; xOffset = r.x + pWidth / 2;
g2.setPaint(new GradientPaint(xOffset, r.y + getAnimationIndex() * step * 2, startColor, g2.setPaint(new GradientPaint(xOffset, r.y + getAnimationIndex() * step * 2, startColor,
xOffset, r.y + getFrameCount() * step + getAnimationIndex() * step * 2, xOffset,
r.y + getFrameCount() * step + getAnimationIndex() * step * 2,
endColor, true)); endColor, true));
} }
g2.fill(shape); g2.fill(shape);
@ -180,7 +182,8 @@ public class DarkProgressBarUI extends BasicProgressBarUI implements PropertyCha
@Override @Override
protected void installDefaults() { protected void installDefaults() {
super.installDefaults(); super.installDefaults();
UIManager.put("ProgressBar.repaintInterval", isSimplified() ? REPAINT_INTERVAL_SIMPLIFIED : REPAINT_INTERVAL_DEFAULT); UIManager.put("ProgressBar.repaintInterval",
isSimplified() ? REPAINT_INTERVAL_SIMPLIFIED : REPAINT_INTERVAL_DEFAULT);
UIManager.put("ProgressBar.cycleTime", isSimplified() ? CYCLE_TIME_SIMPLIFIED : CYCLE_TIME_DEFAULT); UIManager.put("ProgressBar.cycleTime", isSimplified() ? CYCLE_TIME_SIMPLIFIED : CYCLE_TIME_DEFAULT);
trackColor = UIManager.getColor("ProgressBar.trackColor"); trackColor = UIManager.getColor("ProgressBar.trackColor");
progressColor = UIManager.getColor("ProgressBar.progressColor"); progressColor = UIManager.getColor("ProgressBar.progressColor");

2
core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java

@ -55,7 +55,7 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
private LayoutManager layoutManager; private LayoutManager layoutManager;
private LayoutManager oldLayout; private LayoutManager oldLayout;
private JRootPane rootPane; private JRootPane rootPane;
private DisposeListener disposeListener = new DisposeListener(); private final DisposeListener disposeListener = new DisposeListener();
private boolean decorationStyleLock = false; private boolean decorationStyleLock = false;
private int windowDecorationsStyle = -1; private int windowDecorationsStyle = -1;

12
core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkSubstanceRootLayout.java

@ -126,9 +126,9 @@ class DarkSubstanceRootLayout implements LayoutManager2 {
} }
} }
if ((root.getWindowDecorationStyle() != JRootPane.NONE) if ((root.getWindowDecorationStyle() != JRootPane.NONE)
&& (root.getUI() instanceof DarkRootPaneUI)) { && (root.getUI() instanceof DarkRootPaneUI)) {
JComponent titlePane = ((DarkRootPaneUI) root.getUI()) JComponent titlePane = ((DarkRootPaneUI) root.getUI())
.getTitlePane(); .getTitlePane();
if (titlePane != null) { if (titlePane != null) {
tpd = titlePane.getMinimumSize(); tpd = titlePane.getMinimumSize();
if (tpd != null) { if (tpd != null) {
@ -139,8 +139,8 @@ class DarkSubstanceRootLayout implements LayoutManager2 {
} }
return new Dimension(Math.max(Math.max(cpWidth, mbWidth), tpWidth) return new Dimension(Math.max(Math.max(cpWidth, mbWidth), tpWidth)
+ i.left + i.right, cpHeight + mbHeight + tpHeight + i.top + i.left + i.right, cpHeight + mbHeight + tpHeight + i.top
+ i.bottom); + i.bottom);
} }
protected CustomTitlePane getTitlePane(final JRootPane root) { protected CustomTitlePane getTitlePane(final JRootPane root) {
@ -212,9 +212,9 @@ class DarkSubstanceRootLayout implements LayoutManager2 {
} }
if ((root.getWindowDecorationStyle() != JRootPane.NONE) if ((root.getWindowDecorationStyle() != JRootPane.NONE)
&& (root.getUI() instanceof DarkRootPaneUI)) { && (root.getUI() instanceof DarkRootPaneUI)) {
JComponent titlePane = ((DarkRootPaneUI) root.getUI()) JComponent titlePane = ((DarkRootPaneUI) root.getUI())
.getTitlePane(); .getTitlePane();
if (titlePane != null) { if (titlePane != null) {
tpd = titlePane.getMaximumSize(); tpd = titlePane.getMaximumSize();
if (tpd != null) { if (tpd != null) {

22
core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarListener.java

@ -43,10 +43,10 @@ public class DarkScrollBarListener extends MouseAdapter implements AdjustmentLis
protected final JScrollBar scrollbar; protected final JScrollBar scrollbar;
private final DarkScrollBarUI ui; private final DarkScrollBarUI ui;
private Animator trackFadeoutAnimator; private final Animator trackFadeoutAnimator;
private Animator trackFadeinAnimator; private final Animator trackFadeinAnimator;
private Animator thumbFadeoutAnimator; private final Animator thumbFadeoutAnimator;
private Animator thumbFadeinAnimator; private final Animator thumbFadeinAnimator;
protected boolean mouseOverThumb = false; protected boolean mouseOverThumb = false;
protected boolean mouseOverTrack = false; protected boolean mouseOverTrack = false;
@ -183,7 +183,7 @@ public class DarkScrollBarListener extends MouseAdapter implements AdjustmentLis
} }
protected void resetAnimators(final Animator fadeInAnimator, final Animator fadeOutAnimator, protected void resetAnimators(final Animator fadeInAnimator, final Animator fadeOutAnimator,
final boolean overAnimatedComponent, final float currentAlpha, final float maxAlpha) { final boolean overAnimatedComponent, final float currentAlpha, final float maxAlpha) {
fadeInAnimator.reset(); fadeInAnimator.reset();
fadeOutAnimator.reset(); fadeOutAnimator.reset();
if (scrollbar != null && (scrollbar.getValueIsAdjusting() || overAnimatedComponent)) { if (scrollbar != null && (scrollbar.getValueIsAdjusting() || overAnimatedComponent)) {
@ -221,7 +221,8 @@ public class DarkScrollBarListener extends MouseAdapter implements AdjustmentLis
protected class TrackFadeOutAnimator extends Animator { protected class TrackFadeOutAnimator extends Animator {
public TrackFadeOutAnimator() { public TrackFadeOutAnimator() {
super("Track fadeout", DarkScrollBarListener.FADEOUT_FRAMES_COUNT, DarkScrollBarListener.FADEOUT_FRAMES_COUNT * DarkScrollBarListener.FADEOUT_FRAME_COUNT_FACTOR, false); super("Track fadeout", DarkScrollBarListener.FADEOUT_FRAMES_COUNT,
DarkScrollBarListener.FADEOUT_FRAMES_COUNT * DarkScrollBarListener.FADEOUT_FRAME_COUNT_FACTOR, false);
} }
public void paintNow(final int frame, final int totalFrames, final int cycle) { public void paintNow(final int frame, final int totalFrames, final int cycle) {
@ -245,7 +246,8 @@ public class DarkScrollBarListener extends MouseAdapter implements AdjustmentLis
protected class ThumbFadeInAnimator extends Animator { protected class ThumbFadeInAnimator extends Animator {
public ThumbFadeInAnimator() { public ThumbFadeInAnimator() {
super("Thumb fadein", DarkScrollBarListener.FADEIN_FRAMES_COUNT / 2, DarkScrollBarListener.FADEIN_FRAMES_COUNT * DarkScrollBarListener.FADEIN_FRAME_COUNT_FACTOR, false); super("Thumb fadein", DarkScrollBarListener.FADEIN_FRAMES_COUNT / 2,
DarkScrollBarListener.FADEIN_FRAMES_COUNT * DarkScrollBarListener.FADEIN_FRAME_COUNT_FACTOR, false);
} }
@Override @Override
@ -273,7 +275,8 @@ public class DarkScrollBarListener extends MouseAdapter implements AdjustmentLis
protected class TrackFadeInAnimator extends Animator { protected class TrackFadeInAnimator extends Animator {
public TrackFadeInAnimator() { public TrackFadeInAnimator() {
super("Track fadein", DarkScrollBarListener.FADEIN_FRAMES_COUNT, DarkScrollBarListener.FADEIN_FRAMES_COUNT * DarkScrollBarListener.FADEIN_FRAME_COUNT_FACTOR, false); super("Track fadein", DarkScrollBarListener.FADEIN_FRAMES_COUNT,
DarkScrollBarListener.FADEIN_FRAMES_COUNT * DarkScrollBarListener.FADEIN_FRAME_COUNT_FACTOR, false);
} }
public void paintNow(final int frame, final int totalFrames, final int cycle) { public void paintNow(final int frame, final int totalFrames, final int cycle) {
@ -294,7 +297,8 @@ public class DarkScrollBarListener extends MouseAdapter implements AdjustmentLis
protected class ThumbFadeOutAnimator extends Animator { protected class ThumbFadeOutAnimator extends Animator {
public ThumbFadeOutAnimator() { public ThumbFadeOutAnimator() {
super("Adjustment fadeout", DarkScrollBarListener.FADEOUT_FRAMES_COUNT, DarkScrollBarListener.FADEOUT_FRAMES_COUNT * DarkScrollBarListener.FADEOUT_FRAME_COUNT_FACTOR, false); super("Adjustment fadeout", DarkScrollBarListener.FADEOUT_FRAMES_COUNT,
DarkScrollBarListener.FADEOUT_FRAMES_COUNT * DarkScrollBarListener.FADEOUT_FRAME_COUNT_FACTOR, false);
} }
@Override @Override

6
core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollPaneUI.java

@ -45,7 +45,7 @@ public class DarkScrollPaneUI extends BasicScrollPaneUI {
JScrollBar scrollbar = scrollpane.getHorizontalScrollBar(); JScrollBar scrollbar = scrollpane.getHorizontalScrollBar();
scrollbar.setValueIsAdjusting(true); scrollbar.setValueIsAdjusting(true);
ScrollBarUtil.doScroll(scrollbar, scrollpane.getViewport(), e, ScrollBarUtil.doScroll(scrollbar, scrollpane.getViewport(), e,
scrollpane.getComponentOrientation().isLeftToRight()); scrollpane.getComponentOrientation().isLeftToRight());
scrollbar.setValueIsAdjusting(false); scrollbar.setValueIsAdjusting(false);
}; };
private final MouseWheelListener horizontalMouseWheelListener = e -> { private final MouseWheelListener horizontalMouseWheelListener = e -> {
@ -55,7 +55,7 @@ public class DarkScrollPaneUI extends BasicScrollPaneUI {
JScrollBar scrollbar = scrollpane.getVerticalScrollBar(); JScrollBar scrollbar = scrollpane.getVerticalScrollBar();
scrollbar.setValueIsAdjusting(true); scrollbar.setValueIsAdjusting(true);
ScrollBarUtil.doScroll(scrollbar, scrollpane.getViewport(), e, ScrollBarUtil.doScroll(scrollbar, scrollpane.getViewport(), e,
scrollpane.getComponentOrientation().isLeftToRight()); scrollpane.getComponentOrientation().isLeftToRight());
scrollbar.setValueIsAdjusting(false); scrollbar.setValueIsAdjusting(false);
}; };
private final MouseWheelListener mouseWheelListener = e -> { private final MouseWheelListener mouseWheelListener = e -> {
@ -66,7 +66,7 @@ public class DarkScrollPaneUI extends BasicScrollPaneUI {
: scrollpane.getVerticalScrollBar(); : scrollpane.getVerticalScrollBar();
scrollbar.setValueIsAdjusting(true); scrollbar.setValueIsAdjusting(true);
ScrollBarUtil.doScroll(scrollbar, scrollpane.getViewport(), e, ScrollBarUtil.doScroll(scrollbar, scrollpane.getViewport(), e,
scrollpane.getComponentOrientation().isLeftToRight()); scrollpane.getComponentOrientation().isLeftToRight());
scrollbar.setValueIsAdjusting(false); scrollbar.setValueIsAdjusting(false);
}; };
private final PropertyChangeListener propertyChangeListener = e -> { private final PropertyChangeListener propertyChangeListener = e -> {

4
core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollBarUtil.java

@ -144,10 +144,10 @@ public class ScrollBarUtil implements ScrollBarConstants {
if (limitToBlock) { if (limitToBlock) {
if (direction < 0) { if (direction < 0) {
limit = scrollbar.getValue() - limit = scrollbar.getValue() -
scrollbar.getBlockIncrement(direction); scrollbar.getBlockIncrement(direction);
} else { } else {
limit = scrollbar.getValue() + limit = scrollbar.getValue() +
scrollbar.getBlockIncrement(direction); scrollbar.getBlockIncrement(direction);
} }
} }

16
core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java

@ -112,7 +112,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
private static boolean showVolumeIcon(final JComponent c) { private static boolean showVolumeIcon(final JComponent c) {
return isVolumeSlider(c) return isVolumeSlider(c)
&& Boolean.TRUE.equals(c.getClientProperty(KEY_SHOW_VOLUME_ICON)); && Boolean.TRUE.equals(c.getClientProperty(KEY_SHOW_VOLUME_ICON));
} }
private static boolean isVolumeSlider(final JComponent c) { private static boolean isVolumeSlider(final JComponent c) {
@ -413,10 +413,10 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
int w = showVolumeIcon(slider) ? trackRect.width + getIconBarExt() : trackRect.width; int w = showVolumeIcon(slider) ? trackRect.width + getIconBarExt() : trackRect.width;
if (slider.getComponentOrientation().isLeftToRight()) { if (slider.getComponentOrientation().isLeftToRight()) {
return new Area(new RoundRectangle2D.Double( return new Area(new RoundRectangle2D.Double(
trackRect.x, trackRect.y + yOff, w, trackSize, arc, arc)); trackRect.x, trackRect.y + yOff, w, trackSize, arc, arc));
} else { } else {
return new Area(new RoundRectangle2D.Double( return new Area(new RoundRectangle2D.Double(
trackRect.x - getIconBarExt(), trackRect.y + yOff, w, trackSize, arc, arc)); trackRect.x - getIconBarExt(), trackRect.y + yOff, w, trackSize, arc, arc));
} }
} }
@ -437,10 +437,10 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
int h = showVolumeIcon(slider) ? trackRect.height + getIconBarExt() : trackRect.height; int h = showVolumeIcon(slider) ? trackRect.height + getIconBarExt() : trackRect.height;
if (slider.getComponentOrientation().isLeftToRight()) { if (slider.getComponentOrientation().isLeftToRight()) {
return new Area(new RoundRectangle2D.Double( return new Area(new RoundRectangle2D.Double(
trackRect.x + xOff, trackRect.y, trackSize, h, arc, arc)); trackRect.x + xOff, trackRect.y, trackSize, h, arc, arc));
} else { } else {
return new Area(new RoundRectangle2D.Double( return new Area(new RoundRectangle2D.Double(
trackRect.x + xOff, trackRect.y - getIconBarExt(), trackSize, h, arc, arc)); trackRect.x + xOff, trackRect.y - getIconBarExt(), trackSize, h, arc, arc));
} }
} }
@ -474,7 +474,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
protected boolean isPlainThumb() { protected boolean isPlainThumb() {
Boolean paintThumbArrowShape = (Boolean) slider.getClientProperty(KEY_THUMB_ARROW_SHAPE); Boolean paintThumbArrowShape = (Boolean) slider.getClientProperty(KEY_THUMB_ARROW_SHAPE);
return (!slider.getPaintTicks() && paintThumbArrowShape == null) || return (!slider.getPaintTicks() && paintThumbArrowShape == null) ||
paintThumbArrowShape == Boolean.FALSE; paintThumbArrowShape == Boolean.FALSE;
} }
private void paintSliderThumb(final Graphics2D g) { private void paintSliderThumb(final Graphics2D g) {
@ -641,9 +641,9 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
if (tickSpacing != 0) { if (tickSpacing != 0) {
if ((value - slider.getMinimum()) % tickSpacing != 0) { if ((value - slider.getMinimum()) % tickSpacing != 0) {
float temp = (float) (value - slider.getMinimum()) float temp = (float) (value - slider.getMinimum())
/ (float) tickSpacing; / (float) tickSpacing;
snappedValue = slider.getMinimum() + snappedValue = slider.getMinimum() +
(Math.round(temp) * tickSpacing); (Math.round(temp) * tickSpacing);
} }
} }
return snappedValue; return snappedValue;

10
core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java

@ -38,11 +38,11 @@ import java.awt.*;
*/ */
public class DarkSpinnerBorder implements Border, UIResource { public class DarkSpinnerBorder implements Border, UIResource {
protected Color focusBorderColor; protected final Color focusBorderColor;
protected Color borderColor; protected final Color borderColor;
protected Color inactiveBorderColor; protected final Color inactiveBorderColor;
protected int arc; protected final int arc;
protected int borderSize; protected final int borderSize;
protected Insets insets; protected Insets insets;
protected Insets cellInsets; protected Insets cellInsets;

2
core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerListener.java

@ -64,7 +64,7 @@ public class DarkSpinnerListener extends MouseAdapter implements PropertyChangeL
@Override @Override
public void propertyChange(final PropertyChangeEvent evt) { public void propertyChange(final PropertyChangeEvent evt) {
String key = evt.getPropertyName(); String key = evt.getPropertyName();
Component editorComponent= ui.getEditorComponent(); Component editorComponent = ui.getEditorComponent();
JComponent editor = ui.getEditor(); JComponent editor = ui.getEditor();
if (PropertyKey.OPAQUE.equals(key)) { if (PropertyKey.OPAQUE.equals(key)) {
boolean val = Boolean.TRUE.equals(evt.getNewValue()); boolean val = Boolean.TRUE.equals(evt.getNewValue());

4
core/src/main/java/com/github/weisj/darklaf/ui/spinner/SpinnerConstants.java

@ -45,11 +45,11 @@ public interface SpinnerConstants {
static boolean isTreeCellEditor(final Component c) { static boolean isTreeCellEditor(final Component c) {
return c instanceof JComponent return c instanceof JComponent
&& Boolean.TRUE.equals(((JComponent) c).getClientProperty(KEY_IS_TREE_EDITOR)); && Boolean.TRUE.equals(((JComponent) c).getClientProperty(KEY_IS_TREE_EDITOR));
} }
static boolean isTableCellEditor(final Component c) { static boolean isTableCellEditor(final Component c) {
return c instanceof JComponent return c instanceof JComponent
&& Boolean.TRUE.equals(((JComponent) c).getClientProperty(KEY_IS_TABLE_EDITOR)); && Boolean.TRUE.equals(((JComponent) c).getClientProperty(KEY_IS_TABLE_EDITOR));
} }
} }

14
core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneDivider.java

@ -37,13 +37,13 @@ import java.awt.*;
*/ */
public class DarkSplitPaneDivider extends BasicSplitPaneDivider { public class DarkSplitPaneDivider extends BasicSplitPaneDivider {
protected Icon leftOneTouch; protected final Icon leftOneTouch;
protected Icon rightOneTouch; protected final Icon rightOneTouch;
protected Icon topOneTouch; protected final Icon topOneTouch;
protected Icon bottomOneTouch; protected final Icon bottomOneTouch;
protected Icon verticalSplit; protected final Icon verticalSplit;
protected Icon horizontalSplit; protected final Icon horizontalSplit;
protected Color borderColor; protected final Color borderColor;
public DarkSplitPaneDivider(final BasicSplitPaneUI ui) { public DarkSplitPaneDivider(final BasicSplitPaneUI ui) {
super(ui); super(ui);

2
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkHandler.java

@ -36,7 +36,7 @@ import java.beans.PropertyChangeEvent;
public class DarkHandler extends TabbedPaneHandler { public class DarkHandler extends TabbedPaneHandler {
protected DarkTabbedPaneUI ui; protected final DarkTabbedPaneUI ui;
protected Point origin; protected Point origin;
protected Point tabOrigin; protected Point tabOrigin;

5
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabPanel.java

@ -29,7 +29,7 @@ class DarkScrollableTabPanel extends ScrollableTabPanel {
protected final Rectangle iconRect = new Rectangle(); protected final Rectangle iconRect = new Rectangle();
protected final Rectangle textRect = new Rectangle(); protected final Rectangle textRect = new Rectangle();
private DarkTabbedPaneUI ui; private final DarkTabbedPaneUI ui;
public DarkScrollableTabPanel(final DarkTabbedPaneUI ui) { public DarkScrollableTabPanel(final DarkTabbedPaneUI ui) {
super(ui); super(ui);
@ -79,7 +79,8 @@ class DarkScrollableTabPanel extends ScrollableTabPanel {
public void paint(final Graphics g) { public void paint(final Graphics g) {
super.paint(g); super.paint(g);
if (ui.dragging && ui.tabPane.getTabCount() > 0) { if (ui.dragging && ui.tabPane.getTabCount() > 0) {
ui.paintTab(g, ui.tabPane.getTabPlacement(), ui.dragRect, ui.tabPane.getSelectedIndex(), iconRect, textRect); ui.paintTab(g, ui.tabPane.getTabPlacement(), ui.dragRect, ui.tabPane.getSelectedIndex(), iconRect,
textRect);
Component comp = ui.tabPane.getTabComponentAt(ui.dropSourceIndex); Component comp = ui.tabPane.getTabComponentAt(ui.dropSourceIndex);
if (comp != null) { if (comp != null) {
g.translate(comp.getX(), comp.getY()); g.translate(comp.getX(), comp.getY());

9
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabSupport.java

@ -43,7 +43,7 @@ public class DarkScrollableTabSupport extends ScrollableTabSupport implements Mo
protected final JComponent newTabButton; protected final JComponent newTabButton;
protected final Timer timer; protected final Timer timer;
protected long lastClickEvent; protected long lastClickEvent;
private DarkTabbedPaneUI ui; private final DarkTabbedPaneUI ui;
public DarkScrollableTabSupport(final DarkTabbedPaneUI ui, final int tabPlacement) { public DarkScrollableTabSupport(final DarkTabbedPaneUI ui, final int tabPlacement) {
super(ui); super(ui);
@ -59,7 +59,8 @@ public class DarkScrollableTabSupport extends ScrollableTabSupport implements Mo
moreTabsButton.addActionListener(this); moreTabsButton.addActionListener(this);
newTabButton = ui.createNewTabButton(); newTabButton = ui.createNewTabButton();
newTabButton.setVisible(Boolean.TRUE.equals(ui.tabPane.getClientProperty(DarkTabbedPaneUI.KEY_SHOW_NEW_TAB_BUTTON))); newTabButton.setVisible(
Boolean.TRUE.equals(ui.tabPane.getClientProperty(DarkTabbedPaneUI.KEY_SHOW_NEW_TAB_BUTTON)));
scrollPopupMenu = new ScrollPopupMenu(UIManager.getInt(DarkTabbedPaneUI.KEY_MAX_POPUP_HEIGHT)); scrollPopupMenu = new ScrollPopupMenu(UIManager.getInt(DarkTabbedPaneUI.KEY_MAX_POPUP_HEIGHT));
PopupMenuListener popupMenuListener = new PopupMenuAdapter() { PopupMenuListener popupMenuListener = new PopupMenuAdapter() {
@ -165,7 +166,7 @@ public class DarkScrollableTabSupport extends ScrollableTabSupport implements Mo
int shift; int shift;
if (horizontal) { if (horizontal) {
int rightMargin = size.width - (insets.left + insets.right int rightMargin = size.width - (insets.left + insets.right
+ tabAreaInsets.right + tabAreaInsets.left); + tabAreaInsets.right + tabAreaInsets.left);
if (moreTabsButton.isVisible()) { if (moreTabsButton.isVisible()) {
rightMargin -= moreTabsButton.getWidth(); rightMargin -= moreTabsButton.getWidth();
} }
@ -182,7 +183,7 @@ public class DarkScrollableTabSupport extends ScrollableTabSupport implements Mo
ui.scrollShiftX += shift; ui.scrollShiftX += shift;
} else { } else {
int bottomMargin = size.height - (insets.bottom + tabAreaInsets.bottom int bottomMargin = size.height - (insets.bottom + tabAreaInsets.bottom
+ insets.top + tabAreaInsets.top); + insets.top + tabAreaInsets.top);
if (moreTabsButton.isVisible()) { if (moreTabsButton.isVisible()) {
bottomMargin -= moreTabsButton.getHeight(); bottomMargin -= moreTabsButton.getHeight();
} }

2
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabAreaButton.java

@ -29,7 +29,7 @@ import java.awt.*;
public class DarkTabAreaButton extends JButton implements UIResource { public class DarkTabAreaButton extends JButton implements UIResource {
private DarkTabbedPaneUI ui; private final DarkTabbedPaneUI ui;
public DarkTabAreaButton(final DarkTabbedPaneUI ui) { public DarkTabAreaButton(final DarkTabbedPaneUI ui) {
this.ui = ui; this.ui = ui;

10
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneLayout.java

@ -28,7 +28,7 @@ import java.awt.*;
public class DarkTabbedPaneLayout extends TabbedPaneLayout { public class DarkTabbedPaneLayout extends TabbedPaneLayout {
private DarkTabbedPaneUI ui; private final DarkTabbedPaneUI ui;
public DarkTabbedPaneLayout(final DarkTabbedPaneUI ui) { public DarkTabbedPaneLayout(final DarkTabbedPaneUI ui) {
super(ui); super(ui);
@ -72,7 +72,7 @@ public class DarkTabbedPaneLayout extends TabbedPaneLayout {
// //
if (selectedComponent != null) { if (selectedComponent != null) {
if (selectedComponent != visibleComponent && if (selectedComponent != visibleComponent &&
visibleComponent != null) { visibleComponent != null) {
Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (owner != null && SwingUtilities.isDescendingFrom(owner, visibleComponent)) { if (owner != null && SwingUtilities.isDescendingFrom(owner, visibleComponent)) {
shouldChangeFocus = true; shouldChangeFocus = true;
@ -94,7 +94,7 @@ public class DarkTabbedPaneLayout extends TabbedPaneLayout {
cx = insets.left + tw + contentInsets.left + tabAreaInsets.left + tabAreaInsets.right; cx = insets.left + tw + contentInsets.left + tabAreaInsets.left + tabAreaInsets.right;
cy = insets.top + contentInsets.top; cy = insets.top + contentInsets.top;
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right - tw cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right - tw
- tabAreaInsets.left - tabAreaInsets.right; - tabAreaInsets.left - tabAreaInsets.right;
ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom;
break; break;
case SwingConstants.RIGHT: case SwingConstants.RIGHT:
@ -105,7 +105,7 @@ public class DarkTabbedPaneLayout extends TabbedPaneLayout {
cx = insets.left + contentInsets.left; cx = insets.left + contentInsets.left;
cy = insets.top + contentInsets.top; cy = insets.top + contentInsets.top;
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right - tw cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right - tw
- tabAreaInsets.left - tabAreaInsets.right; - tabAreaInsets.left - tabAreaInsets.right;
ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom;
break; break;
case SwingConstants.BOTTOM: case SwingConstants.BOTTOM:
@ -127,7 +127,7 @@ public class DarkTabbedPaneLayout extends TabbedPaneLayout {
cy = insets.top + th + contentInsets.top + tabAreaInsets.top + tabAreaInsets.bottom; cy = insets.top + th + contentInsets.top + tabAreaInsets.top + tabAreaInsets.bottom;
cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right; cw = bounds.width - insets.left - insets.right - contentInsets.left - contentInsets.right;
ch = bounds.height - th - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom ch = bounds.height - th - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom
- tabAreaInsets.top - tabAreaInsets.bottom; - tabAreaInsets.top - tabAreaInsets.bottom;
break; break;
} }

17
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneScrollLayout.java

@ -29,7 +29,7 @@ import java.util.function.Function;
public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
private DarkTabbedPaneUI ui; private final DarkTabbedPaneUI ui;
public DarkTabbedPaneScrollLayout(final DarkTabbedPaneUI ui) { public DarkTabbedPaneScrollLayout(final DarkTabbedPaneUI ui) {
super(ui); super(ui);
@ -71,7 +71,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
// //
if (selectedComponent != null) { if (selectedComponent != null) {
if (selectedComponent != visibleComponent && if (selectedComponent != visibleComponent &&
visibleComponent != null) { visibleComponent != null) {
Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (owner != null && SwingUtilities.isDescendingFrom(owner, visibleComponent)) { if (owner != null && SwingUtilities.isDescendingFrom(owner, visibleComponent)) {
@ -96,7 +96,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
cx = insets.left + tw + contentInsets.left + tabAreaInsets.left + tabAreaInsets.right; cx = insets.left + tw + contentInsets.left + tabAreaInsets.left + tabAreaInsets.right;
cy = insets.top + contentInsets.top; cy = insets.top + contentInsets.top;
cw = bounds.width - insets.left - insets.right - tw - contentInsets.left - contentInsets.right cw = bounds.width - insets.left - insets.right - tw - contentInsets.left - contentInsets.right
- tabAreaInsets.left - tabAreaInsets.right; - tabAreaInsets.left - tabAreaInsets.right;
ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom; ch = bounds.height - insets.top - insets.bottom - contentInsets.top - contentInsets.bottom;
tw -= tabAreaInsets.left + tabAreaInsets.right; tw -= tabAreaInsets.left + tabAreaInsets.right;
break; break;
@ -313,7 +313,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
: new Rectangle(0, 0, 0, 0); : new Rectangle(0, 0, 0, 0);
if (!verticalTabRuns) { if (!verticalTabRuns) {
int rightMargin = size.width - (insets.right + tabAreaInsets.right int rightMargin = size.width - (insets.right + tabAreaInsets.right
+ insets.left + tabAreaInsets.left); + insets.left + tabAreaInsets.left);
Point p = getMargins(tabPlacement); Point p = getMargins(tabPlacement);
int leftMargin = p.x; int leftMargin = p.x;
int returnAt = p.y; int returnAt = p.y;
@ -360,7 +360,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
} else { } else {
int bottomMargin = size.height - (insets.bottom + tabAreaInsets.bottom int bottomMargin = size.height - (insets.bottom + tabAreaInsets.bottom
+ insets.top + tabAreaInsets.top); + insets.top + tabAreaInsets.top);
Point p = getMargins(tabPlacement); Point p = getMargins(tabPlacement);
int topMargin = p.x; int topMargin = p.x;
int returnAt = p.y; int returnAt = p.y;
@ -413,7 +413,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
if (ui.isHorizontalTabPlacement()) { if (ui.isHorizontalTabPlacement()) {
int leftMargin = 0; int leftMargin = 0;
int returnAt = size.width - (insets.right + tabAreaInsets.right int returnAt = size.width - (insets.right + tabAreaInsets.right
+ insets.left + tabAreaInsets.left); + insets.left + tabAreaInsets.left);
if (tabsButton.isVisible()) { if (tabsButton.isVisible()) {
returnAt -= tabsButton.getPreferredSize().width; returnAt -= tabsButton.getPreferredSize().width;
} }
@ -424,7 +424,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
} else { } else {
int topMargin = 0; int topMargin = 0;
int returnAt = size.height - (insets.bottom + tabAreaInsets.bottom int returnAt = size.height - (insets.bottom + tabAreaInsets.bottom
+ insets.top + tabAreaInsets.top); + insets.top + tabAreaInsets.top);
if (tabsButton.isVisible()) { if (tabsButton.isVisible()) {
returnAt -= tabsButton.getPreferredSize().height; returnAt -= tabsButton.getPreferredSize().height;
} }
@ -570,7 +570,8 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
protected void restoreHiddenTabsY(final int minY, final int maxY, final int tabCount) { protected void restoreHiddenTabsY(final int minY, final int maxY, final int tabCount) {
if (ui.maxVisible < 0 || ui.maxVisible >= tabCount) return; if (ui.maxVisible < 0 || ui.maxVisible >= tabCount) return;
int space = Math.max(maxY - ui.rects[ui.maxVisible].y - ui.rects[ui.maxVisible].height - ui.currentShiftYTmp, 0); int space = Math.max(maxY - ui.rects[ui.maxVisible].y - ui.rects[ui.maxVisible].height - ui.currentShiftYTmp,
0);
int shift = Math.min(minY - ui.rects[0].y - ui.currentShiftYTmp, space); int shift = Math.min(minY - ui.rects[0].y - ui.currentShiftYTmp, space);
shiftTabsY(shift, minY, maxY, tabCount, true); shiftTabsY(shift, minY, maxY, tabCount, true);
} }

2
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java

@ -101,7 +101,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
protected int focusSize; protected int focusSize;
protected boolean dragging; protected boolean dragging;
protected Rectangle dragRect = new Rectangle(); protected final Rectangle dragRect = new Rectangle();
protected Color dragBorderColor; protected Color dragBorderColor;
protected Color dropBackground; protected Color dropBackground;

40
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java

@ -303,7 +303,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
protected void uninstallKeyboardActions() { protected void uninstallKeyboardActions() {
SwingUtilities.replaceUIActionMap(tabPane, null); SwingUtilities.replaceUIActionMap(tabPane, null);
SwingUtilities.replaceUIInputMap(tabPane, JComponent. SwingUtilities.replaceUIInputMap(tabPane, JComponent.
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
null); null);
SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_FOCUSED, SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_FOCUSED,
null); null);
@ -440,7 +440,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
return baseline; return baseline;
case JTabbedPane.BOTTOM: case JTabbedPane.BOTTOM:
baseline = height - insets.bottom - baseline = height - insets.bottom -
tabAreaInsets.bottom - maxTabHeight + baseline; tabAreaInsets.bottom - maxTabHeight + baseline;
return baseline; return baseline;
} }
} }
@ -455,7 +455,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
* @since 1.6 * @since 1.6
*/ */
public Component.BaselineResizeBehavior getBaselineResizeBehavior( public Component.BaselineResizeBehavior getBaselineResizeBehavior(
final JComponent c) { final JComponent c) {
super.getBaselineResizeBehavior(c); super.getBaselineResizeBehavior(c);
switch (tabPane.getTabPlacement()) { switch (tabPane.getTabPlacement()) {
case JTabbedPane.LEFT: case JTabbedPane.LEFT:
@ -508,7 +508,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
int tabCount = tabPane.getTabCount(); int tabCount = tabPane.getTabCount();
Rectangle iconRect = new Rectangle(), Rectangle iconRect = new Rectangle(),
textRect = new Rectangle(); textRect = new Rectangle();
Rectangle clipRect = g.getClipBounds(); Rectangle clipRect = g.getClipBounds();
// Paint tabRuns of tabs from back to front // Paint tabRuns of tabs from back to front
@ -812,7 +812,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
Rectangle tabRect = rects[tabIndex]; Rectangle tabRect = rects[tabIndex];
String propKey = (isSelected ? "selectedLabelShift" : "labelShift"); String propKey = (isSelected ? "selectedLabelShift" : "labelShift");
int nudge = DefaultLookup.getInt( int nudge = DefaultLookup.getInt(
tabPane, this, "TabbedPane." + propKey, 1); tabPane, this, "TabbedPane." + propKey, 1);
switch (tabPlacement) { switch (tabPlacement) {
case LEFT: case LEFT:
@ -950,10 +950,10 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
*/ */
protected void installKeyboardActions() { protected void installKeyboardActions() {
InputMap km = getInputMap(JComponent. InputMap km = getInputMap(JComponent.
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
SwingUtilities.replaceUIInputMap(tabPane, JComponent. SwingUtilities.replaceUIInputMap(tabPane, JComponent.
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
km); km);
km = getInputMap(JComponent.WHEN_FOCUSED); km = getInputMap(JComponent.WHEN_FOCUSED);
SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_FOCUSED, km); SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_FOCUSED, km);
@ -1063,7 +1063,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
mnemonicInputMap.put(KeyStroke.getKeyStroke(mnemonic, DarkUIUtil.getFocusAcceleratorKeyMask()), mnemonicInputMap.put(KeyStroke.getKeyStroke(mnemonic, DarkUIUtil.getFocusAcceleratorKeyMask()),
"setSelectedIndex"); "setSelectedIndex");
mnemonicInputMap.put(KeyStroke.getKeyStroke(mnemonic, InputEvent.ALT_GRAPH_DOWN_MASK mnemonicInputMap.put(KeyStroke.getKeyStroke(mnemonic, InputEvent.ALT_GRAPH_DOWN_MASK
| DarkUIUtil.getFocusAcceleratorKeyMask()), | DarkUIUtil.getFocusAcceleratorKeyMask()),
"setSelectedIndex"); "setSelectedIndex");
mnemonicToIndexMap.put(mnemonic, index); mnemonicToIndexMap.put(mnemonic, index);
} }
@ -1253,16 +1253,16 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
Insets tabInsets = getTabInsets(tabPane.getTabPlacement(), tab); Insets tabInsets = getTabInsets(tabPane.getTabPlacement(), tab);
int cellHeight = maxTabHeight - tabInsets.top - tabInsets.bottom; int cellHeight = maxTabHeight - tabInsets.top - tabInsets.bottom;
return c.getBaseline(pref.width, pref.height) + return c.getBaseline(pref.width, pref.height) +
(cellHeight - pref.height) / 2 + tabInsets.top; (cellHeight - pref.height) / 2 + tabInsets.top;
} else { } else {
View view = getTextViewForTab(tab); View view = getTextViewForTab(tab);
if (view != null) { if (view != null) {
int viewHeight = (int) view.getPreferredSpan(View.Y_AXIS); int viewHeight = (int) view.getPreferredSpan(View.Y_AXIS);
int baseline = BasicHTML.getHTMLBaseline( int baseline = BasicHTML.getHTMLBaseline(
view, (int) view.getPreferredSpan(View.X_AXIS), viewHeight); view, (int) view.getPreferredSpan(View.X_AXIS), viewHeight);
if (baseline >= 0) { if (baseline >= 0) {
return maxTabHeight / 2 - viewHeight / 2 + baseline + return maxTabHeight / 2 - viewHeight / 2 + baseline +
getBaselineOffset(); getBaselineOffset();
} }
return -1; return -1;
} }
@ -1271,7 +1271,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
int fontHeight = metrics.getHeight(); int fontHeight = metrics.getHeight();
int fontBaseline = metrics.getAscent(); int fontBaseline = metrics.getAscent();
return maxTabHeight / 2 - fontHeight / 2 + fontBaseline + return maxTabHeight / 2 - fontHeight / 2 + fontBaseline +
getBaselineOffset(); getBaselineOffset();
} }
/** /**
@ -1621,7 +1621,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
int tabRunOverlay = getTabRunOverlay(tabPlacement); int tabRunOverlay = getTabRunOverlay(tabPlacement);
return (horizRunCount > 0 ? return (horizRunCount > 0 ?
horizRunCount * (maxTabHeight - tabRunOverlay) + tabRunOverlay + horizRunCount * (maxTabHeight - tabRunOverlay) + tabRunOverlay +
tabAreaInsets.top + tabAreaInsets.bottom : tabAreaInsets.top + tabAreaInsets.bottom :
0); 0);
} }
@ -1638,7 +1638,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
int tabRunOverlay = getTabRunOverlay(tabPlacement); int tabRunOverlay = getTabRunOverlay(tabPlacement);
return (vertRunCount > 0 ? return (vertRunCount > 0 ?
vertRunCount * (maxTabWidth - tabRunOverlay) + tabRunOverlay + vertRunCount * (maxTabWidth - tabRunOverlay) + tabRunOverlay +
tabAreaInsets.left + tabAreaInsets.right : tabAreaInsets.left + tabAreaInsets.right :
0); 0);
} }
@ -2215,9 +2215,9 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
*/ */
protected void setVisibleComponent(final Component component) { protected void setVisibleComponent(final Component component) {
if (visibleComponent != null if (visibleComponent != null
&& visibleComponent != component && visibleComponent != component
&& visibleComponent.getParent() == tabPane && visibleComponent.getParent() == tabPane
&& visibleComponent.isVisible()) { && visibleComponent.isVisible()) {
visibleComponent.setVisible(false); visibleComponent.setVisible(false);
} }
@ -2271,7 +2271,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
* The Request focus for visible. * The Request focus for visible.
*/ */
static final String REQUEST_FOCUS_FOR_VISIBLE = static final String REQUEST_FOCUS_FOR_VISIBLE =
"requestFocusForVisibleComponent"; "requestFocusForVisibleComponent";
/** /**
* The Set selected. * The Set selected.
*/ */
@ -2302,8 +2302,8 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
String key = getName(); String key = getName();
JTabbedPane pane = (JTabbedPane) e.getSource(); JTabbedPane pane = (JTabbedPane) e.getSource();
DarkTabbedPaneUIBridge ui = (DarkTabbedPaneUIBridge) DarkUIUtil DarkTabbedPaneUIBridge ui = (DarkTabbedPaneUIBridge) DarkUIUtil
.getUIOfType(pane.getUI(), .getUIOfType(pane.getUI(),
DarkTabbedPaneUIBridge.class); DarkTabbedPaneUIBridge.class);
if (ui == null) { if (ui == null) {
return; return;

5
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/MoreTabsButton.java

@ -35,7 +35,7 @@ public class MoreTabsButton extends DarkTabAreaButton {
protected final static String INFINITY = "\u221e"; protected final static String INFINITY = "\u221e";
protected final Icon icon; protected final Icon icon;
protected DarkTabbedPaneUI ui; protected final DarkTabbedPaneUI ui;
protected final int pad; protected final int pad;
public MoreTabsButton(final DarkTabbedPaneUI ui) { public MoreTabsButton(final DarkTabbedPaneUI ui) {
@ -87,7 +87,8 @@ public class MoreTabsButton extends DarkTabAreaButton {
protected String getLabelString() { protected String getLabelString() {
int invisible = Math.min(ui.minVisible - 1 + ui.tabPane.getTabCount() - ui.maxVisible, ui.tabPane.getTabCount()); int invisible = Math.min(ui.minVisible - 1 + ui.tabPane.getTabCount() - ui.maxVisible,
ui.tabPane.getTabCount());
return invisible >= 100 ? INFINITY : String.valueOf(invisible); return invisible >= 100 ? INFINITY : String.valueOf(invisible);
} }

2
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/NewTabButton.java

@ -33,7 +33,7 @@ import java.awt.*;
public class NewTabButton extends JPanel implements UIResource { public class NewTabButton extends JPanel implements UIResource {
protected final JButton button; protected final JButton button;
protected DarkTabbedPaneUI ui; protected final DarkTabbedPaneUI ui;
protected NewTabButton(final DarkTabbedPaneUI ui) { protected NewTabButton(final DarkTabbedPaneUI ui) {
this.ui = ui; this.ui = ui;

2
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabPanel.java

@ -28,7 +28,7 @@ import javax.swing.plaf.UIResource;
import java.awt.*; import java.awt.*;
public class ScrollableTabPanel extends JPanel implements UIResource { public class ScrollableTabPanel extends JPanel implements UIResource {
private DarkTabbedPaneUIBridge ui; private final DarkTabbedPaneUIBridge ui;
public ScrollableTabPanel(final DarkTabbedPaneUIBridge ui) { public ScrollableTabPanel(final DarkTabbedPaneUIBridge ui) {
super(null); super(null);

6
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabSupport.java

@ -46,9 +46,9 @@ class ScrollableTabSupport {
public String toString() { public String toString() {
return "viewport.viewSize=" + viewport.getViewSize() + "\n" + return "viewport.viewSize=" + viewport.getViewSize() + "\n" +
"viewport.viewRectangle=" + viewport.getViewRect() + "\n" + "viewport.viewRectangle=" + viewport.getViewRect() + "\n" +
"leadingTabIndex=" + leadingTabIndex + "\n" + "leadingTabIndex=" + leadingTabIndex + "\n" +
"tabViewPosition=" + tabViewPosition; "tabViewPosition=" + tabViewPosition;
} }
} }

2
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/ScrollableTabViewport.java

@ -28,7 +28,7 @@ import javax.swing.plaf.UIResource;
import java.awt.*; import java.awt.*;
@SuppressWarnings("serial") @SuppressWarnings("serial")
// Superclass is not serializable across versions // Superclass is not serializable across versions
class ScrollableTabViewport extends JViewport implements UIResource { class ScrollableTabViewport extends JViewport implements UIResource {
public ScrollableTabViewport(final DarkTabbedPaneUIBridge ui) { public ScrollableTabViewport(final DarkTabbedPaneUIBridge ui) {

4
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneHandler.java

@ -39,7 +39,7 @@ import java.beans.PropertyChangeListener;
import java.util.Objects; import java.util.Objects;
public class TabbedPaneHandler implements ChangeListener, ContainerListener, FocusListener, public class TabbedPaneHandler implements ChangeListener, ContainerListener, FocusListener,
MouseListener, MouseMotionListener, PropertyChangeListener { MouseListener, MouseMotionListener, PropertyChangeListener {
private final DarkTabbedPaneUIBridge ui; private final DarkTabbedPaneUIBridge ui;
// //
@ -146,7 +146,7 @@ public class TabbedPaneHandler implements ChangeListener, ContainerListener, Foc
int index = tabPane.getSelectedIndex(); int index = tabPane.getSelectedIndex();
if (index < ui.rects.length && index != -1) { if (index < ui.rects.length && index != -1) {
ui.tabScroller.tabPanel.scrollRectToVisible( ui.tabScroller.tabPanel.scrollRectToVisible(
(Rectangle) ui.rects[index].clone()); (Rectangle) ui.rects[index].clone());
} }
} }
} }

14
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneLayout.java

@ -102,7 +102,7 @@ public class TabbedPaneLayout implements LayoutManager {
// //
if (selectedComponent != null) { if (selectedComponent != null) {
if (selectedComponent != visibleComponent && if (selectedComponent != visibleComponent &&
visibleComponent != null) { visibleComponent != null) {
if (SwingUtilities.findFocusOwner(visibleComponent) != null) { if (SwingUtilities.findFocusOwner(visibleComponent) != null) {
shouldChangeFocus = true; shouldChangeFocus = true;
} }
@ -139,11 +139,11 @@ public class TabbedPaneLayout implements LayoutManager {
} }
cw = bounds.width - totalTabWidth - cw = bounds.width - totalTabWidth -
insets.left - insets.right - insets.left - insets.right -
contentInsets.left - contentInsets.right; contentInsets.left - contentInsets.right;
ch = bounds.height - totalTabHeight - ch = bounds.height - totalTabHeight -
insets.top - insets.bottom - insets.top - insets.bottom -
contentInsets.top - contentInsets.bottom; contentInsets.top - contentInsets.bottom;
for (int i = 0; i < numChildren; i++) { for (int i = 0; i < numChildren; i++) {
Component child = ui.tabPane.getComponent(i); Component child = ui.tabPane.getComponent(i);
@ -151,10 +151,10 @@ public class TabbedPaneLayout implements LayoutManager {
int tabContainerWidth = totalTabWidth == 0 ? bounds.width : int tabContainerWidth = totalTabWidth == 0 ? bounds.width :
totalTabWidth + insets.left + insets.right + totalTabWidth + insets.left + insets.right +
contentInsets.left + contentInsets.right; contentInsets.left + contentInsets.right;
int tabContainerHeight = totalTabHeight == 0 ? bounds.height : int tabContainerHeight = totalTabHeight == 0 ? bounds.height :
totalTabHeight + insets.top + insets.bottom + totalTabHeight + insets.top + insets.bottom +
contentInsets.top + contentInsets.bottom; contentInsets.top + contentInsets.bottom;
int tabContainerX = 0; int tabContainerX = 0;
int tabContainerY = 0; int tabContainerY = 0;

2
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneScrollLayout.java

@ -123,7 +123,7 @@ abstract class TabbedPaneScrollLayout extends TabbedPaneLayout {
// the bottom, flip x positions and adjust by widths // the bottom, flip x positions and adjust by widths
if (!leftToRight && !verticalTabRuns) { if (!leftToRight && !verticalTabRuns) {
int rightMargin = size.width int rightMargin = size.width
- (insets.right + tabAreaInsets.right); - (insets.right + tabAreaInsets.right);
for (i = 0; i < tabCount; i++) { for (i = 0; i < tabCount; i++) {
ui.rects[i].x = rightMargin - ui.rects[i].x - ui.rects[i].width; ui.rects[i].x = rightMargin - ui.rects[i].x - ui.rects[i].width;
} }

27
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneTransferHandler.java

@ -31,19 +31,7 @@ import java.awt.*;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DragGestureEvent; import java.awt.dnd.*;
import java.awt.dnd.DragGestureListener;
import java.awt.dnd.DragGestureRecognizer;
import java.awt.dnd.DragSource;
import java.awt.dnd.DragSourceContext;
import java.awt.dnd.DragSourceDragEvent;
import java.awt.dnd.DragSourceDropEvent;
import java.awt.dnd.DragSourceEvent;
import java.awt.dnd.DragSourceListener;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.DropTargetListener;
import java.awt.event.InputEvent; import java.awt.event.InputEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -81,10 +69,10 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa
// only mouse events supported for drag operations // only mouse events supported for drag operations
if (!(e instanceof MouseEvent) if (!(e instanceof MouseEvent)
// only support known actions // only support known actions
|| !(action == COPY || action == MOVE || action == LINK) || !(action == COPY || action == MOVE || action == LINK)
// only support valid source actions // only support valid source actions
|| (srcActions & action) == 0) { || (srcActions & action) == 0) {
action = NONE; action = NONE;
} }
@ -177,7 +165,7 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa
createDragImage(tabPane, null); createDragImage(tabPane, null);
} }
if ((ui != null && !ui.scrollableTabLayoutEnabled()) if ((ui != null && !ui.scrollableTabLayoutEnabled())
|| tabPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT) { || tabPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT) {
tabPane.setSelectedIndex(currentTransferable.transferData.tabIndex); tabPane.setSelectedIndex(currentTransferable.transferData.tabIndex);
} }
return currentTransferable; return currentTransferable;
@ -260,7 +248,8 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa
} }
Rectangle dropRect = TabbedPaneUtil.getDropRect(supportsIndicator(destTabbedPane), destTabbedPane, Rectangle dropRect = TabbedPaneUtil.getDropRect(supportsIndicator(destTabbedPane), destTabbedPane,
t.transferData.sourceTabbedPane, mouseLocation, t.transferData.sourceTabbedPane, mouseLocation,
t.getTabBounds(), tab, t.transferData.tabIndex, lastTab); t.getTabBounds(), tab, t.transferData.tabIndex,
lastTab);
ui.setDnDIndicatorRect(dropRect.x, dropRect.y, dropRect.width, dropRect.height, ui.setDnDIndicatorRect(dropRect.x, dropRect.y, dropRect.width, dropRect.height,
tab, t.transferData.sourceTabbedPane == destTabbedPane); tab, t.transferData.sourceTabbedPane == destTabbedPane);
lastTab = tab; lastTab = tab;

10
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneUtil.java

@ -124,17 +124,19 @@ public class TabbedPaneUtil implements SwingConstants {
calculateDropRectScrollLayout(destTabbedPane, source, tabBounds, tab, sourceIndex, calculateDropRectScrollLayout(destTabbedPane, source, tabBounds, tab, sourceIndex,
lastTab, tabPlacement, destRect); lastTab, tabPlacement, destRect);
} else { } else {
calculateDropRectWrapLayout(ui, destTabbedPane, source, mouseLocation, tabBounds, tab, sourceIndex, destRect); calculateDropRectWrapLayout(ui, destTabbedPane, source, mouseLocation, tabBounds, tab, sourceIndex,
destRect);
} }
return tabBounds; return tabBounds;
} }
private static void calculateDropRectScrollLayout(final JTabbedPane destTabbedPane, final JTabbedPane source, private static void calculateDropRectScrollLayout(final JTabbedPane destTabbedPane, final JTabbedPane source,
final Rectangle tabBounds, final int tab, final int sourceIndex, final Rectangle tabBounds, final int tab, final int sourceIndex,
final int lastTab, final int tabPlacement, final Rectangle destRect) { final int lastTab, final int tabPlacement,
final Rectangle destRect) {
boolean lastInSource = false; boolean lastInSource = false;
if (destTabbedPane == source && (tab == sourceIndex || (sourceIndex == source.getTabCount() - 1 if (destTabbedPane == source && (tab == sourceIndex || (sourceIndex == source.getTabCount() - 1
&& tab == source.getTabCount()))) { && tab == source.getTabCount()))) {
lastInSource = true; lastInSource = true;
destRect.width = tabBounds.width; destRect.width = tabBounds.width;
destRect.height = tabBounds.height; destRect.height = tabBounds.height;
@ -207,7 +209,7 @@ public class TabbedPaneUtil implements SwingConstants {
tabBounds.width = Math.min(tabBounds.width / 2, destRect.width / 2); tabBounds.width = Math.min(tabBounds.width / 2, destRect.width / 2);
} else { } else {
if (destRect.y + destRect.height <= mouseLocation.y if (destRect.y + destRect.height <= mouseLocation.y
&& prev.y <= mouseLocation.y && mouseLocation.y <= prev.y + prev.height) { && prev.y <= mouseLocation.y && mouseLocation.y <= prev.y + prev.height) {
destRect.x = prev.x + prev.width; destRect.x = prev.x + prev.width;
destRect.y = prev.y; destRect.y = prev.y;
destRect.height = prev.height; destRect.height = prev.height;

3
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java

@ -357,7 +357,8 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe
if (focusOwner instanceof JRootPane) return; if (focusOwner instanceof JRootPane) return;
boolean focus = DarkUIUtil.hasFocus(popupComponent); boolean focus = DarkUIUtil.hasFocus(popupComponent);
if (popupComponent.getTabFrame() != null) { if (popupComponent.getTabFrame() != null) {
Container container = popupComponent.getTabFrame().getContentPane().getContainer(popupComponent.getAlignment()); Container container = popupComponent.getTabFrame().getContentPane().getContainer(
popupComponent.getAlignment());
focus = focus || DarkUIUtil.hasFocus(container); focus = focus || DarkUIUtil.hasFocus(container);
} }
setHeaderBackground(focus); setHeaderBackground(focus);

2
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameComponentPopupMenu.java

@ -37,7 +37,7 @@ import java.beans.PropertyChangeListener;
public class DarkTabFrameComponentPopupMenu extends JXPopupMenu implements PropertyChangeListener, UIResource { public class DarkTabFrameComponentPopupMenu extends JXPopupMenu implements PropertyChangeListener, UIResource {
private final TabFrameTab tab; private final TabFrameTab tab;
private JMenuItem[] actions; private final JMenuItem[] actions;
private int disabled = -1; private int disabled = -1;
public DarkTabFrameComponentPopupMenu(final TabFrameTab tab) { public DarkTabFrameComponentPopupMenu(final TabFrameTab tab) {

2
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java

@ -66,7 +66,7 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang
private Color selectedFontColor; private Color selectedFontColor;
private Color selectedColor; private Color selectedColor;
private Color hoverColor; private Color hoverColor;
private RotatableIcon rotatableIcon = new RotatableIcon(); private final RotatableIcon rotatableIcon = new RotatableIcon();
private boolean printing; private boolean printing;

2
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameUI.java

@ -67,7 +67,7 @@ public class DarkTabFrameUI extends TabFrameUI implements AWTEventListener {
private TabFrameLayout layout; private TabFrameLayout layout;
private int tabHeight; private int tabHeight;
private Color dragBorderColor; private Color dragBorderColor;
private Dimension dropSize = new Dimension(); private final Dimension dropSize = new Dimension();
private Alignment sourceAlign; private Alignment sourceAlign;
private int sourceIndex; private int sourceIndex;
private Alignment destAlign; private Alignment destAlign;

4
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabDragListener.java

@ -52,6 +52,7 @@ public class TabDragListener extends MouseAdapter {
origin = null; origin = null;
} }
@SuppressWarnings("unchecked")
@Override @Override
public void mouseDragged(final MouseEvent e) { public void mouseDragged(final MouseEvent e) {
if (origin == null) origin = e.getPoint(); if (origin == null) origin = e.getPoint();
@ -60,7 +61,8 @@ public class TabDragListener extends MouseAdapter {
if (th != null && tabComponent.getTabFrame().isDndEnabled()) { if (th != null && tabComponent.getTabFrame().isDndEnabled()) {
Point p = e.getPoint(); Point p = e.getPoint();
p = SwingXUtilities.convertPointToParent(tabComponent.getComponent(), p); p = SwingXUtilities.convertPointToParent(tabComponent.getComponent(), p);
JXLayer layer = DarkUIUtil.getParentOfType(JXLayer.class, tabComponent.getComponent()); JXLayer<? extends JComponent> layer = DarkUIUtil.getParentOfType(JXLayer.class,
tabComponent.getComponent());
p = SwingUtilities.convertPoint(layer != null ? layer : tabComponent.getComponent().getParent(), p = SwingUtilities.convertPoint(layer != null ? layer : tabComponent.getComponent().getParent(),
p, tabComponent.getTabFrame()); p, tabComponent.getTabFrame());
tabComponent.getTabFrame().initTransfer(tabComponent.getOrientation(), tabComponent.getIndex()); tabComponent.getTabFrame().initTransfer(tabComponent.getOrientation(), tabComponent.getIndex());

17
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameLayout.java

@ -37,9 +37,9 @@ import java.util.Arrays;
public class TabFrameLayout implements LayoutManager { public class TabFrameLayout implements LayoutManager {
private final JTabFrame tabFrame; private final JTabFrame tabFrame;
private DarkTabFrameUI ui; private final DarkTabFrameUI ui;
private int[] shift; private final int[] shift;
private boolean[] draggedOver; private final boolean[] draggedOver;
private int topHeight; private int topHeight;
private int leftHeight; private int leftHeight;
private int rightHeight; private int rightHeight;
@ -66,9 +66,9 @@ public class TabFrameLayout implements LayoutManager {
public Dimension preferredLayoutSize(final Container parent) { public Dimension preferredLayoutSize(final Container parent) {
Dimension b = tabFrame.getContentPane().getComponent().getPreferredSize(); Dimension b = tabFrame.getContentPane().getComponent().getPreferredSize();
return new Dimension(tabFrame.getLeftTabContainer().getWidth() return new Dimension(tabFrame.getLeftTabContainer().getWidth()
+ tabFrame.getRightTabContainer().getWidth() + b.width, + tabFrame.getRightTabContainer().getWidth() + b.width,
tabFrame.getTopTabContainer().getHeight() tabFrame.getTopTabContainer().getHeight()
+ tabFrame.getBottomTabContainer().getHeight() + b.height); + tabFrame.getBottomTabContainer().getHeight() + b.height);
} }
@ -76,9 +76,9 @@ public class TabFrameLayout implements LayoutManager {
public Dimension minimumLayoutSize(final Container parent) { public Dimension minimumLayoutSize(final Container parent) {
Dimension b = tabFrame.getContentPane().getComponent().getMinimumSize(); Dimension b = tabFrame.getContentPane().getComponent().getMinimumSize();
return new Dimension(tabFrame.getLeftTabContainer().getWidth() return new Dimension(tabFrame.getLeftTabContainer().getWidth()
+ tabFrame.getRightTabContainer().getWidth() + b.width, + tabFrame.getRightTabContainer().getWidth() + b.width,
tabFrame.getTopTabContainer().getHeight() tabFrame.getTopTabContainer().getHeight()
+ tabFrame.getBottomTabContainer().getHeight() + b.height); + tabFrame.getBottomTabContainer().getHeight() + b.height);
} }
@Override @Override
@ -230,7 +230,8 @@ public class TabFrameLayout implements LayoutManager {
int size = rightSize > 0 ? rightHeight : tabFrame.getTabSize(); int size = rightSize > 0 ? rightHeight : tabFrame.getTabSize();
int height = dim.height - topPane.getHeight() - bottomPane.getHeight(); int height = dim.height - topPane.getHeight() - bottomPane.getHeight();
rightPane.setBounds(dim.width - rightHeight, topPane.getHeight(), size, height + (height % 2)); rightPane.setBounds(dim.width - rightHeight, topPane.getHeight(), size, height + (height % 2));
tabFrame.getRightTabContainer().setPreferredSize(new Dimension(rightPane.getHeight(), rightPane.getWidth())); tabFrame.getRightTabContainer().setPreferredSize(
new Dimension(rightPane.getHeight(), rightPane.getWidth()));
tabFrame.getRightTabContainer().setSize(tabFrame.getRightTabContainer().getPreferredSize()); tabFrame.getRightTabContainer().setSize(tabFrame.getRightTabContainer().getPreferredSize());
if (rightSize > 0) { if (rightSize > 0) {
Point start = new Point(0, 0); Point start = new Point(0, 0);

13
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameTransferHandler.java

@ -46,7 +46,7 @@ import java.awt.event.MouseEvent;
public class TabFrameTransferHandler extends TransferHandler implements DropTargetListener, SwingConstants { public class TabFrameTransferHandler extends TransferHandler implements DropTargetListener, SwingConstants {
private static final String MIME_TYPE = DataFlavor.javaJVMLocalObjectMimeType private static final String MIME_TYPE = DataFlavor.javaJVMLocalObjectMimeType
+ ";class=com.github.weisj.darklaf.components.tabframe.JTabFrame"; + ";class=com.github.weisj.darklaf.components.tabframe.JTabFrame";
private static TabbedPaneDragGestureRecognizer recognizer = null; private static TabbedPaneDragGestureRecognizer recognizer = null;
private final Timer timer; private final Timer timer;
private final Timer startTimer; private final Timer startTimer;
@ -70,7 +70,8 @@ public class TabFrameTransferHandler extends TransferHandler implements DropTarg
if (lastTabFrame != null) { if (lastTabFrame != null) {
Point p = MouseInfo.getPointerInfo().getLocation(); Point p = MouseInfo.getPointerInfo().getLocation();
SwingUtilities.convertPointFromScreen(p, lastTabFrame); SwingUtilities.convertPointFromScreen(p, lastTabFrame);
DropTargetDragEvent evt = new DropTargetDragEvent(lastTabFrame.getDropTarget().getDropTargetContext(), p, MOVE, MOVE); DropTargetDragEvent evt = new DropTargetDragEvent(lastTabFrame.getDropTarget().getDropTargetContext(),
p, MOVE, MOVE);
dragOver(evt); dragOver(evt);
} }
}); });
@ -102,10 +103,10 @@ public class TabFrameTransferHandler extends TransferHandler implements DropTarg
// only mouse events supported for drag operations // only mouse events supported for drag operations
if (!(e instanceof MouseEvent) if (!(e instanceof MouseEvent)
// only support known actions // only support known actions
|| !(action == COPY || action == MOVE || action == LINK) || !(action == COPY || action == MOVE || action == LINK)
// only support valid source actions // only support valid source actions
|| (srcActions & action) == 0) { || (srcActions & action) == 0) {
action = NONE; action = NONE;
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save