0

I googled this problem a lot but can't find any answers. I have legacy system with three JFrame objects. They were created in one chain: first JFrame is parent for second one, second is parent for third.

The problem is after I close third window, the first window receive focus and the second one is going behind the first. And its wrong. I expect that after closing third JFrame focus will go to the second window. What could be the problem and how to fix this wrong behaviour?

Code looks something like this:

Frame first = new JFrame(null, "first");
JDialog second = new JDialog(first, "second"); 
JFrame third = new JFrame(second, "third");

third.addWindowListener(new WindowAdapter() {
  // request focus in second window when focus lost in third
});
yu.pitomets
  • 1,660
  • 2
  • 17
  • 44

1 Answers1

-1

Using several JFrame objects in one application is a bad practice. See the following answer, that could help to change your implementation. https://stackoverflow.com/a/9554657/2239537

Community
  • 1
  • 1
Alex Kartishev
  • 1,836
  • 3
  • 18
  • 25