首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何处理JInternalFrame关闭JDesktopPane的问题?

如何处理JInternalFrame关闭JDesktopPane的问题?
EN

Stack Overflow用户
提问于 2013-11-20 06:19:46
回答 3查看 2.5K关注 0票数 3

我有一个JFrame(HMSDoctor),因为我使用JDesktopPane调用一个JInternalFrame(CurrentOPD)

代码语言:javascript
复制
//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(跟随)。

我怎么能这样做?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2013-11-22 17:28:07

是的,首先您必须在main frame中使用frame,当JInternalFrame(CurrentOPD)关闭时,您可以调用JInternalFrame(Follow)

票数 1
EN

Stack Overflow用户

发布于 2013-11-20 06:21:34

请参阅关于如何编写内部帧侦听器的Swing教程中的部分。我想您会想要侦听“关闭”事件,然后再做一些额外的处理。

票数 5
EN

Stack Overflow用户

发布于 2013-11-20 06:34:29

代码语言:javascript
复制
 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);
            ...
        }
    } 
    ...
}
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20088836

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档