-1

I have a JFrame that contains dynamic content and

my_frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

The frame is show only when the user press a JButton and my_frame class contains only a constructor (for fist time invocation) and a refresh method for refreshing its content. Now i would that when the JFrame become visibile again, my_frame intercept the event and call automatically the refresh method. How can i do it?

4

1 回答 1

3

现在我希望当 JFrame 再次变得可见时,my_frame 拦截事件并自动调用刷新方法。我该怎么做?

  • 好概念,重用一个的好主意Top-Level Container

  • 我建议使用JDialog(parent)而不是JFrame

  • 你可以调用my_frame.setVisible(true),假设它my_frame被声明并初始化为变量

  • 或者Window[] wins = Window.getWindows();返回数组Top-Level Container,在这个数组里面循环你可以测试 if (wins[i] instanceof JFrame) {,然后调用wins[i].setVisible(true);

于 2013-08-06T09:37:01.683 回答