I am creating a Transliterating tool in Java. It's almost complete. Here is the screenshot.
I am using JWindow
for dropdown, which must be focusable for some reason.
As, user can write in one input only at one time. I've created this window
static, so all Text components use the same instance instead of creating new one.
Problem occurs, when I work in more than one window. It works fine unless both window are showing on screen. But when owner window of this dropdown window is closed, dropdown window is not focusable anymore.
As Javadoc of JWindow(Window owner)
constructor says:
Creates a window with the specified owner window. This window will not be focusable unless its owner is showing on the screen. If owner is null, the shared owner will be used and this window will not be focusable.
So, how can I create a static, focusable window, that is shared by all components in different windows.
Don't use a JWindow.
Instead you can use a non decorated JDialog. Then you won't have the focus problem.
Edit:
You can prevent the dialog from initially getting focus when you make it visible by using code like:
dialog.setWindowFocusableState(false);
dialog.setVisible(true);
dialog.setWindowFocusableState(true);