I’m working in Java to create an internal tool. The two consists of two JPanels which are anticipated to run on two separate screens. I want to be able to click a JButton which is part of JFrame A which will send a keyboard action to JFrame B.
Unfortunately I can’t seem to do this because JFrame B doesn’t have the focus and I can’t use any of the request Focus methods because JFrame B is not a child of the Focus Window (JFrame A is).
So how can I either give JFrame B focus despite it not being a child of the Focus Window or send Keyboard Events to JFrame B that it will respond to without having focus?
is so hard to manage Focus between two JFrames, better would be create only one JFrame and other Top-level Containers would be JDialogs, create one/two JDialog(s) and reuse that by removing all JComponents
basicaly it would be :
but between two JFrames is things little bit complicated, just basic and uncompleted example (based on code from old.good.sun.forums.com)
EDIT: for How to adds Focus to the
JDialogis there excelent Woodoo by camickr Dialog Focus but AncestorListener isn’t my cup of Java and too much abstract for me