首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JDesktopPane和JInternalFrame帮助!

JDesktopPane和JInternalFrame帮助!
EN

Stack Overflow用户
提问于 2011-01-04 12:06:24
回答 1查看 1K关注 0票数 0

大家好,

我有一个关于限制JDesktopPane的重复JInternalFrames的问题。基本上,在JDesktopPane中添加一个实例JInternalFrame是比较全面的。而是限制JDesktopPane上同一实例的重复JInternalFrame,并使该实例成为JDesktopPane的顶层。

我怎么才能实现它呢?我是否要将所有实例存储到一个ArrayList中,并检查它是否是关于execute的实例已经打开?

非常感谢您的回复。

谢谢西里尔·H。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-01-04 23:57:54

代码语言:javascript
复制
/**
 * method to search for active internal frame windows
 * and return true or false depending on the outcome. this method uses internalframe names
 */
public boolean searchIFrame(String search, JInternalFrame frame[])
{
    for(int i = 0; i < frame.length; i++)
        if(frame[i].getTitle().toString().equals(search))
            return true;
        return false;
}

//its implementation in your program. "Information Form" is the internalframe's name
//jdesk is the desktoppane object or instance
boolean srch = searchIFrame("Information Form", jdesk.getAllFrames());
    if(!srch) {        
                VisitationForm at = new VisitationForm();
                at.pack();
                jdesk.add(at);

                try
                {
                    at.setSelected(true);
                    at.setVisible(true);
                    // We're done, so clear the feedback message
                    //bar.setString(" ");
                    //bar.setIndeterminate(false);
                    at.requestFocus();

                }
                catch (PropertyVetoException pve)
                {
                    //bar.setString(" ");
                    //bar.setIndeterminate(false);

                    // Then display the error in a dialog box
                    System.out.println(pve);
                }

            }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4590550

复制
相关文章

相似问题

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