Java 如何处理来自JDesktopPane的JInternalFrame关闭操作?
我有一个Java 如何处理来自JDesktopPane的JInternalFrame关闭操作?,java,swing,jinternalframe,Java,Swing,Jinternalframe,我有一个JFrame(HMSDoctor),我使用JDesktopPane调用一个JInternalFrame(CurrentOPD) //opening JInternalFrame(CurrentOPD) by using JDesktopPane in JFrame(HMSDoctor). JDesktopPane jdp=new JDesktopPane(); jdp.add(new CurrentOPD); //Above code display proper
JFrame(HMSDoctor)
,我使用JDesktopPane
调用一个JInternalFrame(CurrentOPD)
//opening JInternalFrame(CurrentOPD) by using JDesktopPane in JFrame(HMSDoctor).
JDesktopPane jdp=new JDesktopPane();
jdp.add(new CurrentOPD);
//Above code display proper JInternalFrame.
当我当时关闭JInternalFrame时,我想在JFrame(HMSDoctor)
中执行另一个JInternalFrame(Follow)
我怎样才能做到这一点呢?请参阅上的Swing教程部分。我想您应该先监听“closed”事件,然后再做一些额外的处理。是的,首先您必须在主
帧中添加internalframelistener
,当您的JInternalFrame(CurrentOPD)
关闭时,您可以调用JInternalFrame(Follow)
非常感谢您,先生@DaxeshPrajapati,说真的,你不接受这个答案而接受另一个答案。
public void actionPerformed(ActionEvent e) {
if (SHOW.equals(e.getActionCommand())) {
...
if (listenedToWindow == null) {
listenedToWindow = new JInternalFrame("Event Generator",
true, //resizable
true, //closable
true, //maximizable
true); //iconifiable
//We want to reuse the internal frame, so we need to
//make it hide (instead of being disposed of, which is
//the default) when the user closes it.
listenedToWindow.setDefaultCloseOperation(
WindowConstants.HIDE_ON_CLOSE);
listenedToWindow.addInternalFrameListener(this);
...
}
}
...
}