Domanda

How can I call some method after frame visibility changed to true?

frame.setVisible(true);

My application has 2 frames. if I open second frame main frame hided. After closing second frame main frame is shown. so, I want to reload jlist after main frame shown again

È stato utile?

Soluzione

My suggestion is to change your program design. No user wants to have windows flung at them and swapped. Instead use one main JFrame and swap JPanel views using a CardLayout.

If you must show a child window from a visible parent window, use a JDialog. Note that if you do show a modal JDialog, it is easy to know when the dialog is no longer visible since the parent's code flow resumes from right after where you make the modal dialog visible. For example, please have a look at my code in this answer.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top