コンポーネントの親要素を閉じることは可能ですか..おそらくJPanelからJFrame
/ですか?JInternalFrame
はいの場合、どのようにそれを行うことができますか?
1152 次
2 に答える
4
これはあなたを助けます:
SwingUtilities.windowForComponent(panel).dispose();
また
SwingUtilities.windowForComponent(panel).setVisible(false);
于 2013-01-24T18:06:55.423 に答える
2
この回答の修正版
public class CustomPanel extends JPanel {
private JFrame parent; //Need to pass this reference somehow, constructor or otherwise
public void closeJFrame() {
WindowEvent winEvent = new WindowEvent(parent, WindowEvent.WINDOW_CLOSING);
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(winEvent );
}
}
于 2013-01-24T18:08:41.370 に答える