From ce4693fddf60a1bb15e219dbe7d439dc11f0b30c Mon Sep 17 00:00:00 2001 From: weisj Date: Fri, 11 Sep 2020 18:11:26 +0200 Subject: [PATCH] Replace usage of #requestFocus with #requestFocusInWindow --- .../com/github/weisj/darklaf/components/DefaultButton.java | 2 +- .../github/weisj/darklaf/components/tabframe/JTabFrame.java | 2 +- .../github/weisj/darklaf/components/tabframe/PanelPopup.java | 2 +- .../java/com/github/weisj/darklaf/settings/ThemeSettings.java | 2 +- .../weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java | 2 +- .../weisj/darklaf/ui/combobox/DarkComboBoxListener.java | 2 +- .../weisj/darklaf/ui/filechooser/DarkFileChooserUIBridge.java | 2 +- .../com/github/weisj/darklaf/ui/filechooser/DarkFilePane.java | 4 ++-- .../github/weisj/darklaf/ui/spinner/DarkSpinnerListener.java | 2 +- .../weisj/darklaf/ui/tabbedpane/DarkScrollableTabSupport.java | 2 +- .../weisj/darklaf/ui/tabbedpane/DarkTabbedPaneHandler.java | 2 +- .../weisj/darklaf/ui/tabbedpane/DarkTabbedPaneLayout.java | 2 +- .../darklaf/ui/tabbedpane/DarkTabbedPaneScrollLayout.java | 2 +- .../weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java | 4 ++-- .../github/weisj/darklaf/ui/tabbedpane/TabbedPaneHandler.java | 2 +- .../github/weisj/darklaf/ui/tabbedpane/TabbedPaneLayout.java | 2 +- .../github/weisj/darklaf/ui/tabbedpane/TabbedPaneUtil.java | 2 +- .../weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java | 2 +- .../weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java | 2 +- .../com/github/weisj/darklaf/ui/tabframe/DarkTabFrameUI.java | 2 +- .../main/java/com/github/weisj/darklaf/ui/text/DarkCaret.java | 2 +- 21 files changed, 23 insertions(+), 23 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/components/DefaultButton.java b/core/src/main/java/com/github/weisj/darklaf/components/DefaultButton.java index c62d00e0..ca638bc1 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/DefaultButton.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/DefaultButton.java @@ -43,7 +43,7 @@ public class DefaultButton extends JButton { @Override public void addNotify() { super.addNotify(); - if (requestFocusOnDisplay) requestFocus(); + if (requestFocusOnDisplay) requestFocusInWindow(); SwingUtilities.getRootPane(this).setDefaultButton(this); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java index 7a581dac..75906a7d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java @@ -556,7 +556,7 @@ public class JTabFrame extends JComponent { setPopupVisibility(compAtIndex, enabled); if (enabled) { getPopupComponentAt(a).doLayout(); - getPopupComponentAt(a).requestFocus(); + getPopupComponentAt(a).requestFocusInWindow(); } firePropertyChange(TabFramePopup.KEY_VISIBLE_TAB, new TabFramePosition(a, oldIndex), new TabFramePosition(a, index)); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/PanelPopup.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/PanelPopup.java index 398ed047..885c5e38 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/PanelPopup.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/PanelPopup.java @@ -193,7 +193,7 @@ public class PanelPopup extends JPanel implements TabFramePopup { parent.openTab(getAlignment(), getIndex()); open = true; firePropertyChange(KEY_OPEN, oldOpen, true); - requestFocus(); + requestFocusInWindow(); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java b/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java index b3c20f07..f88b7743 100644 --- a/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java +++ b/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java @@ -130,7 +130,7 @@ public class ThemeSettings implements ThemePreferenceListener { throw new IllegalStateException("Can't show dialog while settings panel is used elsewhere"); } if (dialog != null && dialog.isVisible()) { - dialog.requestFocus(); + dialog.requestFocusInWindow(); return; } refresh(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java index 9cca95f0..7556ecc6 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java @@ -106,7 +106,7 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements textHex.addAncestorListener(new AncestorAdapter() { @Override public void ancestorAdded(final AncestorEvent event) { - textHex.requestFocus(); + textHex.requestFocusInWindow(); textHex.removeAncestorListener(this); } }); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxListener.java index a676eccd..b491779f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxListener.java @@ -43,7 +43,7 @@ public class DarkComboBoxListener extends MouseAdapter implements PropertyChange @Override public void mousePressed(final MouseEvent e) { - comboBox.getEditor().getEditorComponent().requestFocus(); + comboBox.getEditor().getEditorComponent().requestFocusInWindow(); } @Override diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUIBridge.java index 6a185a37..fb55aeb3 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUIBridge.java @@ -264,7 +264,7 @@ public abstract class DarkFileChooserUIBridge extends BasicFileChooserUI { if (e.getOldValue() == null && e.getNewValue() != null) { // Ancestor was added, set initial focus fileNameTextField.selectAll(); - fileNameTextField.requestFocus(); + fileNameTextField.requestFocusInWindow(); } break; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePane.java b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePane.java index c5fc1a91..24ea6003 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePane.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePane.java @@ -317,7 +317,7 @@ public class DarkFilePane extends DarkFilePaneUIBridge { editCell.setBounds(r.x, r.y, r.width - editX - gap, r.height); } list.putClientProperty("JList.isEditing", true); - editCell.requestFocus(); + editCell.requestFocusInWindow(); editCell.selectAll(); break; @@ -511,7 +511,7 @@ public class DarkFilePane extends DarkFilePaneUIBridge { @Override public void ancestorAdded(final AncestorEvent event) { SwingUtilities.invokeLater(() -> { - editorComponent.requestFocus(); + editorComponent.requestFocusInWindow(); ((JTextComponent) editorComponent).selectAll(); }); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerListener.java index fd621c8b..8a46f3cf 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerListener.java @@ -50,7 +50,7 @@ public class DarkSpinnerListener extends MouseAdapter implements PropertyChangeL @Override public void mousePressed(final MouseEvent e) { super.mousePressed(e); - spinner.getEditor().requestFocus(); + spinner.getEditor().requestFocusInWindow(); } @Override diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabSupport.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabSupport.java index 18c08b46..153635e2 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabSupport.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabSupport.java @@ -235,7 +235,7 @@ public class DarkScrollableTabSupport extends ScrollableTabSupport implements Mo // and invocation of action. ui.tabPane.setSelectedComponent(comp); ui.tabPane.doLayout(); - comp.requestFocus(); + comp.requestFocusInWindow(); } } }); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneHandler.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneHandler.java index 7f0544e6..98518801 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneHandler.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneHandler.java @@ -169,7 +169,7 @@ public class DarkTabbedPaneHandler extends TabbedPaneHandler { @Override public void mousePressed(final MouseEvent e) { super.mousePressed(e); - ui.tabPane.requestFocus(); + ui.tabPane.requestFocusInWindow(); origin = e.getPoint(); pressedIndex = ui.tabForCoordinate(ui.tabPane, e.getX(), e.getY()); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneLayout.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneLayout.java index f551edc3..9d271382 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneLayout.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneLayout.java @@ -193,7 +193,7 @@ public class DarkTabbedPaneLayout extends TabbedPaneLayout { layoutTabComponents(); if (shouldChangeFocus) { if (!ui.requestFocusForVisibleComponent()) { - ui.tabPane.requestFocus(); + ui.tabPane.requestFocusInWindow(); } } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneScrollLayout.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneScrollLayout.java index ae0e55b2..afc7e45c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneScrollLayout.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneScrollLayout.java @@ -213,7 +213,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout { layoutTabComponents(); if (shouldChangeFocus) { if (!ui.requestFocusForVisibleComponent()) { - ui.tabPane.requestFocus(); + ui.tabPane.requestFocusInWindow(); } } } 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 57642cb2..ec3eee7d 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 @@ -2209,7 +2209,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi public void actionPerformed(final ActionEvent e) { String key = getName(); JTabbedPane pane = (JTabbedPane) e.getSource(); - DarkTabbedPaneUIBridge ui = (DarkTabbedPaneUIBridge) DarkUIUtil + DarkTabbedPaneUIBridge ui = DarkUIUtil .getUIOfType(pane.getUI(), DarkTabbedPaneUIBridge.class); @@ -2243,7 +2243,7 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi ui.navigateSelectedTab(SwingConstants.SOUTH); } } else if (Objects.equals(key, REQUEST_FOCUS)) { - pane.requestFocus(); + pane.requestFocusInWindow(); } else if (Objects.equals(key, REQUEST_FOCUS_FOR_VISIBLE)) { ui.requestFocusForVisibleComponent(); } else if (Objects.equals(key, SET_SELECTED)) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneHandler.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneHandler.java index 3448d371..f5c8ad6f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneHandler.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneHandler.java @@ -171,7 +171,7 @@ public class TabbedPaneHandler implements ChangeListener, ContainerListener, Foc } else if (ui.tabPane.isRequestFocusEnabled()) { // Clicking on selected tab, try and give the tabbedpane // focus. Repaint will occur in focusGained. - ui.tabPane.requestFocus(); + ui.tabPane.requestFocusInWindow(); } } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneLayout.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneLayout.java index 44b90370..f81cd202 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneLayout.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneLayout.java @@ -172,7 +172,7 @@ public abstract class TabbedPaneLayout implements LayoutManager { layoutTabComponents(); if (shouldChangeFocus) { if (!ui.requestFocusForVisibleComponent()) { - ui.tabPane.requestFocus(); + ui.tabPane.requestFocusInWindow(); } } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneUtil.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneUtil.java index 5558d98e..8c8e3fe0 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneUtil.java @@ -290,7 +290,7 @@ public class TabbedPaneUtil implements SwingConstants { protected static void selectTab(final JTabbedPane tabbedPane, final int index) { SwingUtilities.invokeLater(() -> { tabbedPane.setSelectedIndex(index); - tabbedPane.requestFocus(); + tabbedPane.requestFocusInWindow(); }); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java index 588d2a72..aac75e9a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java @@ -114,7 +114,7 @@ public class DarkTabFrameTabContainerUI extends DarkPanelUI implements PropertyC } else { Component popup = tabFrame.getPopupComponentAt(a, index); if (!DarkUIUtil.hasFocus(popup)) { - popup.requestFocus(); + popup.requestFocusInWindow(); } else { tabFrame.toggleTab(a, index, false); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java index 70515ada..260defe8 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java @@ -197,7 +197,7 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang } else { Component popup = tabFrame.getPopupComponentAt(a, index); if (!DarkUIUtil.hasFocus(popup)) { - popup.requestFocus(); + popup.requestFocusInWindow(); } else { tabFrame.toggleTab(a, index, false); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameUI.java index 9f8e6e43..0d0796d0 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameUI.java @@ -552,7 +552,7 @@ public class DarkTabFrameUI extends TabFrameUI implements AWTEventListener { MouseEvent e = (MouseEvent) event; Component comp = e.getComponent().getComponentAt(e.getPoint()); if (comp instanceof TabFramePopup || comp instanceof PopupContainer || comp instanceof JTabFrame) { - comp.requestFocus(); + comp.requestFocusInWindow(); } } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkCaret.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkCaret.java index 9f1357ef..9abf4429 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkCaret.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkCaret.java @@ -302,7 +302,7 @@ public class DarkCaret extends DefaultCaret implements UIResource { if (inWindow) { textArea.requestFocusInWindow(); } else { - textArea.requestFocus(); + textArea.requestFocusInWindow(); } } }