Fixed focus issue that caused new dialogs to sometimes have focus taken

away
This commit is contained in:
dragonmacher 2024-11-15 20:52:34 -05:00
parent c9a51029bb
commit 7712224ff1

View File

@ -1385,6 +1385,7 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
} }
private synchronized ComponentPlaceholder maybeGetPlaceholderToFocus() { private synchronized ComponentPlaceholder maybeGetPlaceholderToFocus() {
if (nextFocusedPlaceholder != null) { if (nextFocusedPlaceholder != null) {
ComponentPlaceholder temp = nextFocusedPlaceholder; ComponentPlaceholder temp = nextFocusedPlaceholder;
setNextFocusPlaceholder(null); setNextFocusPlaceholder(null);
@ -1392,8 +1393,12 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
} }
KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
Component permanentFocusOwner = kfm.getPermanentFocusOwner();
Component focusOwner = kfm.getFocusOwner(); Component focusOwner = kfm.getFocusOwner();
if (focusOwner == null) {
// A null focus owner and a null permanent focus owner imply that Java did not know who
// should get focus. Make sure one of our widgets gets focus.
if (focusOwner == null && permanentFocusOwner == null) {
return findNextFocusedComponent(); return findNextFocusedComponent();
} }
return null; return null;
@ -1463,6 +1468,7 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
} }
private ComponentPlaceholder findNextFocusedComponent() { private ComponentPlaceholder findNextFocusedComponent() {
Iterator<ComponentPlaceholder> iterator = lastFocusedPlaceholders.iterator(); Iterator<ComponentPlaceholder> iterator = lastFocusedPlaceholders.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
ComponentPlaceholder placeholder = iterator.next(); ComponentPlaceholder placeholder = iterator.next();
@ -1471,7 +1477,6 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
} }
iterator.remove(); iterator.remove();
} }
return getActivePlaceholder(defaultProvider); return getActivePlaceholder(defaultProvider);
} }