diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/UIAction.java b/core/src/main/java/com/github/weisj/darklaf/ui/UIAction.java index 291ea00d7..addd74c4c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/UIAction.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/UIAction.java @@ -1,8 +1,30 @@ +/* + * MIT License + * + * Copyright (c) 2021 Jannis Weis + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ package com.github.weisj.darklaf.ui; -import javax.swing.Action; import java.beans.PropertyChangeListener; +import javax.swing.Action; + public abstract class UIAction implements Action { private final String name; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java index d9b988255..b539bbc91 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java @@ -36,11 +36,9 @@ import javax.swing.plaf.basic.BasicListUI; import javax.swing.text.Position; -import sun.swing.DefaultLookup; -import com.github.weisj.darklaf.ui.UIAction; - import com.github.weisj.darklaf.ui.BasicTransferable; import com.github.weisj.darklaf.ui.DragRecognitionSupport; +import com.github.weisj.darklaf.ui.UIAction; import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.LazyActionMap; import com.github.weisj.darklaf.util.PropertyKey; @@ -615,11 +613,11 @@ protected Handler getHandler() { */ InputMap getInputMap(final int condition) { if (condition == JComponent.WHEN_FOCUSED) { - InputMap keyMap = (InputMap) DefaultLookup.get(list, this, "List.focusInputMap"); + InputMap keyMap = (InputMap) UIManager.get("List.focusInputMap", list.getLocale()); InputMap rtlKeyMap; if (isLeftToRight || ((rtlKeyMap = - (InputMap) DefaultLookup.get(list, this, "List.focusInputMap.RightToLeft")) == null)) { + (InputMap) UIManager.get("List.focusInputMap.RightToLeft", list.getLocale())) == null)) { return keyMap; } else { rtlKeyMap.setParent(keyMap); @@ -1248,7 +1246,7 @@ protected void paintDropLine(final Graphics g) { return; } - Color c = DefaultLookup.getColor(list, this, "List.dropLineColor", null); + Color c = UIManager.getColor("List.dropLineColor"); if (c != null) { g.setColor(c); Rectangle rect = getDropLineRect(loc); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java b/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java index 2f12f06c0..cc1fba4c3 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java @@ -29,8 +29,8 @@ import javax.swing.plaf.basic.BasicMenuItemUI; import sun.swing.MenuItemLayoutHelper; -import com.github.weisj.darklaf.ui.UIAction; +import com.github.weisj.darklaf.ui.UIAction; import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.LazyActionMap; import com.github.weisj.darklaf.util.StringUtil; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneUI.java index e3cf867a5..4ca527896 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneUI.java @@ -28,7 +28,6 @@ import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicOptionPaneUI; -import sun.swing.DefaultLookup; public class DarkOptionPaneUI extends BasicOptionPaneUI { @@ -39,16 +38,16 @@ public static ComponentUI createUI(final JComponent x) { @Override protected Container createButtonArea() { JPanel bottom = new JPanel(); - Border border = (Border) DefaultLookup.get(optionPane, this, "OptionPane.buttonAreaBorder"); + Border border = (Border) UIManager.get("OptionPane.buttonAreaBorder"); bottom.setName("OptionPane.buttonArea"); if (border != null) { bottom.setBorder(border); } bottom.setLayout(new DarkButtonAreaLayout( - DefaultLookup.getBoolean(optionPane, this, "OptionPane.sameSizeButtons", false), - DefaultLookup.getInt(optionPane, this, "OptionPane.buttonPadding", 6), - DefaultLookup.getInt(optionPane, this, "OptionPane.buttonOrientation", SwingConstants.CENTER), - DefaultLookup.getBoolean(optionPane, this, "OptionPane.isYesLast", false))); + UIManager.getBoolean("OptionPane.sameSizeButtons"), + UIManager.getInt("OptionPane.buttonPadding"), + UIManager.getInt("OptionPane.buttonOrientation"), + UIManager.getBoolean("OptionPane.isYesLast"))); addButtonComponents(bottom, getButtons(), getInitialValueIndex()); return bottom; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java index ca8843eb3..e1e697cb4 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java @@ -683,12 +683,7 @@ protected void layoutTabComponents() { // center component int x = outerX + (outerWidth - width) / 2; int y = outerY + (outerHeight - height) / 2; - - int tabPlacement = tabPane.getTabPlacement(); - boolean isSeleceted = i == tabPane.getSelectedIndex(); - - c.setBounds(x + getTabLabelShiftX(tabPlacement, i, isSeleceted), - y + getTabLabelShiftY(tabPlacement, i, isSeleceted), width, height); + c.setBounds(x, y, width, height); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java index 4c81c9aac..4bacc93bd 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java @@ -39,9 +39,7 @@ import javax.swing.plaf.basic.BasicHTML; import javax.swing.text.View; -import sun.swing.DefaultLookup; import com.github.weisj.darklaf.ui.UIAction; - import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.LazyActionMap; import com.github.weisj.darklaf.util.PropertyKey; @@ -659,7 +657,7 @@ protected View getTextViewForTab(final int tabIndex) { protected int getTabLabelShiftX(final int tabPlacement, final int tabIndex, final boolean isSelected) { Rectangle tabRect = rects[tabIndex]; String propKey = (isSelected ? "selectedLabelShift" : "labelShift"); - int nudge = DefaultLookup.getInt(tabPane, this, "TabbedPane." + propKey, 1); + int nudge = UIManager.getInt("TabbedPane." + propKey); switch (tabPlacement) { case LEFT: @@ -683,8 +681,8 @@ protected int getTabLabelShiftX(final int tabPlacement, final int tabIndex, fina */ protected int getTabLabelShiftY(final int tabPlacement, final int tabIndex, final boolean isSelected) { Rectangle tabRect = rects[tabIndex]; - int nudge = (isSelected ? DefaultLookup.getInt(tabPane, this, "TabbedPane.selectedLabelShift", -1) - : DefaultLookup.getInt(tabPane, this, "TabbedPane.labelShift", 1)); + int nudge = (isSelected ? UIManager.getInt("TabbedPane.selectedLabelShift") + : UIManager.getInt("TabbedPane.labelShift")); switch (tabPlacement) { case BOTTOM: @@ -857,9 +855,9 @@ protected MouseListener createMouseListener() { */ InputMap getInputMap(final int condition) { if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) { - return (InputMap) DefaultLookup.get(tabPane, this, "TabbedPane.ancestorInputMap"); + return (InputMap) UIManager.get("TabbedPane.ancestorInputMap", tabPane.getLocale()); } else if (condition == JComponent.WHEN_FOCUSED) { - return (InputMap) DefaultLookup.get(tabPane, this, "TabbedPane.focusInputMap"); + return (InputMap) UIManager.get("TabbedPane.focusInputMap", tabPane.getLocale()); } return null; } @@ -1509,7 +1507,7 @@ protected Insets getContentBorderInsets(final int tabPlacement) { */ protected void navigateSelectedTab(final int direction) { int tabPlacement = tabPane.getTabPlacement(); - int current = DefaultLookup.getBoolean(tabPane, this, "TabbedPane.selectionFollowsFocus", true) + int current = !Boolean.FALSE.equals(UIManager.get("TabbedPane.selectionFollowsFocus")) ? tabPane.getSelectedIndex() : getFocusIndex(); int tabCount = tabPane.getTabCount(); @@ -1682,7 +1680,7 @@ protected void selectAdjacentRunTab(final int tabPlacement, final int tabIndex, * @param index the index */ protected void navigateTo(final int index) { - if (DefaultLookup.getBoolean(tabPane, this, "TabbedPane.selectionFollowsFocus", true)) { + if (!Boolean.FALSE.equals(UIManager.get("TabbedPane.selectionFollowsFocus"))) { tabPane.setSelectedIndex(index); } else { // Just move focus (not selection) diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java index 4115227bc..ab808c949 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java @@ -37,8 +37,6 @@ import javax.swing.table.TableCellEditor; import javax.swing.table.TableColumn; -import sun.swing.DefaultLookup; - import com.github.weisj.darklaf.ui.DragRecognitionSupport; import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.PropertyUtil; @@ -179,11 +177,11 @@ protected MouseInputListener createMouseInputListener() { */ InputMap getInputMap(final int condition) { if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) { - InputMap keyMap = (InputMap) DefaultLookup.get(table, this, "Table.ancestorInputMap"); + InputMap keyMap = (InputMap) UIManager.get("Table.ancestorInputMap", table.getLocale()); InputMap rtlKeyMap; if (table.getComponentOrientation().isLeftToRight() || ((rtlKeyMap = - (InputMap) DefaultLookup.get(table, this, "Table.ancestorInputMap.RightToLeft")) == null)) { + (InputMap) UIManager.get("Table.ancestorInputMap.RightToLeft", table.getLocale())) == null)) { return keyMap; } else { rtlKeyMap.setParent(keyMap);