Browse Source

Updated code style

- Keep simple if in one line.
- Wrap enum declarations if necessary.
pull/214/head
weisj 4 years ago
parent
commit
ae473cb7a1
  1. 3
      core/src/main/java/com/github/weisj/darklaf/DarkLaf.java
  2. 24
      core/src/main/java/com/github/weisj/darklaf/LafManager.java
  3. 3
      core/src/main/java/com/github/weisj/darklaf/components/ClosableTabComponent.java
  4. 3
      core/src/main/java/com/github/weisj/darklaf/components/ClosableTabbedPane.java
  5. 6
      core/src/main/java/com/github/weisj/darklaf/components/ColorPipetteBase.java
  6. 3
      core/src/main/java/com/github/weisj/darklaf/components/ColoredRadioButton.java
  7. 3
      core/src/main/java/com/github/weisj/darklaf/components/DefaultButton.java
  8. 3
      core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java
  9. 3
      core/src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java
  10. 9
      core/src/main/java/com/github/weisj/darklaf/components/RotatableIconAnimator.java
  11. 18
      core/src/main/java/com/github/weisj/darklaf/components/border/DarkBorders.java
  12. 6
      core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java
  13. 15
      core/src/main/java/com/github/weisj/darklaf/components/color/PopupColorChooser.java
  14. 6
      core/src/main/java/com/github/weisj/darklaf/components/color/QuickColorChooser.java
  15. 15
      core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java
  16. 6
      core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTree.java
  17. 3
      core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTreeModel.java
  18. 30
      core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTreeNode.java
  19. 3
      core/src/main/java/com/github/weisj/darklaf/components/filetree/WatchFileTree.java
  20. 12
      core/src/main/java/com/github/weisj/darklaf/components/filetree/WatchFileTreeModel.java
  21. 3
      core/src/main/java/com/github/weisj/darklaf/components/loading/LoadingIndicator.java
  22. 21
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java
  23. 3
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java
  24. 9
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabContainer.java
  25. 12
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabLabel.java
  26. 3
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabbedPopup.java
  27. 3
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/ToggleSplitPane.java
  28. 9
      core/src/main/java/com/github/weisj/darklaf/components/text/LineHighlighter.java
  29. 9
      core/src/main/java/com/github/weisj/darklaf/components/text/NumberingPane.java
  30. 6
      core/src/main/java/com/github/weisj/darklaf/components/text/TextFieldHistoryPopup.java
  31. 3
      core/src/main/java/com/github/weisj/darklaf/components/togglebuttonlist/JToggleButtonList.java
  32. 24
      core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java
  33. 6
      core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipStyle.java
  34. 3
      core/src/main/java/com/github/weisj/darklaf/components/tree/TristateTreeNode.java
  35. 6
      core/src/main/java/com/github/weisj/darklaf/components/treetable/JTreeTable.java
  36. 3
      core/src/main/java/com/github/weisj/darklaf/components/treetable/model/DefaultTreeTableModel.java
  37. 6
      core/src/main/java/com/github/weisj/darklaf/components/treetable/model/TreeTableNode.java
  38. 6
      core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateButtonModel.java
  39. 3
      core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBox.java
  40. 3
      core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBoxMenuItem.java
  41. 9
      core/src/main/java/com/github/weisj/darklaf/graphics/Animator.java
  42. 6
      core/src/main/java/com/github/weisj/darklaf/graphics/GraphicsUtil.java
  43. 6
      core/src/main/java/com/github/weisj/darklaf/graphics/StringPainter.java
  44. 6
      core/src/main/java/com/github/weisj/darklaf/listener/UIUpdater.java
  45. 3
      core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java
  46. 3
      core/src/main/java/com/github/weisj/darklaf/platform/ThemePreferencesHandler.java
  47. 15
      core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java
  48. 24
      core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsPanel.java
  49. 12
      core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java
  50. 24
      core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java
  51. 3
      core/src/main/java/com/github/weisj/darklaf/task/UserPreferenceAdjustmentTask.java
  52. 15
      core/src/main/java/com/github/weisj/darklaf/ui/DarkPopupFactory.java
  53. 9
      core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java
  54. 15
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java
  55. 24
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java
  56. 6
      core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java
  57. 27
      core/src/main/java/com/github/weisj/darklaf/ui/cell/hint/CellHintPopupListener.java
  58. 18
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorTriangle.java
  59. 12
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java
  60. 3
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkPreviewPanel.java
  61. 6
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/RecentSwatchPanel.java
  62. 6
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SlideComponent.java
  63. 9
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SwatchPanel.java
  64. 6
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java
  65. 18
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java
  66. 3
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java
  67. 9
      core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUI.java
  68. 3
      core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameUI.java
  69. 6
      core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java
  70. 3
      core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java
  71. 6
      core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java
  72. 6
      core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuUI.java
  73. 39
      core/src/main/java/com/github/weisj/darklaf/ui/menu/MenuItemLayoutDelegate.java
  74. 18
      core/src/main/java/com/github/weisj/darklaf/ui/numberingpane/DarkNumberingPaneUI.java
  75. 3
      core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneBorder.java
  76. 3
      core/src/main/java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java
  77. 3
      core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuUI.java
  78. 3
      core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/EventHelperUtil.java
  79. 12
      core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabberUtil.java
  80. 6
      core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/PopupMenuContainer.java
  81. 21
      core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java
  82. 6
      core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarListener.java
  83. 3
      core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java
  84. 24
      core/src/main/java/com/github/weisj/darklaf/ui/separator/DarkSeparatorUI.java
  85. 3
      core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java
  86. 6
      core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java
  87. 3
      core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java
  88. 18
      core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DividerStyle.java
  89. 3
      core/src/main/java/com/github/weisj/darklaf/ui/splitpane/ThinSplitPaneDivider.java
  90. 12
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabSupport.java
  91. 6
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneHandler.java
  92. 18
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneScrollLayout.java
  93. 24
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java
  94. 12
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java
  95. 3
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneLayout.java
  96. 3
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneTransferHandler.java
  97. 12
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneUtil.java
  98. 15
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java
  99. 18
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java
  100. 21
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java
  101. Some files were not shown because too many files have changed in this diff Show More

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

@ -129,8 +129,7 @@ public class DarkLaf extends ThemedLookAndFeel {
LafManager.setTheme(currentTheme); LafManager.setTheme(currentTheme);
} }
for (DefaultsInitTask task : INIT_TASKS) { for (DefaultsInitTask task : INIT_TASKS) {
if (task.onlyDuringInstallation() && !isInitialized) if (task.onlyDuringInstallation() && !isInitialized) continue;
continue;
task.run(currentTheme, defaults); task.run(currentTheme, defaults);
} }
return defaults; return defaults;

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

@ -131,8 +131,7 @@ public final class LafManager {
*/ */
public static void enabledPreferenceChangeReporting(final boolean enabled) { public static void enabledPreferenceChangeReporting(final boolean enabled) {
ThemePreferencesHandler.getSharedInstance().enablePreferenceChangeReporting(enabled); ThemePreferencesHandler.getSharedInstance().enablePreferenceChangeReporting(enabled);
if (ThemeSettings.isInitialized()) if (ThemeSettings.isInitialized()) ThemeSettings.getInstance().setSystemPreferencesEnabled(enabled);
ThemeSettings.getInstance().setSystemPreferencesEnabled(enabled);
} }
/** /**
@ -208,8 +207,7 @@ public final class LafManager {
* @see PreferredThemeStyle * @see PreferredThemeStyle
*/ */
public static ThemeProvider getThemeProvider() { public static ThemeProvider getThemeProvider() {
if (themeProvider == null) if (themeProvider == null) themeProvider = createDefaultThemeProvider();
themeProvider = createDefaultThemeProvider();
return themeProvider; return themeProvider;
} }
@ -247,8 +245,7 @@ public final class LafManager {
* @param themes the themes to register. * @param themes the themes to register.
*/ */
public static void registerTheme(final Theme... themes) { public static void registerTheme(final Theme... themes) {
if (themes == null) if (themes == null) return;
return;
for (Theme theme : themes) { for (Theme theme : themes) {
registerTheme(theme); registerTheme(theme);
} }
@ -376,8 +373,7 @@ public final class LafManager {
eventSupport.dispatchEvent(new ThemeChangeEvent(old, theme), ThemeChangeListener::themeChanged); eventSupport.dispatchEvent(new ThemeChangeEvent(old, theme), ThemeChangeListener::themeChanged);
LOGGER.fine(() -> "Setting theme to " + theme); LOGGER.fine(() -> "Setting theme to " + theme);
} }
if (ThemeSettings.isInitialized()) if (ThemeSettings.isInitialized()) ThemeSettings.getInstance().refresh();
ThemeSettings.getInstance().refresh();
} }
/** /**
@ -416,8 +412,7 @@ public final class LafManager {
* @param theme the theme to install. * @param theme the theme to install.
*/ */
public static void installTheme(final Theme theme) { public static void installTheme(final Theme theme) {
if (theme == getTheme() && isInstalled()) if (theme == getTheme() && isInstalled()) return;
return;
setTheme(theme); setTheme(theme);
install(); install();
} }
@ -529,15 +524,12 @@ public final class LafManager {
* @return the closes match. NonNull. * @return the closes match. NonNull.
*/ */
public static Theme getClosestMatchForTheme(final Theme theme) { public static Theme getClosestMatchForTheme(final Theme theme) {
if (theme == null) if (theme == null) return themeForPreferredStyle(null);
return themeForPreferredStyle(null);
for (Theme registered : getRegisteredThemes()) { for (Theme registered : getRegisteredThemes()) {
if (registered.equals(theme)) if (registered.equals(theme)) return registered;
return registered;
} }
for (Theme registered : getRegisteredThemes()) { for (Theme registered : getRegisteredThemes()) {
if (registered.getThemeClass().equals(theme.getThemeClass())) if (registered.getThemeClass().equals(theme.getThemeClass())) return registered;
return registered;
} }
return themeForPreferredStyle(null); return themeForPreferredStyle(null);
} }

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

@ -168,8 +168,7 @@ public class ClosableTabComponent extends JPanel {
int tabCount = tabComponent.pane.getTabCount(); int tabCount = tabComponent.pane.getTabCount();
for (int i = tabCount - 1; i >= 0; i--) { for (int i = tabCount - 1; i >= 0; i--) {
Component tabComp = tabComponent.pane.getTabComponentAt(i); Component tabComp = tabComponent.pane.getTabComponentAt(i);
if (tabComp == tabComponent) if (tabComp == tabComponent) continue;
continue;
if (tabComp instanceof ClosableTabComponent && ((ClosableTabComponent) tabComp).isClosable()) { if (tabComp instanceof ClosableTabComponent && ((ClosableTabComponent) tabComp).isClosable()) {
tabComponent.pane.removeTabAt(i); tabComponent.pane.removeTabAt(i);
} }

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

@ -85,8 +85,7 @@ public class ClosableTabbedPane extends JTabbedPane {
*/ */
public void setTabClosable(final int index, final boolean closable) { public void setTabClosable(final int index, final boolean closable) {
ClosableTabComponent tab = getClosableTabComponent(index); ClosableTabComponent tab = getClosableTabComponent(index);
if (tab != null) if (tab != null) tab.setClosable(closable);
tab.setClosable(closable);
} }
/** /**

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

@ -145,8 +145,7 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
protected Point updateLocation() { protected Point updateLocation() {
PointerInfo pointerInfo = MouseInfo.getPointerInfo(); PointerInfo pointerInfo = MouseInfo.getPointerInfo();
if (pointerInfo == null) if (pointerInfo == null) return null;
return null;
Point mouseLocation = pointerInfo.getLocation(); Point mouseLocation = pointerInfo.getLocation();
Window pickerWindow = getPickerWindow(); Window pickerWindow = getPickerWindow();
@ -170,8 +169,7 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
@Override @Override
public void eventDispatched(final AWTEvent event) { public void eventDispatched(final AWTEvent event) {
if (pickerWindow == null || !pickerWindow.isVisible()) if (pickerWindow == null || !pickerWindow.isVisible()) return;
return;
switch (event.getID()) { switch (event.getID()) {
case MouseEvent.MOUSE_PRESSED: case MouseEvent.MOUSE_PRESSED:
((MouseEvent) event).consume(); ((MouseEvent) event).consume();

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

@ -82,8 +82,7 @@ public class ColoredRadioButton extends JRadioButton {
private void updateColorUI() { private void updateColorUI() {
ColoredRadioButtonUI ui = DarkUIUtil.getUIOfType(getUI(), ColoredRadioButtonUI.class); ColoredRadioButtonUI ui = DarkUIUtil.getUIOfType(getUI(), ColoredRadioButtonUI.class);
if (ui != null) if (ui != null) ui.setColors(color, focusColor);
ui.setColors(color, focusColor);
repaint(); repaint();
} }

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

@ -40,8 +40,7 @@ public class DefaultButton extends JButton {
@Override @Override
public void addNotify() { public void addNotify() {
super.addNotify(); super.addNotify();
if (requestFocusOnDisplay) if (requestFocusOnDisplay) requestFocusInWindow();
requestFocusInWindow();
SwingUtilities.getRootPane(this).setDefaultButton(this); SwingUtilities.getRootPane(this).setDefaultButton(this);
} }
} }

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

@ -126,8 +126,7 @@ public class DefaultColorPipette extends ColorPipetteBase {
Window pickerWindow = getPickerWindow(); Window pickerWindow = getPickerWindow();
if (pickerWindow != null && pickerWindow.isShowing()) { if (pickerWindow != null && pickerWindow.isShowing()) {
Point mouseLoc = updateLocation(); Point mouseLoc = updateLocation();
if (mouseLoc == null) if (mouseLoc == null) return;
return;
final Color c = getPixelColor(mouseLoc); final Color c = getPixelColor(mouseLoc);
if (!c.equals(getColor()) || !mouseLoc.equals(previousLocation) || force) { if (!c.equals(getColor()) || !mouseLoc.equals(previousLocation) || force) {
setColor(c); setColor(c);

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

@ -177,8 +177,7 @@ public class OverlayScrollPane extends JLayeredPane implements PropertyChangeLis
} }
protected void updateScrollPaneUI() { protected void updateScrollPaneUI() {
if (scrollPane == null) if (scrollPane == null) return;
return;
scrollPane.setLayout(new ScrollLayoutManagerDelegate((ScrollPaneLayout) scrollPane.getLayout()) { scrollPane.setLayout(new ScrollLayoutManagerDelegate((ScrollPaneLayout) scrollPane.getLayout()) {
@Override @Override

9
core/src/main/java/com/github/weisj/darklaf/components/RotatableIconAnimator.java

@ -42,8 +42,7 @@ public class RotatableIconAnimator extends Timer {
public RotatableIconAnimator(final int frames, final RotatableIcon icon, final JComponent parent) { public RotatableIconAnimator(final int frames, final RotatableIcon icon, final JComponent parent) {
super(100, null); super(100, null);
if (icon == null) if (icon == null) throw new IllegalArgumentException("Icon is null");
throw new IllegalArgumentException("Icon is null");
addActionListener(this::onAction); addActionListener(this::onAction);
setRepeats(true); setRepeats(true);
this.icon = icon; this.icon = icon;
@ -52,8 +51,7 @@ public class RotatableIconAnimator extends Timer {
} }
public void resume() { public void resume() {
if (!isRunning()) if (!isRunning()) start();
start();
} }
public void onAction(final ActionEvent e) { public void onAction(final ActionEvent e) {
@ -71,7 +69,6 @@ public class RotatableIconAnimator extends Timer {
} }
public void suspend() { public void suspend() {
if (isRunning()) if (isRunning()) stop();
stop();
} }
} }

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

@ -36,33 +36,27 @@ public final class DarkBorders {
public static Border createLineBorder(final int top, final int left, final int bottom, final int right) { public static Border createLineBorder(final int top, final int left, final int bottom, final int right) {
if (top == 0 && left == 0 && bottom == 0 && right == 0) { if (top == 0 && left == 0 && bottom == 0 && right == 0) {
if (sharedBorderEmpty == null) if (sharedBorderEmpty == null) sharedBorderEmpty = createDarkLineBorder(0, 0, 0, 0);
sharedBorderEmpty = createDarkLineBorder(0, 0, 0, 0);
return sharedBorderEmpty; return sharedBorderEmpty;
} }
if (top == 1 && left == 0 && bottom == 0 && right == 0) { if (top == 1 && left == 0 && bottom == 0 && right == 0) {
if (sharedBorderT == null) if (sharedBorderT == null) sharedBorderT = createDarkLineBorder(1, 0, 0, 0);
sharedBorderT = createDarkLineBorder(1, 0, 0, 0);
return sharedBorderT; return sharedBorderT;
} }
if (top == 0 && left == 1 && bottom == 0 && right == 0) { if (top == 0 && left == 1 && bottom == 0 && right == 0) {
if (sharedBorderL == null) if (sharedBorderL == null) sharedBorderL = createDarkLineBorder(0, 1, 0, 0);
sharedBorderL = createDarkLineBorder(0, 1, 0, 0);
return sharedBorderL; return sharedBorderL;
} }
if (top == 0 && left == 0 && bottom == 1 && right == 0) { if (top == 0 && left == 0 && bottom == 1 && right == 0) {
if (sharedBorderB == null) if (sharedBorderB == null) sharedBorderB = createDarkLineBorder(0, 0, 1, 0);
sharedBorderB = createDarkLineBorder(0, 0, 1, 0);
return sharedBorderB; return sharedBorderB;
} }
if (top == 0 && left == 0 && bottom == 0 && right == 1) { if (top == 0 && left == 0 && bottom == 0 && right == 1) {
if (sharedBorderR == null) if (sharedBorderR == null) sharedBorderR = createDarkLineBorder(0, 0, 0, 1);
sharedBorderR = createDarkLineBorder(0, 0, 0, 1);
return sharedBorderR; return sharedBorderR;
} }
if (top == 1 && left == 1 && bottom == 1 && right == 1) { if (top == 1 && left == 1 && bottom == 1 && right == 1) {
if (sharedBorderTLBR == null) if (sharedBorderTLBR == null) sharedBorderTLBR = createDarkLineBorder(1, 1, 1, 1);
sharedBorderTLBR = createDarkLineBorder(1, 1, 1, 1);
return sharedBorderTLBR; return sharedBorderTLBR;
} }
return createDarkLineBorder(top, left, bottom, right); return createDarkLineBorder(top, left, bottom, right);

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

@ -197,8 +197,7 @@ public class DropShadowBorder implements Border, Serializable {
} }
protected void drawImage(final Graphics g, final Image image, final Point p) { protected void drawImage(final Graphics g, final Image image, final Point p) {
if (p == null) if (p == null) return;
return;
g.drawImage(image, p.x, p.y, null); g.drawImage(image, p.x, p.y, null);
} }
@ -377,8 +376,7 @@ public class DropShadowBorder implements Border, Serializable {
public DropShadowBorder setShadowColor(final Color shadowColor) { public DropShadowBorder setShadowColor(final Color shadowColor) {
this.shadowColor = shadowColor; this.shadowColor = shadowColor;
if (shadowColor == null) if (shadowColor == null) this.shadowColor = Color.BLACK;
this.shadowColor = Color.BLACK;
return this; return this;
} }

15
core/src/main/java/com/github/weisj/darklaf/components/color/PopupColorChooser.java

@ -43,8 +43,7 @@ public class PopupColorChooser extends JToolTip {
protected static ToolTipContext context; protected static ToolTipContext context;
protected SmallColorChooser getChooser(final Color initial, final Consumer<Color> callback) { protected SmallColorChooser getChooser(final Color initial, final Consumer<Color> callback) {
if (chooser == null) if (chooser == null) chooser = new SmallColorChooser(initial, callback);
chooser = new SmallColorChooser(initial, callback);
SmallColorChooser smallColorChooser = chooser; SmallColorChooser smallColorChooser = chooser;
if (chooser.getParent() != null) { if (chooser.getParent() != null) {
// Already in use. Create new one. // Already in use. Create new one.
@ -56,8 +55,7 @@ public class PopupColorChooser extends JToolTip {
} }
protected ToolTipContext getContext() { protected ToolTipContext getContext() {
if (context == null) if (context == null) context = createToolTipContext();
context = createToolTipContext();
return context; return context;
} }
@ -106,8 +104,7 @@ public class PopupColorChooser extends JToolTip {
AWTEventListener listener = event -> { AWTEventListener listener = event -> {
if (event instanceof MouseEvent) { if (event instanceof MouseEvent) {
int id = event.getID(); int id = event.getID();
if (id != MouseEvent.MOUSE_CLICKED && id != MouseEvent.MOUSE_PRESSED) if (id != MouseEvent.MOUSE_CLICKED && id != MouseEvent.MOUSE_PRESSED) return;
return;
} }
boolean doClose = event instanceof FocusEvent && (!(DarkUIUtil.hasFocus(toolTip, (FocusEvent) event) boolean doClose = event instanceof FocusEvent && (!(DarkUIUtil.hasFocus(toolTip, (FocusEvent) event)
|| DarkUIUtil.hasFocus(toolTip) || DarkUIUtil.hasFocus(parent, (FocusEvent) event))); || DarkUIUtil.hasFocus(toolTip) || DarkUIUtil.hasFocus(parent, (FocusEvent) event)));
@ -126,10 +123,8 @@ public class PopupColorChooser extends JToolTip {
close.set(e -> { close.set(e -> {
popup.hide(); popup.hide();
Toolkit.getDefaultToolkit().removeAWTEventListener(listener); Toolkit.getDefaultToolkit().removeAWTEventListener(listener);
if (window != null) if (window != null) window.removeComponentListener(windowListener);
window.removeComponentListener(windowListener); if (onClose != null) onClose.accept(e);
if (onClose != null)
onClose.accept(e);
}); });
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
window.addComponentListener(windowListener); window.addComponentListener(windowListener);

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

@ -83,8 +83,7 @@ public class QuickColorChooser extends JPanel {
final Supplier<Color> supplier, final Supplier<Boolean> activationCheck) { final Supplier<Color> supplier, final Supplier<Boolean> activationCheck) {
AtomicBoolean isShowing = new AtomicBoolean(false); AtomicBoolean isShowing = new AtomicBoolean(false);
component.addMouseListener((MouseClickListener) e -> { component.addMouseListener((MouseClickListener) e -> {
if (!component.isEnabled() || isShowing.get() || !activationCheck.get()) if (!component.isEnabled() || isShowing.get() || !activationCheck.get()) return;
return;
isShowing.set(true); isShowing.set(true);
PopupColorChooser.showColorChooser(component, supplier.get(), c -> { PopupColorChooser.showColorChooser(component, supplier.get(), c -> {
if (c != null) { if (c != null) {
@ -99,8 +98,7 @@ public class QuickColorChooser extends JPanel {
} }
public void setSelected(final boolean selected) { public void setSelected(final boolean selected) {
if (checkBox != null) if (checkBox != null) checkBox.setSelected(selected);
checkBox.setSelected(selected);
} }
public Color getColor() { public Color getColor() {

15
core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java

@ -94,8 +94,7 @@ public class SmallColorChooser extends JPanel {
colorTriangle.addListener((c, o) -> { colorTriangle.addListener((c, o) -> {
previewComponent.setColor(c); previewComponent.setColor(c);
for (DarkColorModel model : COLOR_MODELS) { for (DarkColorModel model : COLOR_MODELS) {
if (o != model) if (o != model) updateMap.get(model).run();
updateMap.get(model).run();
} }
if (o != hexField) { if (o != hexField) {
hexField.setText(ColorUtil.toHex(c)); hexField.setText(ColorUtil.toHex(c));
@ -117,14 +116,12 @@ public class SmallColorChooser extends JPanel {
} }
protected void setColor(final Object source, final DarkColorModel model, final int... values) { protected void setColor(final Object source, final DarkColorModel model, final int... values) {
if (isValueChanging()) if (isValueChanging()) return;
return;
setValueChanging(true); setValueChanging(true);
if (model != null) { if (model != null) {
colorTriangle.setColorFromModel(source, model, values); colorTriangle.setColorFromModel(source, model, values);
} }
if (callback != null) if (callback != null) callback.accept(colorTriangle.getColor());
callback.accept(colorTriangle.getColor());
setValueChanging(false); setValueChanging(false);
} }
@ -259,8 +256,7 @@ public class SmallColorChooser extends JPanel {
label.setValue(String.valueOf(slider.getValue())); label.setValue(String.valueOf(slider.getValue()));
slider.addChangeListener(e -> { slider.addChangeListener(e -> {
if (isValueChanging()) if (isValueChanging()) return;
return;
int[] values = new int[count]; int[] values = new int[count];
for (int j = 0; j < count; j++) { for (int j = 0; j < count; j++) {
values[j] = sliders[j].getValue(); values[j] = sliders[j].getValue();
@ -318,8 +314,7 @@ public class SmallColorChooser extends JPanel {
public void setValue(final String value) { public void setValue(final String value) {
this.value = value; this.value = value;
if (this.value == null) if (this.value == null) this.value = "";
this.value = "";
setText(before + ": " + value + after); setText(before + ": " + value + after);
} }
} }

6
core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTree.java

@ -82,15 +82,13 @@ public class FileTree extends JTree {
public Path getSelectedFile() { public Path getSelectedFile() {
TreePath path = getSelectionPath(); TreePath path = getSelectionPath();
if (path == null) if (path == null) return null;
return null;
return ((FileTreeNode) path.getLastPathComponent()).getFile(); return ((FileTreeNode) path.getLastPathComponent()).getFile();
} }
public List<Path> getSelectedFiles() { public List<Path> getSelectedFiles() {
TreePath[] paths = getSelectionPaths(); TreePath[] paths = getSelectionPaths();
if (paths == null) if (paths == null) return Collections.emptyList();
return Collections.emptyList();
return Arrays.stream(getSelectionPaths()).map(TreePath::getLastPathComponent).map(FileTreeNode.class::cast) return Arrays.stream(getSelectionPaths()).map(TreePath::getLastPathComponent).map(FileTreeNode.class::cast)
.map(FileTreeNode::getFile).collect(Collectors.toList()); .map(FileTreeNode::getFile).collect(Collectors.toList());
} }

3
core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTreeModel.java

@ -72,8 +72,7 @@ public class FileTreeModel extends DefaultTreeModel {
} }
public void setShowHiddenFiles(final boolean showHiddenFiles) { public void setShowHiddenFiles(final boolean showHiddenFiles) {
if (showHiddenFiles == this.showHiddenFiles) if (showHiddenFiles == this.showHiddenFiles) return;
return;
this.showHiddenFiles = showHiddenFiles; this.showHiddenFiles = showHiddenFiles;
reload(); reload();
} }

30
core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTreeNode.java

@ -50,10 +50,8 @@ public class FileTreeNode implements TreeNode, Comparable<FileTreeNode> {
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
if (this == o) if (this == o) return true;
return true; if (o == null || getClass() != o.getClass()) return false;
if (o == null || getClass() != o.getClass())
return false;
FileTreeNode that = (FileTreeNode) o; FileTreeNode that = (FileTreeNode) o;
return Objects.equals(file, that.file); return Objects.equals(file, that.file);
} }
@ -69,8 +67,7 @@ public class FileTreeNode implements TreeNode, Comparable<FileTreeNode> {
private int addSorted(final List<FileTreeNode> nodes, final FileTreeNode node) { private int addSorted(final List<FileTreeNode> nodes, final FileTreeNode node) {
int index = Collections.binarySearch(nodes, node); int index = Collections.binarySearch(nodes, node);
if (index < 0) if (index < 0) index = ~index;
index = ~index;
nodes.add(index, node); nodes.add(index, node);
model.register(node); model.register(node);
return index; return index;
@ -90,10 +87,8 @@ public class FileTreeNode implements TreeNode, Comparable<FileTreeNode> {
} }
protected void reload(final int depth) { protected void reload(final int depth) {
if (depth < 0) if (depth < 0) return;
return; if (children.get() == null) return;
if (children.get() == null)
return;
List<FileTreeNode> fileList = children.get(); List<FileTreeNode> fileList = children.get();
this.<ReloadOp>doInBackground(pub -> { this.<ReloadOp>doInBackground(pub -> {
taskCount.getAndIncrement(); taskCount.getAndIncrement();
@ -131,8 +126,7 @@ public class FileTreeNode implements TreeNode, Comparable<FileTreeNode> {
} }
} }
}, () -> { }, () -> {
if (depth > 0) if (depth > 0) fileList.forEach(n -> n.reload(depth - 1));
fileList.forEach(n -> n.reload(depth - 1));
taskCount.getAndDecrement(); taskCount.getAndDecrement();
}); });
} }
@ -245,15 +239,13 @@ public class FileTreeNode implements TreeNode, Comparable<FileTreeNode> {
} }
public boolean isNodeChild(final TreeNode aNode) { public boolean isNodeChild(final TreeNode aNode) {
if (aNode == null) if (aNode == null) return false;
return false;
return (aNode.getParent() == this); return (aNode.getParent() == this);
} }
@Override @Override
public int compareTo(final FileTreeNode o) { public int compareTo(final FileTreeNode o) {
if (o == null) if (o == null) return -1;
return -1;
boolean thisDir = Files.isDirectory(file); boolean thisDir = Files.isDirectory(file);
boolean oDir = Files.isDirectory(o.file); boolean oDir = Files.isDirectory(o.file);
if (thisDir == oDir) { if (thisDir == oDir) {
@ -289,8 +281,7 @@ public class FileTreeNode implements TreeNode, Comparable<FileTreeNode> {
@Override @Override
protected void reload(final int depth) { protected void reload(final int depth) {
if (depth < 0) if (depth < 0) return;
return;
List<FileTreeNode> nodes = children.get(); List<FileTreeNode> nodes = children.get();
createInitialDirectories().forEach(p -> { createInitialDirectories().forEach(p -> {
FileTreeNode node = model.createNode(this, p); FileTreeNode node = model.createNode(this, p);
@ -307,8 +298,7 @@ public class FileTreeNode implements TreeNode, Comparable<FileTreeNode> {
return false; return false;
}); });
if (depth > 0) if (depth > 0) children.get().forEach(n -> n.reload(depth - 1));
children.get().forEach(n -> n.reload(depth - 1));
} }
@Override @Override

3
core/src/main/java/com/github/weisj/darklaf/components/filetree/WatchFileTree.java

@ -48,8 +48,7 @@ public class WatchFileTree extends FileTree {
@Override @Override
public void setFileTreeModel(final FileTreeModel fileTreeModel) { public void setFileTreeModel(final FileTreeModel fileTreeModel) {
if (getModel() == fileTreeModel) if (getModel() == fileTreeModel) return;
return;
if (getModel() instanceof WatchFileTreeModel) { if (getModel() instanceof WatchFileTreeModel) {
((WatchFileTreeModel) getModel()).stopWatching(); ((WatchFileTreeModel) getModel()).stopWatching();
} }

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

@ -101,8 +101,7 @@ public class WatchFileTreeModel extends FileTreeModel {
} }
public void startWatching() { public void startWatching() {
if (watchTask != null) if (watchTask != null) return;
return;
isScheduled.set(true); isScheduled.set(true);
watchTask = scheduler.schedule(this::watch, 0, TimeUnit.SECONDS); watchTask = scheduler.schedule(this::watch, 0, TimeUnit.SECONDS);
} }
@ -158,10 +157,8 @@ public class WatchFileTreeModel extends FileTreeModel {
protected void register(final FileTreeNode node) { protected void register(final FileTreeNode node) {
synchronized (getLock()) { synchronized (getLock()) {
WatchService ws = getWatchService(); WatchService ws = getWatchService();
if (ws == null || !Files.isDirectory(node.file)) if (ws == null || !Files.isDirectory(node.file)) return;
return; if (getNodeMap().containsKey(node.file)) return;
if (getNodeMap().containsKey(node.file))
return;
try { try {
LOGGER.finer(() -> "Register watch service for \"" + node.file + "\""); LOGGER.finer(() -> "Register watch service for \"" + node.file + "\"");
node.watchKey = node.file.register(ws, StandardWatchEventKinds.ENTRY_CREATE, node.watchKey = node.file.register(ws, StandardWatchEventKinds.ENTRY_CREATE,
@ -174,8 +171,7 @@ public class WatchFileTreeModel extends FileTreeModel {
protected void unregister(final FileTreeNode node) { protected void unregister(final FileTreeNode node) {
synchronized (getLock()) { synchronized (getLock()) {
if (node.watchKey == null) if (node.watchKey == null) return;
return;
LOGGER.finer(() -> "Unregister watch service for \"" + node.file + "\""); LOGGER.finer(() -> "Unregister watch service for \"" + node.file + "\"");
getNodeMap().remove(node.file); getNodeMap().remove(node.file);
node.watchKey.cancel(); node.watchKey.cancel();

3
core/src/main/java/com/github/weisj/darklaf/components/loading/LoadingIndicator.java

@ -79,8 +79,7 @@ public class LoadingIndicator extends JLabel {
} }
private void setAnimatorState(final boolean running) { private void setAnimatorState(final boolean running) {
if (running == animator.isRunning()) if (running == animator.isRunning()) return;
return;
if (running) { if (running) {
animator.resume(); animator.resume();
} else { } else {

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

@ -91,11 +91,9 @@ public class JTabFrame extends JComponent {
protected void updatePopupUIs() { protected void updatePopupUIs() {
if (popupLists != null) { if (popupLists != null) {
for (List<TabFramePopup> list : popupLists) { for (List<TabFramePopup> list : popupLists) {
if (list == null) if (list == null) continue;
continue;
for (TabFramePopup popup : list) { for (TabFramePopup popup : list) {
if (popup == null) if (popup == null) continue;
continue;
popup.updateContentUI(); popup.updateContentUI();
} }
} }
@ -551,11 +549,9 @@ public class JTabFrame extends JComponent {
*/ */
public void toggleTab(final Alignment a, final int index, final boolean enabled) { public void toggleTab(final Alignment a, final int index, final boolean enabled) {
int oldIndex = selectedIndices[a.getIndex()]; int oldIndex = selectedIndices[a.getIndex()];
if (content.isEnabled(a) == enabled && oldIndex == index) if (content.isEnabled(a) == enabled && oldIndex == index) return;
return;
TabFrameTab compAtIndex = getTabComponentAt(a, index); TabFrameTab compAtIndex = getTabComponentAt(a, index);
if (!compAtIndex.isEnabled()) if (!compAtIndex.isEnabled()) return;
return;
compAtIndex.setSelected(enabled); compAtIndex.setSelected(enabled);
notifySelectionChange(compAtIndex); notifySelectionChange(compAtIndex);
setPopupVisibility(compAtIndex, enabled); setPopupVisibility(compAtIndex, enabled);
@ -631,8 +627,7 @@ public class JTabFrame extends JComponent {
* @param c the popup to close. * @param c the popup to close.
*/ */
public void closeTab(final TabFramePopup c) { public void closeTab(final TabFramePopup c) {
if (c == null) if (c == null) return;
return;
closeTab(c.getAlignment(), c.getIndex()); closeTab(c.getAlignment(), c.getIndex());
} }
@ -664,8 +659,7 @@ public class JTabFrame extends JComponent {
* @param c the popup to open. * @param c the popup to open.
*/ */
public void openTab(final TabFramePopup c) { public void openTab(final TabFramePopup c) {
if (c == null) if (c == null) return;
return;
openTab(c.getAlignment(), c.getIndex()); openTab(c.getAlignment(), c.getIndex());
} }
@ -924,8 +918,7 @@ public class JTabFrame extends JComponent {
* @return true if selected. * @return true if selected.
*/ */
public boolean isSelected(final Alignment a, final int index) { public boolean isSelected(final Alignment a, final int index) {
if (a == null) if (a == null) return false;
return false;
return selectedIndices[a.ordinal()] == index; return selectedIndices[a.ordinal()] == index;
} }

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

@ -181,8 +181,7 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
* @param force whether to force the layout process. * @param force whether to force the layout process.
*/ */
public void setEnabled(final Alignment a, final boolean enabled, final boolean force) { public void setEnabled(final Alignment a, final boolean enabled, final boolean force) {
if (enabled == isEnabled(a) && !force) if (enabled == isEnabled(a) && !force) return;
return;
switch (a) { switch (a) {
case NORTH: case NORTH:
changeStatus(enabled, Alignment.NORTH_EAST, topSplit, topSplitter, changeStatus(enabled, Alignment.NORTH_EAST, topSplit, topSplitter,

9
core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabContainer.java

@ -106,8 +106,7 @@ public class TabFrameTabContainer extends JPanel implements TabFrameTab {
@Override @Override
public void setOrientation(final Alignment a) { public void setOrientation(final Alignment a) {
if (this.orientation == a) if (this.orientation == a) return;
return;
Alignment oldOrientation = this.orientation; Alignment oldOrientation = this.orientation;
this.orientation = a; this.orientation = a;
firePropertyChange(KEY_ORIENTATION, oldOrientation, orientation); firePropertyChange(KEY_ORIENTATION, oldOrientation, orientation);
@ -120,8 +119,7 @@ public class TabFrameTabContainer extends JPanel implements TabFrameTab {
@Override @Override
public void setSelected(final boolean selected) { public void setSelected(final boolean selected) {
if (selected == this.selected) if (selected == this.selected) return;
return;
boolean oldSelected = this.selected; boolean oldSelected = this.selected;
this.selected = selected; this.selected = selected;
firePropertyChange(KEY_SELECTED, oldSelected, selected); firePropertyChange(KEY_SELECTED, oldSelected, selected);
@ -134,8 +132,7 @@ public class TabFrameTabContainer extends JPanel implements TabFrameTab {
@Override @Override
public void setAccelerator(final int accelerator) { public void setAccelerator(final int accelerator) {
if (this.accelerator == accelerator) if (this.accelerator == accelerator) return;
return;
int oldAccelerator = this.accelerator; int oldAccelerator = this.accelerator;
this.accelerator = accelerator; this.accelerator = accelerator;
firePropertyChange(KEY_ACCELERATOR, oldAccelerator, accelerator); firePropertyChange(KEY_ACCELERATOR, oldAccelerator, accelerator);

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

@ -103,8 +103,7 @@ public class TabFrameTabLabel extends JLabel implements TabFrameTab {
@Override @Override
public void setOrientation(final Alignment a) { public void setOrientation(final Alignment a) {
if (this.orientation == a) if (this.orientation == a) return;
return;
Alignment oldOrientation = this.orientation; Alignment oldOrientation = this.orientation;
this.orientation = a; this.orientation = a;
firePropertyChange(KEY_ORIENTATION, oldOrientation, orientation); firePropertyChange(KEY_ORIENTATION, oldOrientation, orientation);
@ -117,8 +116,7 @@ public class TabFrameTabLabel extends JLabel implements TabFrameTab {
@Override @Override
public void setSelected(final boolean selected) { public void setSelected(final boolean selected) {
if (selected == this.selected) if (selected == this.selected) return;
return;
boolean oldSelected = this.selected; boolean oldSelected = this.selected;
this.selected = selected; this.selected = selected;
firePropertyChange(KEY_SELECTED, oldSelected, selected); firePropertyChange(KEY_SELECTED, oldSelected, selected);
@ -131,8 +129,7 @@ public class TabFrameTabLabel extends JLabel implements TabFrameTab {
@Override @Override
public void setAccelerator(final int accelerator) { public void setAccelerator(final int accelerator) {
if (this.accelerator == accelerator) if (this.accelerator == accelerator) return;
return;
int oldAccelerator = this.accelerator; int oldAccelerator = this.accelerator;
this.accelerator = accelerator; this.accelerator = accelerator;
firePropertyChange(KEY_ACCELERATOR, oldAccelerator, accelerator); firePropertyChange(KEY_ACCELERATOR, oldAccelerator, accelerator);
@ -166,8 +163,7 @@ public class TabFrameTabLabel extends JLabel implements TabFrameTab {
* @param title the title * @param title the title
*/ */
public void setTitle(final String title) { public void setTitle(final String title) {
if (Objects.equals(title, this.title)) if (Objects.equals(title, this.title)) return;
return;
String oldTitle = this.title; String oldTitle = this.title;
this.title = title; this.title = title;
firePropertyChange(KEY_TITLE, oldTitle, selected); firePropertyChange(KEY_TITLE, oldTitle, selected);

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

@ -138,8 +138,7 @@ public class TabbedPopup extends PanelPopup {
* @param component the component to add. * @param component the component to add.
*/ */
public void setContentPane(final Component component) { public void setContentPane(final Component component) {
if (component == null) if (component == null) return;
return;
if (getContentPanes().contains(component)) { if (getContentPanes().contains(component)) {
return; return;
} }

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

@ -146,8 +146,7 @@ public class ToggleSplitPane extends JSplitPane {
@Override @Override
public void setDividerLocation(final int location) { public void setDividerLocation(final int location) {
if (isInLayout) if (isInLayout) return;
return;
isInLayout = true; isInLayout = true;
if (resizable) { if (resizable) {
super.setDividerLocation(location); super.setDividerLocation(location);

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

@ -85,16 +85,13 @@ public class LineHighlighter implements Highlighter.HighlightPainter, ChangeList
private void resetHighlight() { private void resetHighlight() {
// Use invokeLater to make sure updates to the Document are completed, // Use invokeLater to make sure updates to the Document are completed,
// otherwise Undo processing causes the modelToView method to loop. // otherwise Undo processing causes the modelToView method to loop.
if (component == null) if (component == null) return;
return;
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
try { try {
if (component == null) if (component == null) return;
return;
int offset = component.getCaretPosition(); int offset = component.getCaretPosition();
Rectangle view = component.modelToView(offset); Rectangle view = component.modelToView(offset);
if (view == null) if (view == null) return;
return;
Rectangle currentView = view.getBounds(); Rectangle currentView = view.getBounds();
// Remove the highlighting from the previously highlighted line // Remove the highlighting from the previously highlighted line

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

@ -101,8 +101,7 @@ public class NumberingPane extends JComponent {
} }
public void addIconListener(final int offset, final IconListener listener) throws BadLocationException { public void addIconListener(final int offset, final IconListener listener) throws BadLocationException {
if (textComponent == null) if (textComponent == null) return;
return;
addIconListener(textComponent.getDocument().createPosition(offset), listener); addIconListener(textComponent.getDocument().createPosition(offset), listener);
} }
@ -117,8 +116,7 @@ public class NumberingPane extends JComponent {
} }
public void removeIconListener(final int offset, final IconListener listener) throws BadLocationException { public void removeIconListener(final int offset, final IconListener listener) throws BadLocationException {
if (textComponent == null) if (textComponent == null) return;
return;
removeIconListener(textComponent.getDocument().createPosition(offset), listener); removeIconListener(textComponent.getDocument().createPosition(offset), listener);
} }
@ -138,8 +136,7 @@ public class NumberingPane extends JComponent {
} }
public List<IconListener> getIconListeners(final int offset) throws BadLocationException { public List<IconListener> getIconListeners(final int offset) throws BadLocationException {
if (textComponent == null) if (textComponent == null) return new ArrayList<>();
return new ArrayList<>();
return getIconListeners(textComponent.getDocument().createPosition(offset)); return getIconListeners(textComponent.getDocument().createPosition(offset));
} }

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

@ -84,8 +84,7 @@ public class TextFieldHistoryPopup extends ScrollPopupMenu implements SearchList
* @throws IllegalArgumentException if capacity is negative * @throws IllegalArgumentException if capacity is negative
*/ */
public void setCapacity(final int capacity) throws IllegalArgumentException { public void setCapacity(final int capacity) throws IllegalArgumentException {
if (capacity < 0) if (capacity < 0) throw new IllegalArgumentException("Negative history size is not supported");
throw new IllegalArgumentException("Negative history size is not supported");
this.capacity = capacity; this.capacity = capacity;
} }
@ -122,8 +121,7 @@ public class TextFieldHistoryPopup extends ScrollPopupMenu implements SearchList
@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) {
if (history.size() == 0) if (history.size() == 0) return;
return;
super.show(invoker, x, y); super.show(invoker, x, y);
} }

3
core/src/main/java/com/github/weisj/darklaf/components/togglebuttonlist/JToggleButtonList.java

@ -64,8 +64,7 @@ public class JToggleButtonList extends JList<JToggleButton> {
@Override @Override
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
int leadIndex = getSelectionModel().getLeadSelectionIndex(); int leadIndex = getSelectionModel().getLeadSelectionIndex();
if (leadIndex >= 0) if (leadIndex >= 0) setSelected(leadIndex, !JToggleButtonList.this.isSelected(leadIndex));
setSelected(leadIndex, !JToggleButtonList.this.isSelected(leadIndex));
} }
}); });
super.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); super.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

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

@ -42,8 +42,7 @@ public class ToolTipContext {
private static ToolTipContext defaultContext; private static ToolTipContext defaultContext;
public static ToolTipContext getDefaultContext() { public static ToolTipContext getDefaultContext() {
if (defaultContext == null) if (defaultContext == null) defaultContext = createDefaultContext();
defaultContext = createDefaultContext();
return defaultContext; return defaultContext;
} }
@ -66,14 +65,12 @@ public class ToolTipContext {
@Override @Override
public void mouseMoved(final MouseEvent e) { public void mouseMoved(final MouseEvent e) {
if (hotSpotArea == null) if (hotSpotArea == null) return;
return;
checkExit(e); checkExit(e);
} }
private void checkExit(final MouseEvent e) { private void checkExit(final MouseEvent e) {
if (!hideOnExit) if (!hideOnExit) return;
return;
if (hotSpotArea != null) { if (hotSpotArea != null) {
if (!hotSpotArea.contains(e.getPoint())) { if (!hotSpotArea.contains(e.getPoint())) {
ToolTipManager.sharedInstance().mousePressed(null); ToolTipManager.sharedInstance().mousePressed(null);
@ -466,8 +463,7 @@ public class ToolTipContext {
*/ */
public Point getToolTipLocation(final Point mp, final MouseEvent mouseEvent, final boolean centerHorizontally, public Point getToolTipLocation(final Point mp, final MouseEvent mouseEvent, final boolean centerHorizontally,
final boolean centerVertically) { final boolean centerVertically) {
if (target == null) if (target == null) return null;
return null;
updateToolTip(); updateToolTip();
MouseEvent event = processEvent(mouseEvent, mp); MouseEvent event = processEvent(mouseEvent, mp);
Rectangle rect = getTargetRect(event, centerHorizontally, centerVertically); Rectangle rect = getTargetRect(event, centerHorizontally, centerVertically);
@ -515,8 +511,7 @@ public class ToolTipContext {
} }
private MouseEvent processEvent(final MouseEvent mouseEvent, final Point mp) { private MouseEvent processEvent(final MouseEvent mouseEvent, final Point mp) {
if (mouseEvent != null) if (mouseEvent != null) return mouseEvent;
return mouseEvent;
return new MouseEvent(target, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, mp.x, mp.y, 0, false, 0); return new MouseEvent(target, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, mp.x, mp.y, 0, false, 0);
} }
@ -542,8 +537,7 @@ public class ToolTipContext {
} }
public void updateToolTipUI() { public void updateToolTipUI() {
if (toolTip != null) if (toolTip != null) toolTip.updateUI();
toolTip.updateUI();
} }
private Dimension getContentSize() { private Dimension getContentSize() {
@ -615,8 +609,7 @@ public class ToolTipContext {
} }
public void setToolTip(final JToolTip toolTip) { public void setToolTip(final JToolTip toolTip) {
if (toolTip == null) if (toolTip == null) return;
return;
this.toolTip = toolTip; this.toolTip = toolTip;
if (this.target != toolTip.getComponent()) { if (this.target != toolTip.getComponent()) {
this.toolTip.setComponent(this.target); this.toolTip.setComponent(this.target);
@ -629,8 +622,7 @@ public class ToolTipContext {
public ToolTipContext setFallBackPositionProvider(final Function<ToolTipContext, Point> fallBackPositionProvider) { public ToolTipContext setFallBackPositionProvider(final Function<ToolTipContext, Point> fallBackPositionProvider) {
this.fallBackPositionProvider = fallBackPositionProvider; this.fallBackPositionProvider = fallBackPositionProvider;
if (fallBackPositionProvider == null) if (fallBackPositionProvider == null) this.fallBackPositionProvider = c -> null;
this.fallBackPositionProvider = c -> null;
return this; return this;
} }
} }

6
core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipStyle.java

@ -35,10 +35,8 @@ public enum ToolTipStyle implements ToolTipConstants {
} }
public static ToolTipStyle parse(final Object style) { public static ToolTipStyle parse(final Object style) {
if (style instanceof ToolTipStyle) if (style instanceof ToolTipStyle) return (ToolTipStyle) style;
return (ToolTipStyle) style; if (style == null) return null;
if (style == null)
return null;
String name = style.toString(); String name = style.toString();
if (VARIANT_PLAIN_BALLOON.equalsIgnoreCase(name) || ToolTipStyle.PLAIN_BALLOON.name().equalsIgnoreCase(name)) { if (VARIANT_PLAIN_BALLOON.equalsIgnoreCase(name) || ToolTipStyle.PLAIN_BALLOON.name().equalsIgnoreCase(name)) {
return ToolTipStyle.PLAIN_BALLOON; return ToolTipStyle.PLAIN_BALLOON;

3
core/src/main/java/com/github/weisj/darklaf/components/tree/TristateTreeNode.java

@ -112,8 +112,7 @@ public class TristateTreeNode extends DefaultMutableTreeNode implements LabeledT
for (Object node : children) { for (Object node : children) {
if (node instanceof TristateTreeNode) { if (node instanceof TristateTreeNode) {
TristateState nodeState = ((TristateTreeNode) node).getUserObject(); TristateState nodeState = ((TristateTreeNode) node).getUserObject();
if (state == null) if (state == null) state = nodeState;
state = nodeState;
if (state != nodeState) { if (state != nodeState) {
state = TristateState.INDETERMINATE_SEL; state = TristateState.INDETERMINATE_SEL;
break; break;

6
core/src/main/java/com/github/weisj/darklaf/components/treetable/JTreeTable.java

@ -73,8 +73,7 @@ public class JTreeTable extends JTable implements TreeSelectionListener {
DarkTreeUI ui = DarkUIUtil.getUIOfType(tree.getUI(), DarkTreeUI.class); DarkTreeUI ui = DarkUIUtil.getUIOfType(tree.getUI(), DarkTreeUI.class);
if (ui != null) { if (ui != null) {
CellHintPopupListener<JTree, ?> listener = ui.getPopupListener(); CellHintPopupListener<JTree, ?> listener = ui.getPopupListener();
if (listener != null) if (listener != null) listener.repaint();
listener.repaint();
} }
}); });
} }
@ -93,8 +92,7 @@ public class JTreeTable extends JTable implements TreeSelectionListener {
tree.processEvent(e); tree.processEvent(e);
} }
} }
if (((InputEvent) e).isConsumed()) if (((InputEvent) e).isConsumed()) return;
return;
} }
super.processEvent(e); super.processEvent(e);
} }

3
core/src/main/java/com/github/weisj/darklaf/components/treetable/model/DefaultTreeTableModel.java

@ -61,8 +61,7 @@ public class DefaultTreeTableModel extends AbstractTreeTableModel {
@Override @Override
public Object getValueAt(final Object node, final int column) { public Object getValueAt(final Object node, final int column) {
TreeTableNode treeTableNode = DarkUIUtil.nullableCast(TreeTableNode.class, node); TreeTableNode treeTableNode = DarkUIUtil.nullableCast(TreeTableNode.class, node);
if (treeTableNode == null) if (treeTableNode == null) return null;
return null;
return treeTableNode.getValueAt(column); return treeTableNode.getValueAt(column);
} }

6
core/src/main/java/com/github/weisj/darklaf/components/treetable/model/TreeTableNode.java

@ -41,8 +41,7 @@ public interface TreeTableNode extends TreeNode {
@Override @Override
default int getIndex(final TreeNode node) { default int getIndex(final TreeNode node) {
if (!(node instanceof TreeTableNode)) if (!(node instanceof TreeTableNode)) return -1;
return -1;
return getIndex((TreeTableNode) node); return getIndex((TreeTableNode) node);
} }
@ -57,8 +56,7 @@ public interface TreeTableNode extends TreeNode {
@Override @Override
default TreeTableNode getChildAt(final int index) { default TreeTableNode getChildAt(final int index) {
if (index < 0 || index >= getChildCount()) if (index < 0 || index >= getChildCount()) return null;
return null;
return getChildren().get(index); return getChildren().get(index);
} }

6
core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateButtonModel.java

@ -42,8 +42,7 @@ public class TristateButtonModel extends JToggleButton.ToggleButtonModel {
} }
public void setIndeterminate() { public void setIndeterminate() {
if (!allowsIndeterminate || isIndeterminate()) if (!allowsIndeterminate || isIndeterminate()) return;
return;
setState(isSelected() ? TristateState.INDETERMINATE_DES : TristateState.INDETERMINATE_SEL); setState(isSelected() ? TristateState.INDETERMINATE_DES : TristateState.INDETERMINATE_SEL);
} }
@ -79,8 +78,7 @@ public class TristateButtonModel extends JToggleButton.ToggleButtonModel {
} }
public void setState(final TristateState state) { public void setState(final TristateState state) {
if (this.state == state) if (this.state == state) return;
return;
if (!allowsIndeterminate && state.isIndeterminate()) { if (!allowsIndeterminate && state.isIndeterminate()) {
return; return;
} }

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

@ -47,8 +47,7 @@ public class TristateCheckBox extends JCheckBox {
} }
private void iterateState() { private void iterateState() {
if (!getModel().isEnabled()) if (!getModel().isEnabled()) return;
return;
getTristateModel().iterateState(); getTristateModel().iterateState();
} }

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

@ -115,8 +115,7 @@ public class TristateCheckBoxMenuItem extends JCheckBoxMenuItem {
} }
private void iterateState() { private void iterateState() {
if (!getModel().isEnabled()) if (!getModel().isEnabled()) return;
return;
grabFocus(); grabFocus();
getTristateModel().iterateState(); getTristateModel().iterateState();

9
core/src/main/java/com/github/weisj/darklaf/graphics/Animator.java

@ -65,8 +65,7 @@ public abstract class Animator {
public void reset() { public void reset() {
currentFrame %= totalFrames; currentFrame %= totalFrames;
if (!forward) if (!forward) currentFrame = totalFrames - currentFrame;
currentFrame = totalFrames - currentFrame;
} }
private static ScheduledExecutorService createScheduler() { private static ScheduledExecutorService createScheduler() {
@ -139,8 +138,7 @@ public abstract class Animator {
} }
private void onTick() { private void onTick() {
if (isDisposed() || ticker == null) if (isDisposed() || ticker == null) return;
return;
if (startTime == -1) { if (startTime == -1) {
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
@ -151,8 +149,7 @@ public abstract class Animator {
final double totalTime = stopTime - startTime; final double totalTime = stopTime - startTime;
final int newFrame = (int) (passedTime * totalFrames / totalTime) + startFrame; final int newFrame = (int) (passedTime * totalFrames / totalTime) + startFrame;
if (currentFrame > 0 && newFrame == currentFrame) if (currentFrame > 0 && newFrame == currentFrame) return;
return;
currentFrame = newFrame; currentFrame = newFrame;
if (currentFrame >= totalFrames) { if (currentFrame >= totalFrames) {

6
core/src/main/java/com/github/weisj/darklaf/graphics/GraphicsUtil.java

@ -41,13 +41,11 @@ public final class GraphicsUtil {
private GraphicsUtil() {} private GraphicsUtil() {}
public static void setOpaqueBuffered(final JComponent c, final boolean opaqueBuffered) { public static void setOpaqueBuffered(final JComponent c, final boolean opaqueBuffered) {
if (c != null) if (c != null) c.putClientProperty(KEY_OPAQUE_BUFFERED, opaqueBuffered);
c.putClientProperty(KEY_OPAQUE_BUFFERED, opaqueBuffered);
} }
public static boolean isOpaqueBuffered(final JComponent c) { public static boolean isOpaqueBuffered(final JComponent c) {
if (!SystemInfo.isWindows) if (!SystemInfo.isWindows) return false;
return false;
return PropertyUtil.getBooleanProperty(c, KEY_OPAQUE_BUFFERED); return PropertyUtil.getBooleanProperty(c, KEY_OPAQUE_BUFFERED);
} }

6
core/src/main/java/com/github/weisj/darklaf/graphics/StringPainter.java

@ -103,8 +103,7 @@ public class StringPainter {
public static <T extends JComponent> void drawStringImpl(final Graphics g, final T c, final View view, public static <T extends JComponent> void drawStringImpl(final Graphics g, final T c, final View view,
final String text, final Rectangle textRect, final Font font, final FontMetrics fm, final int mnemIndex, final String text, final Rectangle textRect, final Font font, final FontMetrics fm, final int mnemIndex,
final Color background) { final Color background) {
if (text == null || text.equals("")) if (text == null || text.equals("")) return;
return;
GraphicsContext context = GraphicsUtil.setupAntialiasing(g); GraphicsContext context = GraphicsUtil.setupAntialiasing(g);
@ -212,8 +211,7 @@ public class StringPainter {
try { try {
Field surfaceField = graphics2D.getClass().getField("surfaceData"); Field surfaceField = graphics2D.getClass().getField("surfaceData");
Object surfaceDataValue = surfaceField.get(graphics2D); Object surfaceDataValue = surfaceField.get(graphics2D);
if (surfaceDataValue == null) if (surfaceDataValue == null) return null;
return null;
Field imgField; Field imgField;
try { try {

6
core/src/main/java/com/github/weisj/darklaf/listener/UIUpdater.java

@ -45,8 +45,7 @@ public class UIUpdater implements ThemeChangeListener {
* @param component the component. * @param component the component.
*/ */
public static void registerComponent(final JComponent component) { public static void registerComponent(final JComponent component) {
if (component == null) if (component == null) return;
return;
removeComponent(component); removeComponent(component);
UIUpdater updater = new UIUpdater(component); UIUpdater updater = new UIUpdater(component);
component.putClientProperty(KEY_UPDATER, updater); component.putClientProperty(KEY_UPDATER, updater);
@ -90,7 +89,6 @@ public class UIUpdater implements ThemeChangeListener {
@Override @Override
public void themeInstalled(final ThemeChangeEvent e) { public void themeInstalled(final ThemeChangeEvent e) {
if (component != null) if (component != null) SwingUtilities.updateComponentTreeUI(component);
SwingUtilities.updateComponentTreeUI(component);
} }
} }

3
core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java

@ -43,8 +43,7 @@ public class DecorationsHandler {
private boolean decorationsEnabled = true; private boolean decorationsEnabled = true;
public static DecorationsHandler getSharedInstance() { public static DecorationsHandler getSharedInstance() {
if (sharedInstance == null) if (sharedInstance == null) setSharedInstance(new DecorationsHandler());
setSharedInstance(new DecorationsHandler());
return sharedInstance; return sharedInstance;
} }

3
core/src/main/java/com/github/weisj/darklaf/platform/ThemePreferencesHandler.java

@ -44,8 +44,7 @@ public class ThemePreferencesHandler {
private ThemePreferenceProvider preferenceProvider; private ThemePreferenceProvider preferenceProvider;
public static ThemePreferencesHandler getSharedInstance() { public static ThemePreferencesHandler getSharedInstance() {
if (sharedInstance == null) if (sharedInstance == null) setSharedInstance(new ThemePreferencesHandler());
setSharedInstance(new ThemePreferencesHandler());
return sharedInstance; return sharedInstance;
} }

15
core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java

@ -432,8 +432,7 @@ public class ThemeSettings implements ThemePreferenceListener {
private Theme getEffectiveTheme(final PreferredThemeStyle themeStyle) { private Theme getEffectiveTheme(final PreferredThemeStyle themeStyle) {
Theme baseTheme = getEffectiveBaseTheme(themeStyle); Theme baseTheme = getEffectiveBaseTheme(themeStyle);
if (baseTheme == null) if (baseTheme == null) return null;
return null;
FontSizeRule fontSizeRule = getEffectiveFontSizeRule(baseTheme, themeStyle); FontSizeRule fontSizeRule = getEffectiveFontSizeRule(baseTheme, themeStyle);
AccentColorRule accentColorRule = getEffectiveAccentColorRule(baseTheme); AccentColorRule accentColorRule = getEffectiveAccentColorRule(baseTheme);
return baseTheme.derive(fontSizeRule, accentColorRule); return baseTheme.derive(fontSizeRule, accentColorRule);
@ -444,14 +443,12 @@ public class ThemeSettings implements ThemePreferenceListener {
} }
private FontSizeRule getEffectiveFontSizeRule(final Theme theme, final PreferredThemeStyle preferredThemeStyle) { private FontSizeRule getEffectiveFontSizeRule(final Theme theme, final PreferredThemeStyle preferredThemeStyle) {
if (theme == null) if (theme == null) return FontSizeRule.getDefault();
return FontSizeRule.getDefault();
return isFontSizeFollowsSystem() ? preferredThemeStyle.getFontSizeRule() : getFontSizeRule(); return isFontSizeFollowsSystem() ? preferredThemeStyle.getFontSizeRule() : getFontSizeRule();
} }
private AccentColorRule getEffectiveAccentColorRule(final Theme theme) { private AccentColorRule getEffectiveAccentColorRule(final Theme theme) {
if (theme == null) if (theme == null) return AccentColorRule.getDefault();
return AccentColorRule.getDefault();
return currentConfiguration.getAccentColorRule(); return currentConfiguration.getAccentColorRule();
} }
@ -466,10 +463,8 @@ public class ThemeSettings implements ThemePreferenceListener {
} }
protected void applyTheme(final Theme theme) { protected void applyTheme(final Theme theme) {
if (theme == null) if (theme == null) return;
return; if (LafManager.getTheme().appearsEqualTo(theme)) return;
if (LafManager.getTheme().appearsEqualTo(theme))
return;
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
LafManager.installTheme(theme); LafManager.installTheme(theme);
refresh(); refresh();

24
core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsPanel.java

@ -126,8 +126,7 @@ public class ThemeSettingsPanel extends JPanel {
boolean selected = Objects.equals(radioButton.getColor(), currentColor) boolean selected = Objects.equals(radioButton.getColor(), currentColor)
|| (radioButton == defaultButton && Objects.equals(defaultColor, currentColor)); || (radioButton == defaultButton && Objects.equals(defaultColor, currentColor));
bg.setSelected(radioButton.getModel(), selected); bg.setSelected(radioButton.getModel(), selected);
if (selected) if (selected) return true;
return true;
} }
return false; return false;
} }
@ -257,8 +256,7 @@ public class ThemeSettingsPanel extends JPanel {
} }
if (!updateButtonGroup(bg, color, defaultButton, defaultColor)) { if (!updateButtonGroup(bg, color, defaultButton, defaultColor)) {
customButton.setSelected(true); customButton.setSelected(true);
if (customButton.getColor() == null) if (customButton.getColor() == null) customButton.setColor(color);
customButton.setColor(color);
} }
} }
@ -371,14 +369,10 @@ public class ThemeSettingsPanel extends JPanel {
if (!enabledSystemPreferences.getTristateModel().isIndeterminate()) { if (!enabledSystemPreferences.getTristateModel().isIndeterminate()) {
boolean selected = enabledSystemPreferences.getTristateModel().isSelected(); boolean selected = enabledSystemPreferences.getTristateModel().isSelected();
if (themeFollowsSystem.isEnabled()) if (themeFollowsSystem.isEnabled()) themeFollowsSystem.setSelected(selected);
themeFollowsSystem.setSelected(selected); if (accentColorFollowsSystem.isEnabled()) accentColorFollowsSystem.setSelected(selected);
if (accentColorFollowsSystem.isEnabled()) if (selectionColorFollowsSystem.isEnabled()) selectionColorFollowsSystem.setSelected(selected);
accentColorFollowsSystem.setSelected(selected); if (fontSizeFollowsSystem.isEnabled()) fontSizeFollowsSystem.setSelected(selected);
if (selectionColorFollowsSystem.isEnabled())
selectionColorFollowsSystem.setSelected(selected);
if (fontSizeFollowsSystem.isEnabled())
fontSizeFollowsSystem.setSelected(selected);
} }
update(); update();
}); });
@ -564,8 +558,7 @@ public class ThemeSettingsPanel extends JPanel {
} }
private AccentColorRule getAccentColorRule(final Theme theme) { private AccentColorRule getAccentColorRule(final Theme theme) {
if (theme == null) if (theme == null) return AccentColorRule.getDefault();
return AccentColorRule.getDefault();
Color accentColor = getAccentColor(theme, isAccentColorFollowsSystem()); Color accentColor = getAccentColor(theme, isAccentColorFollowsSystem());
Color selectionColor = getSelectionColor(theme, isSelectionColorFollowsSystem()); Color selectionColor = getSelectionColor(theme, isSelectionColorFollowsSystem());
return AccentColorRule.fromColor(accentColor, selectionColor); return AccentColorRule.fromColor(accentColor, selectionColor);
@ -592,8 +585,7 @@ public class ThemeSettingsPanel extends JPanel {
} }
private FontSizeRule getFontSizeRule(final Theme theme, final PreferredThemeStyle preferredThemeStyle) { private FontSizeRule getFontSizeRule(final Theme theme, final PreferredThemeStyle preferredThemeStyle) {
if (theme == null) if (theme == null) return FontSizeRule.getDefault();
return FontSizeRule.getDefault();
return isFontSizeFollowsSystem() ? preferredThemeStyle.getFontSizeRule() return isFontSizeFollowsSystem() ? preferredThemeStyle.getFontSizeRule()
: FontSizeRule.relativeAdjustment(fontSlider.getValue()); // Todo : FontSizeRule.relativeAdjustment(fontSlider.getValue()); // Todo
} }

12
core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java

@ -56,8 +56,7 @@ public class AccentColorAdjustmentTask extends ColorAdjustmentTask {
return; return;
} }
Properties props = currentTheme.loadAccentProperties(); Properties props = currentTheme.loadAccentProperties();
if (props == null || props.isEmpty()) if (props == null || props.isEmpty()) return;
return;
if (accentColor != null) { if (accentColor != null) {
adjustColors(MAIN_ACCENT_LIST_KEY, accentColor, props, properties); adjustColors(MAIN_ACCENT_LIST_KEY, accentColor, props, properties);
} }
@ -78,8 +77,7 @@ public class AccentColorAdjustmentTask extends ColorAdjustmentTask {
ColorInfo info = new ColorInfo(); ColorInfo info = new ColorInfo();
for (Object o : list) { for (Object o : list) {
setColorInfo(o, info); setColorInfo(o, info);
if (info.key == null) if (info.key == null) continue;
continue;
Object c = mapColor(info, hsb, properties); Object c = mapColor(info, hsb, properties);
if (c instanceof Color) { if (c instanceof Color) {
properties.put(info.key, c); properties.put(info.key, c);
@ -99,10 +97,8 @@ public class AccentColorAdjustmentTask extends ColorAdjustmentTask {
if (o instanceof Pair<?, ?>) { if (o instanceof Pair<?, ?>) {
Object first = ((Pair<?, ?>) o).getFirst(); Object first = ((Pair<?, ?>) o).getFirst();
Object second = ((Pair<?, ?>) o).getSecond(); Object second = ((Pair<?, ?>) o).getSecond();
if (!(first instanceof String)) if (!(first instanceof String)) return;
return; if (!(second instanceof List<?>)) return;
if (!(second instanceof List<?>))
return;
String key = first.toString(); String key = first.toString();
List<?> list = (List<?>) second; List<?> list = (List<?>) second;
if (list.size() != 3 || !(list.get(0) instanceof Integer) || !(list.get(1) instanceof Integer) if (list.size() != 3 || !(list.get(0) instanceof Integer) || !(list.get(1) instanceof Integer)

24
core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java

@ -103,10 +103,8 @@ public class FontDefaultsInitTask implements DefaultsInitTask {
} }
private boolean systemKerningEnabled() { private boolean systemKerningEnabled() {
if (SystemInfo.isMac) if (SystemInfo.isMac) return SystemInfo.isMacOSMojave;
return SystemInfo.isMacOSMojave; if (SystemInfo.isWindows) return SystemInfo.isWindowsVista;
if (SystemInfo.isWindows)
return SystemInfo.isWindowsVista;
return false; return false;
} }
@ -144,8 +142,7 @@ public class FontDefaultsInitTask implements DefaultsInitTask {
Font font = entry.getValue(); Font font = entry.getValue();
String fontName = SystemInfo.isMacOSCatalina ? MAC_OS_CATALINA_FONT_NAME_FALLBACK : MAC_OS_FONT_NAME; String fontName = SystemInfo.isMacOSCatalina ? MAC_OS_CATALINA_FONT_NAME_FALLBACK : MAC_OS_FONT_NAME;
Font macFont = FontUtil.createFont(fontName, font.getStyle(), font.getSize()); Font macFont = FontUtil.createFont(fontName, font.getStyle(), font.getSize());
if (SystemInfo.isMacOSMojave) if (SystemInfo.isMacOSMojave) macFont = macFont.deriveFont(ENABLE_KERNING);
macFont = macFont.deriveFont(ENABLE_KERNING);
if (font instanceof UIResource) { if (font instanceof UIResource) {
macFont = new DarkFontUIResource(macFont); macFont = new DarkFontUIResource(macFont);
} }
@ -154,8 +151,7 @@ public class FontDefaultsInitTask implements DefaultsInitTask {
private Font mapWindowsFont(final Map.Entry<Object, Font> entry) { private Font mapWindowsFont(final Map.Entry<Object, Font> entry) {
Font font = entry.getValue(); Font font = entry.getValue();
if (!SystemInfo.isWindowsVista) if (!SystemInfo.isWindowsVista) return font;
return font;
Font windowsFont = FontUtil.createFont(WINDOWS_10_FONT_NAME, font.getStyle(), font.getSize()); Font windowsFont = FontUtil.createFont(WINDOWS_10_FONT_NAME, font.getStyle(), font.getSize());
if (font instanceof UIResource) { if (font instanceof UIResource) {
windowsFont = new DarkFontUIResource(windowsFont); windowsFont = new DarkFontUIResource(windowsFont);
@ -167,26 +163,22 @@ public class FontDefaultsInitTask implements DefaultsInitTask {
PropertyLoader.replacePropertiesOfType(Font.class, defaults, e -> kerningPredicate.test(e.getKey().toString()), PropertyLoader.replacePropertiesOfType(Font.class, defaults, e -> kerningPredicate.test(e.getKey().toString()),
f -> { f -> {
Font font = f.deriveFont(ENABLE_KERNING); Font font = f.deriveFont(ENABLE_KERNING);
if (f instanceof UIResource) if (f instanceof UIResource) font = new DarkFontUIResource(font);
font = new DarkFontUIResource(font);
return font; return font;
}); });
} }
private void applyFontRule(final Theme currentTheme, final UIDefaults defaults) { private void applyFontRule(final Theme currentTheme, final UIDefaults defaults) {
FontSizeRule rule = currentTheme.getFontSizeRule(); FontSizeRule rule = currentTheme.getFontSizeRule();
if (rule == null || rule.getType() == FontSizeRule.AdjustmentType.NO_ADJUSTMENT) if (rule == null || rule.getType() == FontSizeRule.AdjustmentType.NO_ADJUSTMENT) return;
return;
PropertyLoader.replacePropertiesOfType(Font.class, defaults, f -> fontWithRule(f, rule)); PropertyLoader.replacePropertiesOfType(Font.class, defaults, f -> fontWithRule(f, rule));
} }
private Font fontWithRule(final Font font, final FontSizeRule rule) { private Font fontWithRule(final Font font, final FontSizeRule rule) {
if (font == null) if (font == null) return null;
return null;
float size = font.getSize2D(); float size = font.getSize2D();
float newSize = rule.adjustFontSize(size); float newSize = rule.adjustFontSize(size);
if (newSize == size) if (newSize == size) return font;
return font;
if (newSize <= 0) { if (newSize <= 0) {
LOGGER.warning("Font " + font + " would be invisible after applying " + rule + ". Font won't be changed!"); LOGGER.warning("Font " + font + " would be invisible after applying " + rule + ". Font won't be changed!");
return font; return font;

3
core/src/main/java/com/github/weisj/darklaf/task/UserPreferenceAdjustmentTask.java

@ -31,8 +31,7 @@ public abstract class UserPreferenceAdjustmentTask implements DefaultsAdjustment
@Override @Override
public void run(final Theme currentTheme, final Properties properties) { public void run(final Theme currentTheme, final Properties properties) {
for (DefaultsAdjustmentTask task : getTasks()) { for (DefaultsAdjustmentTask task : getTasks()) {
if (task != null) if (task != null) task.run(currentTheme, properties);
task.run(currentTheme, properties);
} }
} }

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

@ -89,10 +89,8 @@ public class DarkPopupFactory extends PopupFactory {
public static PopupType getPopupType(final Popup popup) { public static PopupType getPopupType(final Popup popup) {
String popupClassName = popup.getClass().getSimpleName(); String popupClassName = popup.getClass().getSimpleName();
if (popupClassName.endsWith("LightWeightPopup")) if (popupClassName.endsWith("LightWeightPopup")) return PopupType.LIGHT_WEIGHT;
return PopupType.LIGHT_WEIGHT; if (popupClassName.endsWith("MediumWeightPopup")) return PopupType.MEDIUM_WEIGHT;
if (popupClassName.endsWith("MediumWeightPopup"))
return PopupType.MEDIUM_WEIGHT;
return PopupType.HEAVY_WEIGHT; return PopupType.HEAVY_WEIGHT;
} }
@ -100,8 +98,7 @@ public class DarkPopupFactory extends PopupFactory {
if (type == PopupType.MEDIUM_WEIGHT) { if (type == PopupType.MEDIUM_WEIGHT) {
JRootPane rootPane = SwingUtilities.getRootPane(contents); JRootPane rootPane = SwingUtilities.getRootPane(contents);
// Prevents decorations from being reinstalled. // Prevents decorations from being reinstalled.
if (rootPane != null) if (rootPane != null) rootPane.putClientProperty(DarkRootPaneUI.KEY_NO_DECORATIONS_UPDATE, true);
rootPane.putClientProperty(DarkRootPaneUI.KEY_NO_DECORATIONS_UPDATE, true);
} else if (type == PopupType.HEAVY_WEIGHT) { } else if (type == PopupType.HEAVY_WEIGHT) {
Window window = SwingUtilities.getWindowAncestor(contents); Window window = SwingUtilities.getWindowAncestor(contents);
if (window != null) { if (window != null) {
@ -131,8 +128,7 @@ public class DarkPopupFactory extends PopupFactory {
* that is repainted with the proper popup background later. That is why we set window background * that is repainted with the proper popup background later. That is why we set window background
* explicitly. * explicitly.
*/ */
if (rootPane == null) if (rootPane == null) return;
return;
rootPane.setOpaque(opaque); rootPane.setOpaque(opaque);
if (opaque) { if (opaque) {
Color bg = ColorUtil.toAlpha(rootPane.getBackground(), 255); Color bg = ColorUtil.toAlpha(rootPane.getBackground(), 255);
@ -188,8 +184,7 @@ public class DarkPopupFactory extends PopupFactory {
protected Color getTranslucentPopupBackground(final boolean decorated) { protected Color getTranslucentPopupBackground(final boolean decorated) {
Color c = UIManager.getColor("PopupMenu.translucentBackground"); Color c = UIManager.getColor("PopupMenu.translucentBackground");
if (!decorated) if (!decorated) c = new DarkColorUIResource(ColorUtil.toAlpha(c, 0));
c = new DarkColorUIResource(ColorUtil.toAlpha(c, 0));
return c; return c;
} }

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

@ -63,10 +63,8 @@ public interface ButtonConstants {
} }
static int chooseArc(final Component c, final int arc, final int minimum, final int altArc, final int roundedArc) { static int chooseArc(final Component c, final int arc, final int minimum, final int altArc, final int roundedArc) {
if (ButtonConstants.isNoArc(c)) if (ButtonConstants.isNoArc(c)) return minimum;
return minimum; if (ButtonConstants.isRound(c)) return roundedArc;
if (ButtonConstants.isRound(c))
return roundedArc;
boolean alt = ButtonConstants.chooseAlternativeArc(c); boolean alt = ButtonConstants.chooseAlternativeArc(c);
return alt ? altArc : arc; return alt ? altArc : arc;
} }
@ -89,8 +87,7 @@ public interface ButtonConstants {
} }
static boolean isBorderlessVariant(final Component c) { static boolean isBorderlessVariant(final Component c) {
if (isBorderlessRectangular(c)) if (isBorderlessRectangular(c)) return true;
return true;
if (c instanceof JButton || c instanceof JToggleButton) { if (c instanceof JButton || c instanceof JToggleButton) {
return isBorderless(c) || doConvertToBorderless((AbstractButton) c); return isBorderless(c) || doConvertToBorderless((AbstractButton) c);
} }

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

@ -153,8 +153,7 @@ public class DarkButtonBorder implements Border, UIResource {
if (paintLeft) { if (paintLeft) {
AlignmentExt corner = getCornerFlag(left); AlignmentExt corner = getCornerFlag(left);
Insets ins = new Insets(0, 0, 0, 0); Insets ins = new Insets(0, 0, 0, 0);
if (corner != null) if (corner != null) ins = corner.maskInsets(ins, borderSize);
ins = corner.maskInsets(ins, borderSize);
int h = height - Math.max(0, getShadowSize(left) - borderSize); int h = height - Math.max(0, getShadowSize(left) - borderSize);
g2.translate(-3 * borderSize + 1, -ins.top); g2.translate(-3 * borderSize + 1, -ins.top);
@ -166,8 +165,7 @@ public class DarkButtonBorder implements Border, UIResource {
if (paintRight) { if (paintRight) {
AlignmentExt corner = getCornerFlag(right); AlignmentExt corner = getCornerFlag(right);
Insets ins = new Insets(0, 0, 0, 0); Insets ins = new Insets(0, 0, 0, 0);
if (corner != null) if (corner != null) ins = corner.maskInsets(ins, borderSize);
ins = corner.maskInsets(ins, borderSize);
int h = height - Math.max(0, getShadowSize(right) - borderSize); int h = height - Math.max(0, getShadowSize(right) - borderSize);
g2.translate(width - borderSize - 1, -ins.top); g2.translate(width - borderSize - 1, -ins.top);
@ -180,8 +178,7 @@ public class DarkButtonBorder implements Border, UIResource {
if (paintTop) { if (paintTop) {
AlignmentExt corner = getCornerFlag(top); AlignmentExt corner = getCornerFlag(top);
Insets ins = new Insets(0, 0, 0, 0); Insets ins = new Insets(0, 0, 0, 0);
if (corner != null) if (corner != null) ins = corner.maskInsets(ins, borderSize);
ins = corner.maskInsets(ins, borderSize);
g2.translate(-ins.left, -3 * borderSize + 1); g2.translate(-ins.left, -3 * borderSize + 1);
PaintUtil.paintFocusBorder(g2, width + ins.right + ins.left, 4 * borderSize, getFocusArc(top), borderSize); PaintUtil.paintFocusBorder(g2, width + ins.right + ins.left, 4 * borderSize, getFocusArc(top), borderSize);
@ -209,8 +206,7 @@ public class DarkButtonBorder implements Border, UIResource {
if (paintBottom) { if (paintBottom) {
AlignmentExt corner = getCornerFlag(bottom); AlignmentExt corner = getCornerFlag(bottom);
Insets ins = new Insets(0, 0, 0, 0); Insets ins = new Insets(0, 0, 0, 0);
if (corner != null) if (corner != null) ins = corner.maskInsets(ins, borderSize);
ins = corner.maskInsets(ins, borderSize);
g2.translate(-ins.left, height - borderSize - 1); g2.translate(-ins.left, height - borderSize - 1);
PaintUtil.paintFocusBorder(g2, width + ins.left + ins.right, 4 * borderSize, getFocusArc(bottom), PaintUtil.paintFocusBorder(g2, width + ins.left + ins.right, 4 * borderSize, getFocusArc(bottom),
@ -270,8 +266,7 @@ public class DarkButtonBorder implements Border, UIResource {
protected Insets maskInsets(final Insets ins, final Component c, final int shadow) { protected Insets maskInsets(final Insets ins, final Component c, final int shadow) {
AlignmentExt alignment = getCornerFlag(c); AlignmentExt alignment = getCornerFlag(c);
if (alignment == null) if (alignment == null) return ins;
return ins;
Insets insetMask = new Insets(borderSize, borderSize, Math.max(borderSize, shadow), borderSize); Insets insetMask = new Insets(borderSize, borderSize, Math.max(borderSize, shadow), borderSize);
insetMask = alignment.maskInsetsInverted(insetMask); insetMask = alignment.maskInsetsInverted(insetMask);
ins.top -= insetMask.top; ins.top -= insetMask.top;

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

@ -121,16 +121,11 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
squareInsets = UIManager.getInsets("Button.squareBorderInsets"); squareInsets = UIManager.getInsets("Button.squareBorderInsets");
squareThinInsets = UIManager.getInsets("Button.squareThinBorderInsets"); squareThinInsets = UIManager.getInsets("Button.squareThinBorderInsets");
borderlessRectangularInsets = UIManager.getInsets("Button.borderlessRectangularInsets"); borderlessRectangularInsets = UIManager.getInsets("Button.borderlessRectangularInsets");
if (insets == null) if (insets == null) insets = new Insets(0, 0, 0, 0);
insets = new Insets(0, 0, 0, 0); if (thinInsets == null) thinInsets = new Insets(0, 0, 0, 0);
if (thinInsets == null) if (squareThinInsets == null) squareThinInsets = new Insets(0, 0, 0, 0);
thinInsets = new Insets(0, 0, 0, 0); if (squareInsets == null) squareInsets = new Insets(0, 0, 0, 0);
if (squareThinInsets == null) if (borderlessRectangularInsets == null) borderlessRectangularInsets = new Insets(0, 0, 0, 0);
squareThinInsets = new Insets(0, 0, 0, 0);
if (squareInsets == null)
squareInsets = new Insets(0, 0, 0, 0);
if (borderlessRectangularInsets == null)
borderlessRectangularInsets = new Insets(0, 0, 0, 0);
updateMargins(b); updateMargins(b);
} }
@ -439,15 +434,13 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
protected void updateMargins(final AbstractButton b) { protected void updateMargins(final AbstractButton b) {
Insets margin = b.getMargin(); Insets margin = b.getMargin();
if (margin != null && !(margin instanceof UIResource)) if (margin != null && !(margin instanceof UIResource)) return;
return;
Insets m = getMargins(b); Insets m = getMargins(b);
b.setMargin(new InsetsUIResource(m.top, m.left, m.bottom, m.right)); b.setMargin(new InsetsUIResource(m.top, m.left, m.bottom, m.right));
} }
private Insets getMargins(final AbstractButton b) { private Insets getMargins(final AbstractButton b) {
if (ButtonConstants.isBorderlessRectangular(b)) if (ButtonConstants.isBorderlessRectangular(b)) return borderlessRectangularInsets;
return borderlessRectangularInsets;
boolean square = ButtonConstants.isSquare(b); boolean square = ButtonConstants.isSquare(b);
return ButtonConstants.isThin(b) ? square ? squareThinInsets : thinInsets : square ? squareInsets : insets; return ButtonConstants.isThin(b) ? square ? squareThinInsets : thinInsets : square ? squareInsets : insets;
} }
@ -457,8 +450,7 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
if (ButtonConstants.isBorderlessRectangular(c)) { if (ButtonConstants.isBorderlessRectangular(c)) {
return super.contains(c, x, y); return super.contains(c, x, y);
} }
if (!(x >= 0 && x <= c.getWidth() && y >= 0 && y <= c.getHeight())) if (!(x >= 0 && x <= c.getWidth() && y >= 0 && y <= c.getHeight())) return false;
return false;
int bs = c.getBorder() instanceof DarkButtonBorder && !ButtonConstants.isBorderless(c) ? borderSize : 0; int bs = c.getBorder() instanceof DarkButtonBorder && !ButtonConstants.isBorderless(c) ? borderSize : 0;
int arc = getArc(c); int arc = getArc(c);
hitArea.setRoundRect(bs, bs, c.getWidth() - 2 * bs, c.getHeight() - 2 * bs, arc, arc); hitArea.setRoundRect(bs, bs, c.getWidth() - 2 * bs, c.getHeight() - 2 * bs, arc, arc);

6
core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java

@ -473,8 +473,7 @@ public class CellUtil {
int row = table.getEditingRow(); int row = table.getEditingRow();
int col = table.getEditingColumn(); int col = table.getEditingColumn();
if (!table.getShowHorizontalLines()) { if (!table.getShowHorizontalLines()) {
if (row > CellUtil.getMinRowIndex(table)) if (row > CellUtil.getMinRowIndex(table)) g.fillRect(0, 0, width, 1);
g.fillRect(0, 0, width, 1);
g.fillRect(0, height - 1, width, 1); g.fillRect(0, height - 1, width, 1);
} }
boolean isWrapper = isInWrapper(c); boolean isWrapper = isInWrapper(c);
@ -529,8 +528,7 @@ public class CellUtil {
if (table != null && !table.getShowVerticalLines()) { if (table != null && !table.getShowVerticalLines()) {
int cMin = getMinColumnIndex(table); int cMin = getMinColumnIndex(table);
int column = table.getEditingColumn(); int column = table.getEditingColumn();
if (column > cMin) if (column > cMin) ins.left++;
ins.left++;
} }
return ins; return ins;
} }

27
core/src/main/java/com/github/weisj/darklaf/ui/cell/hint/CellHintPopupListener.java

@ -85,8 +85,7 @@ public class CellHintPopupListener<T extends JComponent, I> extends MouseInputAd
} }
private void updatePopup(final I index, final Point p) { private void updatePopup(final I index, final Point p) {
if (cellContainer.getComponent() == null || index == null) if (cellContainer.getComponent() == null || index == null) return;
return;
final boolean isEditing = cellContainer.isEditingCell(index); final boolean isEditing = cellContainer.isEditingCell(index);
final Rectangle allocation = cellContainer.getAllocation(); final Rectangle allocation = cellContainer.getAllocation();
final Rectangle cellBounds = cellContainer.getCellBoundsAt(index, isEditing); final Rectangle cellBounds = cellContainer.getCellBoundsAt(index, isEditing);
@ -140,10 +139,8 @@ public class CellHintPopupListener<T extends JComponent, I> extends MouseInputAd
} else { } else {
int upperDiff = Math.max(cellBounds.x + cellBounds.width - visibleBounds.x - visibleBounds.width, 0); int upperDiff = Math.max(cellBounds.x + cellBounds.width - visibleBounds.x - visibleBounds.width, 0);
int lowerDiff = Math.max(visibleBounds.x - cellBounds.x, 0); int lowerDiff = Math.max(visibleBounds.x - cellBounds.x, 0);
if (ltr && upperDiff > 0) if (ltr && upperDiff > 0) lowerDiff = 0;
lowerDiff = 0; if (!ltr && lowerDiff > 0) upperDiff = 0;
if (!ltr && lowerDiff > 0)
upperDiff = 0;
if (upperDiff >= lowerDiff) { if (upperDiff >= lowerDiff) {
rect.x = visibleBounds.x + visibleBounds.width; rect.x = visibleBounds.x + visibleBounds.width;
rect.width = upperDiff; rect.width = upperDiff;
@ -163,8 +160,7 @@ public class CellHintPopupListener<T extends JComponent, I> extends MouseInputAd
} else { } else {
int upperDiff = Math.max(cellBounds.y + cellBounds.height - visibleBounds.y - visibleBounds.height, 0); int upperDiff = Math.max(cellBounds.y + cellBounds.height - visibleBounds.y - visibleBounds.height, 0);
int lowerDiff = Math.max(visibleBounds.y - cellBounds.y, 0); int lowerDiff = Math.max(visibleBounds.y - cellBounds.y, 0);
if (upperDiff > 0) if (upperDiff > 0) lowerDiff = 0;
lowerDiff = 0;
if (upperDiff >= lowerDiff) { if (upperDiff >= lowerDiff) {
rect.y = visibleBounds.y + visibleBounds.height; rect.y = visibleBounds.y + visibleBounds.height;
rect.height = upperDiff; rect.height = upperDiff;
@ -206,10 +202,8 @@ public class CellHintPopupListener<T extends JComponent, I> extends MouseInputAd
} }
public void repaint() { public void repaint() {
if (!cellContainer.getComponent().isShowing()) if (!cellContainer.getComponent().isShowing()) return;
return; if (popup != null) popupComponent.repaint();
if (popup != null)
popupComponent.repaint();
if (lastIndex != null) { if (lastIndex != null) {
Point p = MouseInfo.getPointerInfo().getLocation(); Point p = MouseInfo.getPointerInfo().getLocation();
SwingUtilities.convertPointFromScreen(p, cellContainer.getComponent()); SwingUtilities.convertPointFromScreen(p, cellContainer.getComponent());
@ -246,8 +240,7 @@ public class CellHintPopupListener<T extends JComponent, I> extends MouseInputAd
} }
private void movePopup(final Rectangle bounds) { private void movePopup(final Rectangle bounds) {
if (popup == null) if (popup == null) return;
return;
DarkPopupFactory.PopupType popupType = DarkPopupFactory.getPopupType(popup); DarkPopupFactory.PopupType popupType = DarkPopupFactory.getPopupType(popup);
Window w = DarkUIUtil.getWindow(popupComponent); Window w = DarkUIUtil.getWindow(popupComponent);
if (popupType == DarkPopupFactory.PopupType.HEAVY_WEIGHT) { if (popupType == DarkPopupFactory.PopupType.HEAVY_WEIGHT) {
@ -369,10 +362,8 @@ public class CellHintPopupListener<T extends JComponent, I> extends MouseInputAd
Component renderer = cellHintPopupListener.getRenderer(); Component renderer = cellHintPopupListener.getRenderer();
if (rendererBounds != null && renderer != null) { if (rendererBounds != null && renderer != null) {
Color bg = cellHintPopupListener.getBackground(renderer); Color bg = cellHintPopupListener.getBackground(renderer);
if (bg == null) if (bg == null) bg = cellHintPopupListener.cellContainer.getComponent().getBackground();
bg = cellHintPopupListener.cellContainer.getComponent().getBackground(); if (bg == null) bg = getBackground();
if (bg == null)
bg = getBackground();
if (bg != null) { if (bg != null) {
g.setColor(bg); g.setColor(bg);
g.fillRect(0, 0, getWidth(), getHeight()); g.fillRect(0, 0, getWidth(), getHeight());

18
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorTriangle.java

@ -176,14 +176,12 @@ public class ColorTriangle extends JComponent {
protected void setHSBHue(final double hue) { protected void setHSBHue(final double hue) {
hueHSB = hue; hueHSB = hue;
if (hueHSB < 0) if (hueHSB < 0) hueHSB += 1.0;
hueHSB += 1.0;
} }
protected void setHSLHue(final double hue) { protected void setHSLHue(final double hue) {
hueHSL = hue; hueHSL = hue;
if (hueHSL < 0) if (hueHSL < 0) hueHSL += 1.0;
hueHSL += 1.0;
} }
protected void setValue(final double value) { protected void setValue(final double value) {
@ -310,8 +308,7 @@ public class ColorTriangle extends JComponent {
} }
protected void setColorFromRGB(final Object source, final int r, final int g, final int b) { protected void setColorFromRGB(final Object source, final int r, final int g, final int b) {
if (isMessaging) if (isMessaging) return;
return;
this.color = new Color(r, g, b); this.color = new Color(r, g, b);
double[] hsb = DarkColorModelHSB.RGBtoHSBValues(r, g, b); double[] hsb = DarkColorModelHSB.RGBtoHSBValues(r, g, b);
double[] hsl = DarkColorModelHSL.RGBtoHSLValues(r, g, b); double[] hsl = DarkColorModelHSL.RGBtoHSLValues(r, g, b);
@ -327,8 +324,7 @@ public class ColorTriangle extends JComponent {
} }
protected void setColorFromHSL(final Object source, final double h, final double s, final double l) { protected void setColorFromHSL(final Object source, final double h, final double s, final double l) {
if (isMessaging) if (isMessaging) return;
return;
setHSL(h, s, l); setHSL(h, s, l);
color = DarkColorModelHSL.getColorFromHSLValues(h, s, l); color = DarkColorModelHSL.getColorFromHSLValues(h, s, l);
setHSB(DarkColorModelHSB.RGBtoHSBValues(color.getRed(), color.getGreen(), color.getBlue())); setHSB(DarkColorModelHSB.RGBtoHSBValues(color.getRed(), color.getGreen(), color.getBlue()));
@ -339,8 +335,7 @@ public class ColorTriangle extends JComponent {
} }
protected void setColorFromHSB(final Object source, final double h, final double s, final double b) { protected void setColorFromHSB(final Object source, final double h, final double s, final double b) {
if (isMessaging) if (isMessaging) return;
return;
setHSB(h, s, b); setHSB(h, s, b);
color = DarkColorModelHSB.getColorFromHSBValues(h, s, b); color = DarkColorModelHSB.getColorFromHSBValues(h, s, b);
setHSL(DarkColorModelHSL.RGBtoHSLValues(color.getRed(), color.getGreen(), color.getBlue())); setHSL(DarkColorModelHSL.RGBtoHSLValues(color.getRed(), color.getGreen(), color.getBlue()));
@ -516,8 +511,7 @@ public class ColorTriangle extends JComponent {
protected Shape calculateCircleShape(final double x, final double y, final int size, final int outerSize) { protected Shape calculateCircleShape(final double x, final double y, final int size, final int outerSize) {
outerRadius = size / 2.0; outerRadius = size / 2.0;
innerRadius = outerRadius - outerSize; innerRadius = outerRadius - outerSize;
if (!circleInfo.update(x, y, size, outerSize) && circleShape != null) if (!circleInfo.update(x, y, size, outerSize) && circleShape != null) return circleShape;
return circleShape;
Area outer = new Area(new Ellipse2D.Double(x, y, size, size)); Area outer = new Area(new Ellipse2D.Double(x, y, size, size));
Area inner = new Area( Area inner = new Area(

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

@ -146,24 +146,20 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements
@Override @Override
public void colorChanged(final Color color, final Object source) { public void colorChanged(final Color color, final Object source) {
if (isChanging || color == null) if (isChanging || color == null) return;
return;
isChanging = true; isChanging = true;
currentColor = color; currentColor = color;
ColorSelectionModel model = getColorSelectionModel(); ColorSelectionModel model = getColorSelectionModel();
if (model != null) if (model != null) model.setSelectedColor(currentColor);
model.setSelectedColor(currentColor);
applyColorToFields(color); applyColorToFields(color);
if (source != textHex) if (source != textHex) textHex.setValue(color);
textHex.setValue(color);
previewComponent.setColor(color); previewComponent.setColor(color);
colorWheelPanel.setColor(color, this); colorWheelPanel.setColor(color, this);
isChanging = false; isChanging = false;
} }
protected void onModelChange() { protected void onModelChange() {
if (isChanging) if (isChanging) return;
return;
isChanging = true; isChanging = true;
colorWheelPanel.setModel(getDarkColorModel()); colorWheelPanel.setModel(getDarkColorModel());
updateDescriptors(); updateDescriptors();

3
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkPreviewPanel.java

@ -44,8 +44,7 @@ public class DarkPreviewPanel extends JPanel {
private Color oldColor = null; private Color oldColor = null;
public void paintComponent(final Graphics g) { public void paintComponent(final Graphics g) {
if (oldColor == null) if (oldColor == null) oldColor = getForeground();
oldColor = getForeground();
g.setColor(getBackground()); g.setColor(getBackground());
g.fillRect(0, 0, getWidth(), getHeight()); g.fillRect(0, 0, getWidth(), getHeight());

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

@ -50,14 +50,12 @@ class RecentSwatchPanel extends SwatchPanel {
@Override @Override
public String getToolTipText(final MouseEvent e) { public String getToolTipText(final MouseEvent e) {
Color color = getColorForLocation(e.getX(), e.getY()); Color color = getColorForLocation(e.getX(), e.getY());
if (color == defaultRecentColor || color == null) if (color == defaultRecentColor || color == null) return null;
return null;
return color.getRed() + ", " + color.getGreen() + ", " + color.getBlue(); return color.getRed() + ", " + color.getGreen() + ", " + color.getBlue();
} }
public void setMostRecentColor(final Color c) { public void setMostRecentColor(final Color c) {
if (Objects.equals(colors[0], c)) if (Objects.equals(colors[0], c)) return;
return;
System.arraycopy(colors, 0, colors, 1, colors.length - 1); System.arraycopy(colors, 0, colors, 1, colors.length - 1);
colors[0] = c; colors[0] = c;
repaint(); repaint();

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

@ -86,8 +86,7 @@ class SlideComponent extends JComponent implements ColorListener {
addMouseWheelListener(event -> { addMouseWheelListener(event -> {
int units = event.getUnitsToScroll(); int units = event.getUnitsToScroll();
if (units == 0) if (units == 0) return;
return;
int pointerValue = this.pointerValue + units; int pointerValue = this.pointerValue + units;
pointerValue = Math.max(pointerValue, OFFSET); pointerValue = Math.max(pointerValue, OFFSET);
int size = this.vertical ? getHeight() : getWidth(); int size = this.vertical ? getHeight() : getWidth();
@ -183,8 +182,7 @@ class SlideComponent extends JComponent implements ColorListener {
borderColor = UIManager.getColor("ColorChooser.sliderBorderColor"); borderColor = UIManager.getColor("ColorChooser.sliderBorderColor");
shadowColor = UIManager.getColor("ColorChooser.sliderShadow"); shadowColor = UIManager.getColor("ColorChooser.sliderShadow");
knobFill = UIManager.getColor("ColorChooser.sliderKnobColor"); knobFill = UIManager.getColor("ColorChooser.sliderKnobColor");
if (toolTipContext != null) if (toolTipContext != null) toolTipContext.updateToolTipUI();
toolTipContext.updateToolTipUI();
} }
@Override @Override

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

@ -114,8 +114,7 @@ abstract class SwatchPanel extends JPanel {
@Override @Override
public void updateUI() { public void updateUI() {
super.updateUI(); super.updateUI();
if (toolTipContext != null) if (toolTipContext != null) toolTipContext.updateToolTipUI();
toolTipContext.updateToolTipUI();
} }
protected void initValues() {} protected void initValues() {}
@ -128,8 +127,7 @@ abstract class SwatchPanel extends JPanel {
private Color getColorForCell(final int column, final int row) { private Color getColorForCell(final int column, final int row) {
int index = (row * numSwatches.width) + column; int index = (row * numSwatches.width) + column;
if (index >= colors.length) if (index >= colors.length) return null;
return null;
return colors[(row * numSwatches.width) + column]; return colors[(row * numSwatches.width) + column];
} }
@ -178,8 +176,7 @@ abstract class SwatchPanel extends JPanel {
public String getToolTipText(final MouseEvent e) { public String getToolTipText(final MouseEvent e) {
Color color = getColorForLocation(e.getX(), e.getY()); Color color = getColorForLocation(e.getX(), e.getY());
if (color == null) if (color == null) return null;
return null;
return color.getRed() + ", " + color.getGreen() + ", " + color.getBlue(); return color.getRed() + ", " + color.getGreen() + ", " + color.getBlue();
} }

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

@ -51,10 +51,8 @@ public class DarkComboBoxBorder implements Border, UIResource {
borderColor = UIManager.getColor("ComboBox.activeBorderColor"); borderColor = UIManager.getColor("ComboBox.activeBorderColor");
inactiveBorderColor = UIManager.getColor("ComboBox.inactiveBorderColor"); inactiveBorderColor = UIManager.getColor("ComboBox.inactiveBorderColor");
cellPadding = UIManager.getInsets("ComboBox.cellEditorInsets"); cellPadding = UIManager.getInsets("ComboBox.cellEditorInsets");
if (boxPadding == null) if (boxPadding == null) boxPadding = new Insets(0, 0, 0, 0);
boxPadding = new Insets(0, 0, 0, 0); if (cellPadding == null) cellPadding = new Insets(0, 0, 0, 0);
if (cellPadding == null)
cellPadding = new Insets(0, 0, 0, 0);
} }
@Override @Override

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

@ -75,8 +75,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements ComboBoxConstants
inactiveBackground = UIManager.getColor("ComboBox.inactiveBackground"); inactiveBackground = UIManager.getColor("ComboBox.inactiveBackground");
inactiveForeground = UIManager.getColor("ComboBox.disabledForeground"); inactiveForeground = UIManager.getColor("ComboBox.disabledForeground");
arrowBackground = UIManager.getColor("ComboBox.arrowBackground"); arrowBackground = UIManager.getColor("ComboBox.arrowBackground");
if (boxPadding == null) if (boxPadding == null) boxPadding = new Insets(0, 0, 0, 0);
boxPadding = new Insets(0, 0, 0, 0);
} }
protected void installBorder(final JComponent c) { protected void installBorder(final JComponent c) {
@ -248,18 +247,14 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements ComboBoxConstants
} }
protected Color getBackground(final JComboBox<?> c) { protected Color getBackground(final JComboBox<?> c) {
if (!c.isEnabled()) if (!c.isEnabled()) return inactiveBackground;
return inactiveBackground; if (c.isEditable()) return editBackground;
if (c.isEditable())
return editBackground;
return background; return background;
} }
protected Color getArrowBackground(final JComboBox<?> c) { protected Color getArrowBackground(final JComboBox<?> c) {
if (!c.isEnabled()) if (!c.isEnabled()) return inactiveBackground;
return inactiveBackground; if (c.isEditable()) return arrowBackground;
if (c.isEditable())
return arrowBackground;
return background; return background;
} }
@ -272,8 +267,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements ComboBoxConstants
super.layoutContainer(parent); super.layoutContainer(parent);
if (ComboBoxConstants.isTreeOrTableCellEditor(comboBox)) { if (ComboBoxConstants.isTreeOrTableCellEditor(comboBox)) {
int adj = borderSize / 2; int adj = borderSize / 2;
if (!comboBox.getComponentOrientation().isLeftToRight()) if (!comboBox.getComponentOrientation().isLeftToRight()) adj *= -1;
adj *= -1;
Rectangle bounds = arrowButton.getBounds(); Rectangle bounds = arrowButton.getBounds();
bounds.x += adj; bounds.x += adj;
arrowButton.setBounds(bounds); arrowButton.setBounds(bounds);

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

@ -180,8 +180,7 @@ public class DarkComboPopup extends BasicComboPopup {
@Override @Override
protected void togglePopup() { protected void togglePopup() {
if (comboBox.getItemCount() == 0) if (comboBox.getItemCount() == 0) return;
return;
if (visible) { if (visible) {
visible = false; visible = false;
hide(); hide();

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

@ -117,8 +117,7 @@ public class DarkFileChooserUI extends DarkFileChooserUIBridge {
protected JComponent createControlPanel(final JFileChooser fileChooser) { protected JComponent createControlPanel(final JFileChooser fileChooser) {
JComponent accessoryPanel = getAccessoryPanel(); JComponent accessoryPanel = getAccessoryPanel();
JComponent accessory = fileChooser.getAccessory(); JComponent accessory = fileChooser.getAccessory();
if (accessory != null) if (accessory != null) accessoryPanel.add(accessory);
accessoryPanel.add(accessory);
return accessoryPanel; return accessoryPanel;
} }
@ -366,8 +365,7 @@ public class DarkFileChooserUI extends DarkFileChooserUIBridge {
} }
public BasicFileView getFileView() { public BasicFileView getFileView() {
if (fileView == null) if (fileView == null) fileView = createFileView();
fileView = createFileView();
return fileView; return fileView;
} }
@ -402,8 +400,7 @@ public class DarkFileChooserUI extends DarkFileChooserUIBridge {
} else { } else {
try { try {
String mimeType = Files.probeContentType(f.toPath()); String mimeType = Files.probeContentType(f.toPath());
if (mimeType == null) if (mimeType == null) mimeType = "";
mimeType = "";
if (mimeType.startsWith(MIME_IMAGE)) { if (mimeType.startsWith(MIME_IMAGE)) {
icon = imageFileIcon; icon = imageFileIcon;
} else if (mimeType.startsWith(MIME_TEXT)) { } else if (mimeType.startsWith(MIME_TEXT)) {

3
core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameUI.java

@ -116,8 +116,7 @@ public class DarkInternalFrameUI extends BasicInternalFrameUI implements Propert
} }
protected boolean shouldShowMenuBar(final JInternalFrame internalFrame) { protected boolean shouldShowMenuBar(final JInternalFrame internalFrame) {
if (internalFrame == null) if (internalFrame == null) return false;
return false;
return internalFrame.isSelected() && !internalFrame.isClosed() && !internalFrame.isIcon(); return internalFrame.isSelected() && !internalFrame.isClosed() && !internalFrame.isIcon();
} }
} }

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

@ -51,15 +51,13 @@ public class DarkLabelUI extends BasicLabelUI implements PropertyChangeListener
} }
public static ComponentUI createUI(final JComponent c) { public static ComponentUI createUI(final JComponent c) {
if (darkLabelUI == null) if (darkLabelUI == null) darkLabelUI = new DarkLabelUI();
darkLabelUI = new DarkLabelUI();
return darkLabelUI; return darkLabelUI;
} }
@Override @Override
public void installUI(final JComponent c) { public void installUI(final JComponent c) {
if (c != null) if (c != null) super.installUI(c);
super.installUI(c);
} }
@Override @Override

3
core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java

@ -150,8 +150,7 @@ public class DarkListUI extends DarkListUIBridge implements CellConstants {
for (int column = colCounter - 1; rowBounds.height <= 0 && column >= 0; column--) { for (int column = colCounter - 1; rowBounds.height <= 0 && column >= 0; column--) {
rowBounds.height = getHeight(colCounter - 1, row); rowBounds.height = getHeight(colCounter - 1, row);
} }
if (rowBounds.height <= 0) if (rowBounds.height <= 0) rowBounds.height = getHeight(0, 0);
rowBounds.height = getHeight(0, 0);
g.setClip(rowBounds.x, rowBounds.y, bgWidth > 0 ? bgWidth : rowBounds.width, rowBounds.height); g.setClip(rowBounds.x, rowBounds.y, bgWidth > 0 ? bgWidth : rowBounds.width, rowBounds.height);
g.clipRect(paintBounds.x, paintBounds.y, paintBounds.width, paintBounds.height); g.clipRect(paintBounds.x, paintBounds.y, paintBounds.width, paintBounds.height);

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

@ -77,8 +77,7 @@ public class DarkMenuItemUIBase extends BasicMenuItemUI {
} }
protected boolean isSelected(final JComponent menuItem) { protected boolean isSelected(final JComponent menuItem) {
if (!(menuItem instanceof JMenuItem)) if (!(menuItem instanceof JMenuItem)) return false;
return false;
return menuItem.isEnabled() && ((JMenuItem) menuItem).isArmed(); return menuItem.isEnabled() && ((JMenuItem) menuItem).isArmed();
} }
@ -162,8 +161,7 @@ public class DarkMenuItemUIBase extends BasicMenuItemUI {
protected Color getAcceleratorForeground(final AbstractButton b) { protected Color getAcceleratorForeground(final AbstractButton b) {
ButtonModel model = b.getModel(); ButtonModel model = b.getModel();
if (!model.isEnabled()) if (!model.isEnabled()) return disabledForeground;
return disabledForeground;
if (model.isArmed() || (b instanceof JMenu && model.isSelected())) { if (model.isArmed() || (b instanceof JMenu && model.isSelected())) {
return acceleratorSelectionForeground; return acceleratorSelectionForeground;
} else { } else {

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

@ -77,8 +77,7 @@ public class DarkMenuUI extends BasicMenuUI {
@Override @Override
public void mouseReleased(final MouseEvent e) { public void mouseReleased(final MouseEvent e) {
if (!menu.isEnabled()) if (!menu.isEnabled()) return;
return;
if (pressed && wasEnabled) { if (pressed && wasEnabled) {
pressed = false; pressed = false;
return; return;
@ -117,8 +116,7 @@ public class DarkMenuUI extends BasicMenuUI {
} }
protected boolean isSelected(final JComponent menuItem) { protected boolean isSelected(final JComponent menuItem) {
if (!(menuItem instanceof JMenuItem)) if (!(menuItem instanceof JMenuItem)) return false;
return false;
return menuItem.isEnabled() && ((JMenuItem) menuItem).isArmed(); return menuItem.isEnabled() && ((JMenuItem) menuItem).isArmed();
} }
} }

39
core/src/main/java/com/github/weisj/darklaf/ui/menu/MenuItemLayoutDelegate.java

@ -45,92 +45,79 @@ public class MenuItemLayoutDelegate extends JMenuItem {
@Override @Override
public Insets getInsets(final Insets insets) { public Insets getInsets(final Insets insets) {
if (delegate != null) if (delegate != null) return delegate.getInsets(insets);
return delegate.getInsets(insets);
return super.getInsets(insets); return super.getInsets(insets);
} }
@Override @Override
public Insets getInsets() { public Insets getInsets() {
if (delegate != null) if (delegate != null) return delegate.getInsets();
return delegate.getInsets();
return super.getInsets(); return super.getInsets();
} }
@Override @Override
public Font getFont() { public Font getFont() {
if (delegate != null) if (delegate != null) return delegate.getFont();
return delegate.getFont();
return super.getFont(); return super.getFont();
} }
@Override @Override
public ComponentOrientation getComponentOrientation() { public ComponentOrientation getComponentOrientation() {
if (delegate != null) if (delegate != null) return delegate.getComponentOrientation();
return delegate.getComponentOrientation();
return super.getComponentOrientation(); return super.getComponentOrientation();
} }
@Override @Override
public Container getParent() { public Container getParent() {
if (delegate != null) if (delegate != null) return delegate.getParent();
return delegate.getParent();
return super.getParent(); return super.getParent();
} }
@Override @Override
public KeyStroke getAccelerator() { public KeyStroke getAccelerator() {
if (delegate != null) if (delegate != null) return delegate.getAccelerator();
return delegate.getAccelerator();
return super.getAccelerator(); return super.getAccelerator();
} }
@Override @Override
public int getVerticalAlignment() { public int getVerticalAlignment() {
if (delegate != null) if (delegate != null) return delegate.getVerticalAlignment();
return delegate.getVerticalAlignment();
return super.getVerticalAlignment(); return super.getVerticalAlignment();
} }
@Override @Override
public int getHorizontalAlignment() { public int getHorizontalAlignment() {
if (delegate != null) if (delegate != null) return delegate.getHorizontalAlignment();
return delegate.getHorizontalAlignment();
return super.getHorizontalAlignment(); return super.getHorizontalAlignment();
} }
@Override @Override
public int getVerticalTextPosition() { public int getVerticalTextPosition() {
if (delegate != null) if (delegate != null) return delegate.getVerticalTextPosition();
return delegate.getVerticalTextPosition();
return super.getVerticalTextPosition(); return super.getVerticalTextPosition();
} }
@Override @Override
public int getHorizontalTextPosition() { public int getHorizontalTextPosition() {
if (delegate != null) if (delegate != null) return delegate.getHorizontalTextPosition();
return delegate.getHorizontalTextPosition();
return super.getHorizontalTextPosition(); return super.getHorizontalTextPosition();
} }
@Override @Override
public FontMetrics getFontMetrics(final Font font) { public FontMetrics getFontMetrics(final Font font) {
if (delegate != null) if (delegate != null) return delegate.getFontMetrics(font);
return delegate.getFontMetrics(font);
return super.getFontMetrics(font); return super.getFontMetrics(font);
} }
@Override @Override
public Icon getIcon() { public Icon getIcon() {
if (delegate != null) if (delegate != null) return delegate.getIcon();
return delegate.getIcon();
return super.getIcon(); return super.getIcon();
} }
@Override @Override
public String getText() { public String getText() {
if (delegate != null) if (delegate != null) return delegate.getText();
return delegate.getText();
return super.getText(); return super.getText();
} }
} }

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

@ -141,8 +141,7 @@ public class DarkNumberingPaneUI extends ComponentUI {
g.setColor(c.getBackground()); g.setColor(c.getBackground());
g.fillRect(0, 0, c.getWidth(), c.getHeight()); g.fillRect(0, 0, c.getWidth(), c.getHeight());
} }
if (textComponent == null || viewport == null) if (textComponent == null || viewport == null) return;
return;
FontMetrics metrics = textComponent.getFontMetrics(textComponent.getFont()); FontMetrics metrics = textComponent.getFontMetrics(textComponent.getFont());
int descent = metrics.getDescent(); int descent = metrics.getDescent();
@ -165,12 +164,10 @@ public class DarkNumberingPaneUI extends ComponentUI {
@Override @Override
public Dimension getPreferredSize(final JComponent c) { public Dimension getPreferredSize(final JComponent c) {
if (textComponent == null || viewport == null) if (textComponent == null || viewport == null) return super.getPreferredSize(c);
return super.getPreferredSize(c);
int lines = textComponent.getDocument().getDefaultRootElement().getElementCount(); int lines = textComponent.getDocument().getDefaultRootElement().getElementCount();
int pad = 2 * OUTER_PAD; int pad = 2 * OUTER_PAD;
if (maxIconWidth > 0) if (maxIconWidth > 0) pad += PAD;
pad += PAD;
textWidth = numberingPane.getFontMetrics(numberingPane.getFont()).stringWidth(String.valueOf(lines)); textWidth = numberingPane.getFontMetrics(numberingPane.getFont()).stringWidth(String.valueOf(lines));
return new Dimension(maxIconWidth + pad + textWidth, viewport.getView().getHeight()); return new Dimension(maxIconWidth + pad + textWidth, viewport.getView().getHeight());
} }
@ -253,8 +250,7 @@ public class DarkNumberingPaneUI extends ComponentUI {
@Override @Override
public void mouseClicked(final MouseEvent e) { public void mouseClicked(final MouseEvent e) {
if (textComponent == null) if (textComponent == null) return;
return;
Point p = e.getPoint(); Point p = e.getPoint();
int width = numberingPane.getWidth(); int width = numberingPane.getWidth();
if (p.x > PAD + OUTER_PAD + textWidth && p.x <= width - PAD) { if (p.x > PAD + OUTER_PAD + textWidth && p.x <= width - PAD) {
@ -290,8 +286,7 @@ public class DarkNumberingPaneUI extends ComponentUI {
@Override @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
if (textComponent == null) if (textComponent == null) return;
return;
Point p = e.getPoint(); Point p = e.getPoint();
selectionLineStart = textComponent.viewToModel(new Point(0, p.y)); selectionLineStart = textComponent.viewToModel(new Point(0, p.y));
selectionLineEnd = textComponent.viewToModel(new Point(textComponent.getWidth(), p.y)); selectionLineEnd = textComponent.viewToModel(new Point(textComponent.getWidth(), p.y));
@ -309,8 +304,7 @@ public class DarkNumberingPaneUI extends ComponentUI {
@Override @Override
public void mouseDragged(final MouseEvent e) { public void mouseDragged(final MouseEvent e) {
if (numberingPane.getTextComponent() == null) if (numberingPane.getTextComponent() == null) return;
return;
JTextComponent textPane = numberingPane.getTextComponent(); JTextComponent textPane = numberingPane.getTextComponent();
Point p = e.getPoint(); Point p = e.getPoint();
if (selectionLineEnd >= 0 && selectionLineStart >= 0) { if (selectionLineEnd >= 0 && selectionLineStart >= 0) {

3
core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneBorder.java

@ -31,8 +31,7 @@ public class DarkOptionPaneBorder extends EmptyBorder {
public DarkOptionPaneBorder() { public DarkOptionPaneBorder() {
super(0, 0, 0, 0); super(0, 0, 0, 0);
Insets insets = UIManager.getInsets("OptionPane.borderInsets"); Insets insets = UIManager.getInsets("OptionPane.borderInsets");
if (insets == null) if (insets == null) insets = new Insets(0, 0, 0, 0);
insets = new Insets(0, 0, 0, 0);
left = insets.left; left = insets.left;
right = insets.right; right = insets.right;
top = insets.top; top = insets.top;

3
core/src/main/java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java

@ -32,8 +32,7 @@ public class DarkPanelUI extends BasicPanelUI {
private static PanelUI darkPanelUI; private static PanelUI darkPanelUI;
public static ComponentUI createUI(final JComponent c) { public static ComponentUI createUI(final JComponent c) {
if (darkPanelUI == null) if (darkPanelUI == null) darkPanelUI = new DarkPanelUI();
darkPanelUI = new DarkPanelUI();
return darkPanelUI; return darkPanelUI;
} }
} }

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

@ -101,8 +101,7 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI {
@Override @Override
public Popup getPopup(final JPopupMenu popup, final int x, final int y) { public Popup getPopup(final JPopupMenu popup, final int x, final int y) {
PopupMenuContainer container = getPopupMenuContainer(); PopupMenuContainer container = getPopupMenuContainer();
if (container == null) if (container == null) return super.getPopup(popup, x, y);
return super.getPopup(popup, x, y);
int maxHeight = DarkUIUtil.getScreenBounds(popup, x, y, false).height; int maxHeight = DarkUIUtil.getScreenBounds(popup, x, y, false).height;
return container.createPopup(popup, x, y, maxHeight); return container.createPopup(popup, x, y, maxHeight);
} }

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

@ -28,8 +28,7 @@ public class EventHelperUtil {
private static boolean eventHelperInstallerFlagSet; private static boolean eventHelperInstallerFlagSet;
public static void installEventHelper() { public static void installEventHelper() {
if (eventHelperInstallerFlagSet) if (eventHelperInstallerFlagSet) return;
return;
eventHelperInstallerFlagSet = true; eventHelperInstallerFlagSet = true;
new DummyBasicLookAndFeel().initialize(); new DummyBasicLookAndFeel().initialize();
} }

12
core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabberUtil.java

@ -56,14 +56,11 @@ public class MouseGrabberUtil {
private static ChangeListener getOldMouseGrabber() { private static ChangeListener getOldMouseGrabber() {
MenuSelectionManager menuSelectionManager = MenuSelectionManager.defaultManager(); MenuSelectionManager menuSelectionManager = MenuSelectionManager.defaultManager();
for (ChangeListener listener : menuSelectionManager.getChangeListeners()) { for (ChangeListener listener : menuSelectionManager.getChangeListeners()) {
if (listener == null) if (listener == null) continue;
continue;
Class<?> listenerClass = listener.getClass(); Class<?> listenerClass = listener.getClass();
if (listenerClass == null) if (listenerClass == null) continue;
continue;
Class<?> enclosingClass = listenerClass.getEnclosingClass(); Class<?> enclosingClass = listenerClass.getEnclosingClass();
if (enclosingClass == null) if (enclosingClass == null) continue;
continue;
if (listenerClass.getName().endsWith("MouseGrabber") if (listenerClass.getName().endsWith("MouseGrabber")
&& enclosingClass.getName().endsWith("BasicPopupMenuUI")) { && enclosingClass.getName().endsWith("BasicPopupMenuUI")) {
return listener; return listener;
@ -77,8 +74,7 @@ public class MouseGrabberUtil {
* add our own implementation for it that is a bit more generous with closing the popup. * add our own implementation for it that is a bit more generous with closing the popup.
*/ */
private static void uninstallOldMouseGrabber(final ChangeListener oldMouseGrabber) { private static void uninstallOldMouseGrabber(final ChangeListener oldMouseGrabber) {
if (oldMouseGrabber == null) if (oldMouseGrabber == null) return;
return;
MenuSelectionManager menuSelectionManager = MenuSelectionManager.defaultManager(); MenuSelectionManager menuSelectionManager = MenuSelectionManager.defaultManager();
menuSelectionManager.removeChangeListener(oldMouseGrabber); menuSelectionManager.removeChangeListener(oldMouseGrabber);
if (oldMouseGrabber instanceof AWTEventListener) { if (oldMouseGrabber instanceof AWTEventListener) {

6
core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/PopupMenuContainer.java

@ -65,8 +65,7 @@ public class PopupMenuContainer extends JPanel {
@Override @Override
public void menuKeyPressed(final MenuKeyEvent e) { public void menuKeyPressed(final MenuKeyEvent e) {
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
if (popupMenu == null) if (popupMenu == null) return;
return;
MenuElement[] path = e.getMenuSelectionManager().getSelectedPath(); MenuElement[] path = e.getMenuSelectionManager().getSelectedPath();
if (path.length == 0) { if (path.length == 0) {
return; return;
@ -98,8 +97,7 @@ public class PopupMenuContainer extends JPanel {
} }
private void onHide() { private void onHide() {
if (popupMenu == null) if (popupMenu == null) return;
return;
popupMenu.removePopupMenuListener(this); popupMenu.removePopupMenuListener(this);
popupMenu.removeMenuKeyListener(menuKeyListener); popupMenu.removeMenuKeyListener(menuKeyListener);
} }

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

@ -79,8 +79,7 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
} }
protected void installBorder(final JRootPane root) { protected void installBorder(final JRootPane root) {
if (root == null) if (root == null) return;
return;
LookAndFeel.installBorder(root, borderKeys[windowDecorationsStyle]); LookAndFeel.installBorder(root, borderKeys[windowDecorationsStyle]);
} }
@ -110,12 +109,9 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
protected int decorationsStyleFromWindow(final Window window, final int windowDecorationsStyle) { protected int decorationsStyleFromWindow(final Window window, final int windowDecorationsStyle) {
if (DarkUIUtil.isUndecorated(window) || PropertyUtil.getBooleanProperty(rootPane, KEY_NO_DECORATIONS)) if (DarkUIUtil.isUndecorated(window) || PropertyUtil.getBooleanProperty(rootPane, KEY_NO_DECORATIONS))
return JRootPane.NONE; return JRootPane.NONE;
if (windowDecorationsStyle != JRootPane.NONE) if (windowDecorationsStyle != JRootPane.NONE) return windowDecorationsStyle;
return windowDecorationsStyle; if (window instanceof JFrame) return JRootPane.FRAME;
if (window instanceof JFrame) if (window instanceof JDialog) return JRootPane.PLAIN_DIALOG;
return JRootPane.FRAME;
if (window instanceof JDialog)
return JRootPane.PLAIN_DIALOG;
return windowDecorationsStyle; return windowDecorationsStyle;
} }
@ -155,8 +151,7 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
CustomTitlePane titlePane = DecorationsHandler.getSharedInstance().createTitlePane(root, style, window); CustomTitlePane titlePane = DecorationsHandler.getSharedInstance().createTitlePane(root, style, window);
installLayout(root); installLayout(root);
setTitlePane(root, titlePane); setTitlePane(root, titlePane);
if (titlePane != null) if (titlePane != null) titlePane.setDecorationsStyle(windowDecorationsStyle);
titlePane.setDecorationsStyle(windowDecorationsStyle);
} }
@Override @Override
@ -188,8 +183,7 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
private void updateWindow(final Component parent) { private void updateWindow(final Component parent) {
window = DarkUIUtil.getWindow(parent); window = DarkUIUtil.getWindow(parent);
windowDecorationsStyle = decorationsStyleFromWindow(window, windowDecorationsStyle); windowDecorationsStyle = decorationsStyleFromWindow(window, windowDecorationsStyle);
if (titlePane != null) if (titlePane != null) titlePane.setDecorationsStyle(windowDecorationsStyle);
titlePane.setDecorationsStyle(windowDecorationsStyle);
installBorder(rootPane); installBorder(rootPane);
} }
@ -211,8 +205,7 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
@Override @Override
public void hierarchyChanged(final HierarchyEvent e) { public void hierarchyChanged(final HierarchyEvent e) {
if (rootPane == null) if (rootPane == null) return;
return;
Component parent = rootPane.getParent(); Component parent = rootPane.getParent();
if (parent == null) { if (parent == null) {
return; return;

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

@ -151,14 +151,12 @@ public class DarkScrollBarListener extends MouseAdapter implements AdjustmentLis
@Override @Override
public void adjustmentValueChanged(final AdjustmentEvent e) { public void adjustmentValueChanged(final AdjustmentEvent e) {
if (!e.getValueIsAdjusting()) if (!e.getValueIsAdjusting()) return;
return;
JScrollBar scrollBar = (JScrollBar) e.getAdjustable(); JScrollBar scrollBar = (JScrollBar) e.getAdjustable();
int extent = scrollBar.getModel().getExtent(); int extent = scrollBar.getModel().getExtent();
int value = scrollBar.getValue() + extent; int value = scrollBar.getValue() + extent;
if (value == extent || value == scrollBar.getMaximum()) if (value == extent || value == scrollBar.getMaximum()) return;
return;
Point p = MouseInfo.getPointerInfo().getLocation(); Point p = MouseInfo.getPointerInfo().getLocation();
SwingUtilities.convertPointFromScreen(p, scrollbar); SwingUtilities.convertPointFromScreen(p, scrollbar);

3
core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java

@ -131,8 +131,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI implements ScrollBarConsta
g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
} }
float trackAlpha = scrollBarListener.getTrackAlpha(); float trackAlpha = scrollBarListener.getTrackAlpha();
if (trackAlpha == 0) if (trackAlpha == 0) return;
return;
g.setColor(getTrackColor()); g.setColor(getTrackColor());
((Graphics2D) g).setComposite(COMPOSITE.derive(trackAlpha)); ((Graphics2D) g).setComposite(COMPOSITE.derive(trackAlpha));
g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);

24
core/src/main/java/com/github/weisj/darklaf/ui/separator/DarkSeparatorUI.java

@ -46,13 +46,11 @@ public class DarkSeparatorUI extends BasicSeparatorUI {
color = UIManager.getColor("Separator.foreground"); color = UIManager.getColor("Separator.foreground");
size = UIManager.getDimension("Separator.size"); size = UIManager.getDimension("Separator.size");
insets = UIManager.getInsets("Separator.insets"); insets = UIManager.getInsets("Separator.insets");
if (insets == null) if (insets == null) insets = new Insets(0, 0, 0, 0);
insets = new Insets(0, 0, 0, 0);
} }
public void paint(final Graphics g, final JComponent c) { public void paint(final Graphics g, final JComponent c) {
if (!(c instanceof JSeparator)) if (!(c instanceof JSeparator)) return;
return;
checkSize(c); checkSize(c);
g.setColor(color); g.setColor(color);
if (((JSeparator) c).getOrientation() == JSeparator.VERTICAL) { if (((JSeparator) c).getOrientation() == JSeparator.VERTICAL) {
@ -77,31 +75,25 @@ public class DarkSeparatorUI extends BasicSeparatorUI {
} }
private void checkSize(final JComponent c) { private void checkSize(final JComponent c) {
if (resizeLock) if (resizeLock) return;
return;
Container parent = c.getParent(); Container parent = c.getParent();
if (parent == null) if (parent == null) return;
return;
LayoutManager lm = parent.getLayout(); LayoutManager lm = parent.getLayout();
if (!(lm instanceof BoxLayout || parent instanceof JToolBar)) if (!(lm instanceof BoxLayout || parent instanceof JToolBar)) return;
return;
resizeLock = true; resizeLock = true;
Dimension dim = parent.getSize(); Dimension dim = parent.getSize();
Rectangle bounds = c.getBounds(); Rectangle bounds = c.getBounds();
if (((JSeparator) c).getOrientation() == JSeparator.VERTICAL) { if (((JSeparator) c).getOrientation() == JSeparator.VERTICAL) {
if (bounds.height != dim.height) if (bounds.height != dim.height) c.setBounds(bounds.x, 0, bounds.width, dim.height);
c.setBounds(bounds.x, 0, bounds.width, dim.height);
} else { } else {
if (bounds.width != dim.width) if (bounds.width != dim.width) c.setBounds(0, bounds.y, dim.width, bounds.height);
c.setBounds(0, bounds.y, dim.width, bounds.height);
} }
resizeLock = false; resizeLock = false;
} }
@SuppressWarnings("SuspiciousNameCombination") @SuppressWarnings("SuspiciousNameCombination")
public Dimension getPreferredSize(final JComponent c) { public Dimension getPreferredSize(final JComponent c) {
if (c == null) if (c == null) return new Dimension(size);
return new Dimension(size);
if (((JSeparator) c).getOrientation() == JSeparator.VERTICAL) { if (((JSeparator) c).getOrientation() == JSeparator.VERTICAL) {
return new Dimension(size.width, size.height); return new Dimension(size.width, size.height);
} else { } else {

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

@ -781,8 +781,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
int pos = isHorizontal() ? evt.getX() : evt.getY(); int pos = isHorizontal() ? evt.getX() : evt.getY();
int loc = getLocationForValue(getSnappedValue(evt)); int loc = getLocationForValue(getSnappedValue(evt));
offset = (loc < 0) ? 0 : pos - loc; offset = (loc < 0) ? 0 : pos - loc;
if (iconRect.contains(evt.getPoint())) if (iconRect.contains(evt.getPoint())) return;
return;
super.mousePressed(evt); super.mousePressed(evt);
} }

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

@ -55,10 +55,8 @@ public class DarkSpinnerBorder implements Border, UIResource {
borderSize = UIManager.getInt("Spinner.borderThickness"); borderSize = UIManager.getInt("Spinner.borderThickness");
cellInsets = UIManager.getInsets("Spinner.cellEditorInsets"); cellInsets = UIManager.getInsets("Spinner.cellEditorInsets");
insets = UIManager.getInsets("Spinner.insets"); insets = UIManager.getInsets("Spinner.insets");
if (insets == null) if (insets == null) insets = new Insets(0, 0, 0, 0);
insets = new Insets(0, 0, 0, 0); if (cellInsets == null) cellInsets = new Insets(0, 0, 0, 0);
if (cellInsets == null)
cellInsets = new Insets(0, 0, 0, 0);
} }
@Override @Override

3
core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java

@ -133,8 +133,7 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements SpinnerConstants {
super.layoutContainer(parent); super.layoutContainer(parent);
if (SpinnerConstants.isTreeOrTableCellEditor(spinner)) { if (SpinnerConstants.isTreeOrTableCellEditor(spinner)) {
int adj = borderSize / 2; int adj = borderSize / 2;
if (!spinner.getComponentOrientation().isLeftToRight()) if (!spinner.getComponentOrientation().isLeftToRight()) adj *= -1;
adj *= -1;
adjustButton(prevButton, adj); adjustButton(prevButton, adj);
adjustButton(nextButton, adj); adjustButton(nextButton, adj);
} }

18
core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DividerStyle.java

@ -22,9 +22,9 @@
package com.github.weisj.darklaf.ui.splitpane; package com.github.weisj.darklaf.ui.splitpane;
public enum DividerStyle { public enum DividerStyle {
GRIP(SplitPaneConstants.STYLE_GRIP, false, true), GRIP_BORDERLESS(SplitPaneConstants.STYLE_GRIP_BORDERLESS, false, GRIP(SplitPaneConstants.STYLE_GRIP, false, true),
false), LINE(SplitPaneConstants.STYLE_LINE, true, GRIP_BORDERLESS(SplitPaneConstants.STYLE_GRIP_BORDERLESS, false, false),
true), INVISIBLE(SplitPaneConstants.STYLE_INVISIBLE, true, false); LINE(SplitPaneConstants.STYLE_LINE, true, true), INVISIBLE(SplitPaneConstants.STYLE_INVISIBLE, true, false);
private final String name; private final String name;
private final boolean isThin; private final boolean isThin;
@ -42,8 +42,7 @@ public enum DividerStyle {
public static DividerStyle get(final Object style, final DividerStyle fallback) { public static DividerStyle get(final Object style, final DividerStyle fallback) {
DividerStyle s = getNullableStyle(style); DividerStyle s = getNullableStyle(style);
if (s == null) if (s == null) return fallback;
return fallback;
return s; return s;
} }
@ -65,17 +64,14 @@ public enum DividerStyle {
} }
static DividerStyle getNullableStyle(final Object obj) { static DividerStyle getNullableStyle(final Object obj) {
if (obj == null) if (obj == null) return null;
return null; if (obj instanceof DividerStyle) return (DividerStyle) obj;
if (obj instanceof DividerStyle)
return (DividerStyle) obj;
try { try {
return valueOf(obj.toString()); return valueOf(obj.toString());
} catch (IllegalArgumentException ignored) { } catch (IllegalArgumentException ignored) {
} }
for (DividerStyle s : values()) { for (DividerStyle s : values()) {
if (s.name.equalsIgnoreCase(obj.toString())) if (s.name.equalsIgnoreCase(obj.toString())) return s;
return s;
} }
return null; return null;
} }

3
core/src/main/java/com/github/weisj/darklaf/ui/splitpane/ThinSplitPaneDivider.java

@ -55,8 +55,7 @@ final class ThinSplitPaneDivider extends BasicSplitPaneDivider {
@Override @Override
public boolean contains(final Point p) { public boolean contains(final Point p) {
if (!isEnabled()) if (!isEnabled()) return false;
return false;
return super.contains(p); return super.contains(p);
} }

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

@ -96,8 +96,7 @@ public class DarkScrollableTabSupport extends ScrollableTabSupport implements Mo
if (scrollPopupMenu.isVisible()) { if (scrollPopupMenu.isVisible()) {
scrollPopupMenu.setVisible(false); scrollPopupMenu.setVisible(false);
} else { } else {
if (!ui.tabPane.isEnabled()) if (!ui.tabPane.isEnabled()) return;
return;
if (lastClickEvent == 0 || (System.currentTimeMillis() - lastClickEvent) > 250) { if (lastClickEvent == 0 || (System.currentTimeMillis() - lastClickEvent) > 250) {
Dimension pref = scrollPopupMenu.getPreferredSize(); Dimension pref = scrollPopupMenu.getPreferredSize();
boolean leftToRight = ui.tabPane.getComponentOrientation().isLeftToRight(); boolean leftToRight = ui.tabPane.getComponentOrientation().isLeftToRight();
@ -135,19 +134,16 @@ public class DarkScrollableTabSupport extends ScrollableTabSupport implements Mo
@Override @Override
public void mouseWheelMoved(final MouseWheelEvent e) { public void mouseWheelMoved(final MouseWheelEvent e) {
if (!ui.tabPane.isEnabled() || ui.tabPane.getTabCount() == 0) if (!ui.tabPane.isEnabled() || ui.tabPane.getTabCount() == 0) return;
return;
int tabPosition = ui.tabPane.getTabPlacement(); int tabPosition = ui.tabPane.getTabPlacement();
int scrollAmount = -1 * e.getUnitsToScroll() * e.getScrollAmount(); int scrollAmount = -1 * e.getUnitsToScroll() * e.getScrollAmount();
int scrolled; int scrolled;
if (tabPosition == SwingConstants.LEFT || tabPosition == SwingConstants.RIGHT) { if (tabPosition == SwingConstants.LEFT || tabPosition == SwingConstants.RIGHT) {
if (e.isShiftDown() || !moreTabsButton.isVisible()) if (e.isShiftDown() || !moreTabsButton.isVisible()) return;
return;
timer.stop(); timer.stop();
scrolled = scroll(scrollAmount, false); scrolled = scroll(scrollAmount, false);
} else { } else {
if (!e.isShiftDown() || !moreTabsButton.isVisible()) if (!e.isShiftDown() || !moreTabsButton.isVisible()) return;
return;
timer.stop(); timer.stop();
scrolled = scroll(scrollAmount, true); scrolled = scroll(scrollAmount, true);
} }

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

@ -108,8 +108,7 @@ public class DarkTabbedPaneHandler extends TabbedPaneHandler {
} else if (DarkTabbedPaneUI.KEY_DND.equals(key)) { } else if (DarkTabbedPaneUI.KEY_DND.equals(key)) {
ui.dndEnabled = PropertyUtil.getBooleanProperty(ui.tabPane, DarkTabbedPaneUI.KEY_DND); ui.dndEnabled = PropertyUtil.getBooleanProperty(ui.tabPane, DarkTabbedPaneUI.KEY_DND);
DropTarget dropTarget = ui.tabPane.getDropTarget(); DropTarget dropTarget = ui.tabPane.getDropTarget();
if (dropTarget != null) if (dropTarget != null) dropTarget.setActive(ui.dndEnabled);
dropTarget.setActive(ui.dndEnabled);
} else if (PropertyKey.COMPONENT_ORIENTATION.equals(key)) { } else if (PropertyKey.COMPONENT_ORIENTATION.equals(key)) {
ui.tabPane.doLayout(); ui.tabPane.doLayout();
ui.tabPane.repaint(); ui.tabPane.repaint();
@ -183,8 +182,7 @@ public class DarkTabbedPaneHandler extends TabbedPaneHandler {
@Override @Override
public void mouseDragged(final MouseEvent e) { public void mouseDragged(final MouseEvent e) {
super.mouseDragged(e); super.mouseDragged(e);
if (!ui.dndEnabled) if (!ui.dndEnabled) return;
return;
if (origin == null) { if (origin == null) {
origin = e.getPoint(); origin = e.getPoint();
pressedIndex = ui.tabForCoordinate(ui.tabPane, e.getX(), e.getY()); pressedIndex = ui.tabForCoordinate(ui.tabPane, e.getX(), e.getY());

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

@ -292,8 +292,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
ui.runCount = 0; ui.runCount = 0;
ui.selectedRun = -1; ui.selectedRun = -1;
if (tabCount == 0) if (tabCount == 0) return;
return;
ui.selectedRun = 0; ui.selectedRun = 0;
ui.runCount = 1; ui.runCount = 1;
@ -475,8 +474,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
if (horizontal) { if (horizontal) {
if (leftToRight) { if (leftToRight) {
if (ui.rects[tabCount - 1].x + ui.rects[tabCount - 1].width + buttonBounds.width > maxVal) { if (ui.rects[tabCount - 1].x + ui.rects[tabCount - 1].width + buttonBounds.width > maxVal) {
if (button.getParent() != ui.tabPane) if (button.getParent() != ui.tabPane) ui.tabPane.add(button);
ui.tabPane.add(button);
} else { } else {
if (button.getParent() != ui.scrollableTabSupport.tabPanel) { if (button.getParent() != ui.scrollableTabSupport.tabPanel) {
ui.scrollableTabSupport.tabPanel.add(button); ui.scrollableTabSupport.tabPanel.add(button);
@ -485,8 +483,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
} else { } else {
int x = ui.rects[tabCount - 1].x; int x = ui.rects[tabCount - 1].x;
if (x - buttonBounds.width < minVal) { if (x - buttonBounds.width < minVal) {
if (button.getParent() != ui.tabPane) if (button.getParent() != ui.tabPane) ui.tabPane.add(button);
ui.tabPane.add(button);
} else { } else {
if (button.getParent() != ui.scrollableTabSupport.tabPanel) { if (button.getParent() != ui.scrollableTabSupport.tabPanel) {
ui.scrollableTabSupport.tabPanel.add(button); ui.scrollableTabSupport.tabPanel.add(button);
@ -495,8 +492,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
} }
} else { } else {
if (ui.rects[tabCount - 1].y + ui.rects[tabCount - 1].height + buttonBounds.height > maxVal) { if (ui.rects[tabCount - 1].y + ui.rects[tabCount - 1].height + buttonBounds.height > maxVal) {
if (button.getParent() != ui.tabPane) if (button.getParent() != ui.tabPane) ui.tabPane.add(button);
ui.tabPane.add(button);
} else { } else {
if (button.getParent() != ui.scrollableTabSupport.tabPanel) { if (button.getParent() != ui.scrollableTabSupport.tabPanel) {
ui.scrollableTabSupport.tabPanel.add(button); ui.scrollableTabSupport.tabPanel.add(button);
@ -581,16 +577,14 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
} }
protected void restoreHiddenTabsX(final int minX, final int maxX, final int tabCount) { protected void restoreHiddenTabsX(final int minX, final int maxX, final int tabCount) {
if (ui.maxVisible < 0 || ui.maxVisible >= tabCount) if (ui.maxVisible < 0 || ui.maxVisible >= tabCount) return;
return;
int space = Math.max(maxX - ui.rects[ui.maxVisible].x - ui.rects[ui.maxVisible].width - ui.currentShiftXTmp, 0); int space = Math.max(maxX - ui.rects[ui.maxVisible].x - ui.rects[ui.maxVisible].width - ui.currentShiftXTmp, 0);
int shift = Math.min(minX - ui.rects[0].x - ui.currentShiftXTmp, space); int shift = Math.min(minX - ui.rects[0].x - ui.currentShiftXTmp, space);
shiftTabsX(shift, minX, maxX, tabCount, true); shiftTabsX(shift, minX, maxX, tabCount, true);
} }
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) if (ui.maxVisible < 0 || ui.maxVisible >= tabCount) return;
return;
int space = int space =
Math.max(maxY - ui.rects[ui.maxVisible].y - ui.rects[ui.maxVisible].height - ui.currentShiftYTmp, 0); 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);

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

@ -242,8 +242,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
protected void paintFocusIndicator(final Graphics g, final int tabPlacement, final Rectangle r, final int tabIndex, protected void paintFocusIndicator(final Graphics g, final int tabPlacement, final Rectangle r, final int tabIndex,
final Rectangle iconRect, final Rectangle textRect, final boolean isSelected) { final Rectangle iconRect, final Rectangle textRect, final boolean isSelected) {
if (isSelected) { if (isSelected) {
if (!drawFocusBar()) if (!drawFocusBar()) return;
return;
g.setColor(getAccentColor()); g.setColor(getAccentColor());
switch (tabPlacement) { switch (tabPlacement) {
case LEFT: case LEFT:
@ -355,8 +354,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
@Override @Override
public void setRolloverTab(final int index) { public void setRolloverTab(final int index) {
if (dragging) if (dragging) return;
return;
int oldRollover = rolloverTabIndex; int oldRollover = rolloverTabIndex;
super.setRolloverTab(index); super.setRolloverTab(index);
if (oldRollover != getRolloverTab()) { if (oldRollover != getRolloverTab()) {
@ -413,10 +411,8 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
int height = int height =
Math.max(super.calculateTabAreaHeight(tabPlacement, horizRunCount, maxTabHeight), getFallBackSize()); Math.max(super.calculateTabAreaHeight(tabPlacement, horizRunCount, maxTabHeight), getFallBackSize());
if (isHorizontalTabPlacement()) { if (isHorizontalTabPlacement()) {
if (leadingComp != null) if (leadingComp != null) height = Math.max(height, leadingComp.getPreferredSize().height);
height = Math.max(height, leadingComp.getPreferredSize().height); if (trailingComp != null) height = Math.max(height, trailingComp.getPreferredSize().height);
if (trailingComp != null)
height = Math.max(height, trailingComp.getPreferredSize().height);
} }
return height; return height;
} }
@ -425,10 +421,8 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
protected int calculateTabAreaWidth(final int tabPlacement, final int vertRunCount, final int maxTabWidth) { protected int calculateTabAreaWidth(final int tabPlacement, final int vertRunCount, final int maxTabWidth) {
int width = Math.max(super.calculateTabAreaWidth(tabPlacement, vertRunCount, maxTabWidth), getFallBackSize()); int width = Math.max(super.calculateTabAreaWidth(tabPlacement, vertRunCount, maxTabWidth), getFallBackSize());
if (!isHorizontalTabPlacement()) { if (!isHorizontalTabPlacement()) {
if (leadingComp != null) if (leadingComp != null) width = Math.max(width, leadingComp.getPreferredSize().width);
width = Math.max(width, leadingComp.getPreferredSize().width); if (trailingComp != null) width = Math.max(width, trailingComp.getPreferredSize().width);
if (trailingComp != null)
width = Math.max(width, trailingComp.getPreferredSize().width);
} }
return width; return width;
} }
@ -646,8 +640,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
} }
protected Icon getMoreTabsIcon() { protected Icon getMoreTabsIcon() {
if (moreTabsIcon == null) if (moreTabsIcon == null) moreTabsIcon = UIManager.getIcon("TabbedPane.moreTabs.icon");
moreTabsIcon = UIManager.getIcon("TabbedPane.moreTabs.icon");
return moreTabsIcon; return moreTabsIcon;
} }
@ -812,8 +805,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
} }
public Icon getNewTabIcon() { public Icon getNewTabIcon() {
if (newTabIcon == null) if (newTabIcon == null) newTabIcon = UIManager.getIcon("TabbedPane.newTab.icon");
newTabIcon = UIManager.getIcon("TabbedPane.newTab.icon");
return newTabIcon; return newTabIcon;
} }

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

@ -747,14 +747,10 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
// Fix for 6711145 BasicTabbedPanuUI should not throw a NPE if these // Fix for 6711145 BasicTabbedPanuUI should not throw a NPE if these
// keys are missing. So we are setting them to there default values here // keys are missing. So we are setting them to there default values here
// if the keys are missing. // if the keys are missing.
if (tabInsets == null) if (tabInsets == null) tabInsets = new Insets(0, 4, 1, 4);
tabInsets = new Insets(0, 4, 1, 4); if (selectedTabPadInsets == null) selectedTabPadInsets = new Insets(2, 2, 2, 1);
if (selectedTabPadInsets == null) if (tabAreaInsets == null) tabAreaInsets = new Insets(3, 2, 0, 2);
selectedTabPadInsets = new Insets(2, 2, 2, 1); if (contentBorderInsets == null) contentBorderInsets = new Insets(2, 2, 3, 3);
if (tabAreaInsets == null)
tabAreaInsets = new Insets(3, 2, 0, 2);
if (contentBorderInsets == null)
contentBorderInsets = new Insets(2, 2, 3, 3);
} }
// UI Rendering // UI Rendering

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

@ -448,8 +448,7 @@ public abstract class TabbedPaneLayout implements LayoutManager {
protected void rotateTabRuns(final int tabPlacement, final int selectedRun) { protected void rotateTabRuns(final int tabPlacement, final int selectedRun) {
for (int i = 0; i < selectedRun; i++) { for (int i = 0; i < selectedRun; i++) {
int save = ui.tabRuns[0]; int save = ui.tabRuns[0];
if (ui.runCount - 1 >= 0) if (ui.runCount - 1 >= 0) System.arraycopy(ui.tabRuns, 1, ui.tabRuns, 0, ui.runCount - 1);
System.arraycopy(ui.tabRuns, 1, ui.tabRuns, 0, ui.runCount - 1);
ui.tabRuns[ui.runCount - 1] = save; ui.tabRuns[ui.runCount - 1] = save;
} }
} }

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

@ -291,8 +291,7 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa
@Override @Override
public DataFlavor[] getTransferDataFlavors() { public DataFlavor[] getTransferDataFlavors() {
if (tabFlavor == null) if (tabFlavor == null) return new DataFlavor[0];
return new DataFlavor[0];
return new DataFlavor[] {tabFlavor}; return new DataFlavor[] {tabFlavor};
} }

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

@ -109,8 +109,7 @@ public class TabbedPaneUtil implements SwingConstants {
public static Rectangle getDropRect(final DarkTabbedPaneUI ui, final JTabbedPane destTabbedPane, public static Rectangle getDropRect(final DarkTabbedPaneUI ui, final JTabbedPane destTabbedPane,
final JTabbedPane source, final Point mouseLocation, final Rectangle tabBounds, final int tab, final JTabbedPane source, final Point mouseLocation, final Rectangle tabBounds, final int tab,
final int sourceIndex, final int lastTab) { final int sourceIndex, final int lastTab) {
if (destTabbedPane.getTabCount() == 0) if (destTabbedPane.getTabCount() == 0) return new Rectangle(0, 0, 0, 0);
return new Rectangle(0, 0, 0, 0);
int tabPlacement = destTabbedPane.getTabPlacement(); int tabPlacement = destTabbedPane.getTabPlacement();
Rectangle destRect = destTabbedPane.getBoundsAt(Math.min(tab, destTabbedPane.getTabCount() - 1)); Rectangle destRect = destTabbedPane.getBoundsAt(Math.min(tab, destTabbedPane.getTabCount() - 1));
@ -233,14 +232,12 @@ public class TabbedPaneUtil implements SwingConstants {
if (tabbedPane == sourcePane && sourceIndex == tab) { if (tabbedPane == sourcePane && sourceIndex == tab) {
// Nothing to do. Just select the tab to be sure. // Nothing to do. Just select the tab to be sure.
Component comp = sourcePane.getTabComponentAt(tab); Component comp = sourcePane.getTabComponentAt(tab);
if (comp != null) if (comp != null) comp.setVisible(true);
comp.setVisible(true);
selectTab(sourcePane, sourceIndex); selectTab(sourcePane, sourceIndex);
return false; return false;
} }
int destIndex = tab; int destIndex = tab;
if (tabbedPane.getTabCount() == 0) if (tabbedPane.getTabCount() == 0) destIndex = 0;
destIndex = 0;
if (destIndex < 0 || destIndex > tabbedPane.getTabCount()) { if (destIndex < 0 || destIndex > tabbedPane.getTabCount()) {
return false; return false;
} }
@ -256,8 +253,7 @@ public class TabbedPaneUtil implements SwingConstants {
int index = destIndex; int index = destIndex;
if (tabbedPane == sourcePane) { if (tabbedPane == sourcePane) {
if (sourceIndex < index) if (sourceIndex < index) index--;
index--;
} }
tabbedPane.insertTab(tabName, icon, comp, toolTip, index); tabbedPane.insertTab(tabName, icon, comp, toolTip, index);

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

@ -234,18 +234,15 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe
setHeaderBackground(true); setHeaderBackground(true);
} }
} else if (TabFramePopup.KEY_CONTENT.equals(key)) { } else if (TabFramePopup.KEY_CONTENT.equals(key)) {
if (content == null) if (content == null) return;
return;
content.add((Component) evt.getNewValue(), BorderLayout.CENTER); content.add((Component) evt.getNewValue(), BorderLayout.CENTER);
content.invalidate(); content.invalidate();
} else if (TabFramePopup.KEY_TITLE.equals(key)) { } else if (TabFramePopup.KEY_TITLE.equals(key)) {
if (label == null) if (label == null) return;
return;
label.setText(evt.getNewValue().toString()); label.setText(evt.getNewValue().toString());
label.repaint(); label.repaint();
} else if (TabFramePopup.KEY_ICON.equals(key)) { } else if (TabFramePopup.KEY_ICON.equals(key)) {
if (label == null) if (label == null) return;
return;
label.setIcon((Icon) evt.getNewValue()); label.setIcon((Icon) evt.getNewValue());
label.repaint(); label.repaint();
} else if (TabFramePopup.KEY_VISIBLE_TAB.equals(key)) { } else if (TabFramePopup.KEY_VISIBLE_TAB.equals(key)) {
@ -358,10 +355,8 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe
public void eventDispatched(final AWTEvent event) { public void eventDispatched(final AWTEvent event) {
if (event.getID() == FocusEvent.FOCUS_GAINED) { if (event.getID() == FocusEvent.FOCUS_GAINED) {
Component focusOwner = FocusManager.getCurrentManager().getFocusOwner(); Component focusOwner = FocusManager.getCurrentManager().getFocusOwner();
if (focusOwner instanceof JTabFrame) if (focusOwner instanceof JTabFrame) return;
return; 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 = Container container =

18
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java

@ -91,11 +91,9 @@ public class DarkTabFrameTabContainerUI extends DarkPanelUI implements PropertyC
} }
protected void installAccelerator(final JTabFrame tabFrame) { protected void installAccelerator(final JTabFrame tabFrame) {
if (tabFrame == null) if (tabFrame == null) return;
return;
int acc = tabContainer.getAccelerator(); int acc = tabContainer.getAccelerator();
if (acc < 0) if (acc < 0) return;
return;
tabFrame.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( tabFrame.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
KeyStroke.getKeyStroke(UIManager.getString("TabFrame.acceleratorKeyCode") + " " + acc), KeyStroke.getKeyStroke(UIManager.getString("TabFrame.acceleratorKeyCode") + " " + acc),
ACCELERATOR_PREFIX + acc); ACCELERATOR_PREFIX + acc);
@ -148,8 +146,7 @@ public class DarkTabFrameTabContainerUI extends DarkPanelUI implements PropertyC
} }
protected void uninstallAccelerator(final JTabFrame tabFrame) { protected void uninstallAccelerator(final JTabFrame tabFrame) {
if (tabFrame == null) if (tabFrame == null) return;
return;
int acc = tabContainer.getAccelerator(); int acc = tabContainer.getAccelerator();
String accAction = ACCELERATOR_PREFIX + acc; String accAction = ACCELERATOR_PREFIX + acc;
tabFrame.getActionMap().remove(accAction); tabFrame.getActionMap().remove(accAction);
@ -181,12 +178,10 @@ public class DarkTabFrameTabContainerUI extends DarkPanelUI implements PropertyC
((Component) newVal).addMouseMotionListener(dragListener); ((Component) newVal).addMouseMotionListener(dragListener);
} }
} else if (TabFrameTab.KEY_SELECTED.equals(key)) { } else if (TabFrameTab.KEY_SELECTED.equals(key)) {
if (tabContainer == null) if (tabContainer == null) return;
return;
tabContainer.repaint(); tabContainer.repaint();
} else if (TabFrameTab.KEY_ACCELERATOR.equals(key)) { } else if (TabFrameTab.KEY_ACCELERATOR.equals(key)) {
if (tabContainer == null) if (tabContainer == null) return;
return;
uninstallAccelerator(tabContainer.getTabFrame()); uninstallAccelerator(tabContainer.getTabFrame());
installAccelerator(tabContainer.getTabFrame()); installAccelerator(tabContainer.getTabFrame());
} else if (TabFrameTab.KEY_TAB_FRAME_PARENT.equals(key)) { } else if (TabFrameTab.KEY_TAB_FRAME_PARENT.equals(key)) {
@ -209,8 +204,7 @@ public class DarkTabFrameTabContainerUI extends DarkPanelUI implements PropertyC
} }
public Color getBackground(final TabFrameTabContainer tab) { public Color getBackground(final TabFrameTabContainer tab) {
if (printing) if (printing) return tab.getBackground();
return tab.getBackground();
return tab.isSelected() ? selectedColor return tab.isSelected() ? selectedColor
: hoverListener.isHover() && !tab.getTabFrame().isInTransfer() ? hoverColor : tab.getBackground(); : hoverListener.isHover() && !tab.getTabFrame().isInTransfer() ? hoverColor : tab.getBackground();
} }

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

@ -50,8 +50,7 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang
private final MouseListener mouseListener = new MouseAdapter() { private final MouseListener mouseListener = new MouseAdapter() {
@Override @Override
public void mouseClicked(final MouseEvent e) { public void mouseClicked(final MouseEvent e) {
if (!tabComponent.isEnabled()) if (!tabComponent.isEnabled()) return;
return;
if (SwingUtilities.isLeftMouseButton(e)) { if (SwingUtilities.isLeftMouseButton(e)) {
tabComponent.getTabFrame().toggleTab(tabComponent.getOrientation(), tabComponent.getIndex(), tabComponent.getTabFrame().toggleTab(tabComponent.getOrientation(), tabComponent.getIndex(),
!tabComponent.isSelected()); !tabComponent.isSelected());
@ -143,8 +142,7 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang
updateText(); updateText();
} else if (TabFrameTab.KEY_ACCELERATOR.equals(key)) { } else if (TabFrameTab.KEY_ACCELERATOR.equals(key)) {
updateText(); updateText();
if (tabComponent == null) if (tabComponent == null) return;
return;
uninstallAccelerator(tabComponent.getTabFrame()); uninstallAccelerator(tabComponent.getTabFrame());
installAccelerator(tabComponent.getTabFrame()); installAccelerator(tabComponent.getTabFrame());
} else if (TabFrameTab.KEY_ORIENTATION.equals(key)) { } else if (TabFrameTab.KEY_ORIENTATION.equals(key)) {
@ -175,11 +173,9 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang
} }
protected void installAccelerator(final JTabFrame tabFrame) { protected void installAccelerator(final JTabFrame tabFrame) {
if (tabFrame == null) if (tabFrame == null) return;
return;
int acc = tabComponent.getAccelerator(); int acc = tabComponent.getAccelerator();
if (acc < 0) if (acc < 0) return;
return;
tabFrame.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( tabFrame.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
KeyStroke.getKeyStroke(UIManager.getString("TabFrame.acceleratorKeyCode") + " " + acc), KeyStroke.getKeyStroke(UIManager.getString("TabFrame.acceleratorKeyCode") + " " + acc),
ACCELERATOR_PREFIX + acc); ACCELERATOR_PREFIX + acc);
@ -207,16 +203,14 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang
} }
protected void uninstallAccelerator(final JTabFrame tabFrame) { protected void uninstallAccelerator(final JTabFrame tabFrame) {
if (tabFrame == null) if (tabFrame == null) return;
return;
int acc = tabComponent.getAccelerator(); int acc = tabComponent.getAccelerator();
String accAction = ACCELERATOR_PREFIX + acc; String accAction = ACCELERATOR_PREFIX + acc;
tabFrame.getActionMap().remove(accAction); tabFrame.getActionMap().remove(accAction);
} }
public Color getBackground(final TabFrameTabLabel tab) { public Color getBackground(final TabFrameTabLabel tab) {
if (printing || !tab.isEnabled()) if (printing || !tab.isEnabled()) return tab.getBackground();
return tab.getBackground();
return tab.isSelected() ? selectedColor return tab.isSelected() ? selectedColor
: hoverListener.isHover() && !tab.getTabFrame().isInTransfer() ? hoverColor : tab.getBackground(); : hoverListener.isHover() && !tab.getTabFrame().isInTransfer() ? hoverColor : tab.getBackground();
} }
@ -227,8 +221,7 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang
} }
public Color getTabForeground(final TabFrameTabLabel tab) { public Color getTabForeground(final TabFrameTabLabel tab) {
if (printing) if (printing) return tab.getForeground();
return tab.getForeground();
return tab.isSelected() ? selectedFontColor return tab.isSelected() ? selectedFontColor
: hoverListener.isHover() && !tab.getTabFrame().isInTransfer() ? fontHoverColor : tab.getForeground(); : hoverListener.isHover() && !tab.getTabFrame().isInTransfer() ? fontHoverColor : tab.getForeground();
} }

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

Loading…
Cancel
Save