Java中的MDI应用程序

时间:2015-06-12 03:03:13

标签: java swing mdi jinternalframe jdesktoppane

我正在使用netbeans在java中创建一个MDI应用程序。 问题是我有两个按钮:添加员工和搜索员工。当我单击添加员工时,添加员工的内部框架在桌面窗格中打开,当我单击搜索员工时,它会落后于较早的框架,并且在我退出第一帧之前不可见。我希望如果桌面窗格不为空,则应在单击另一个按钮时放置早期的内部框架。请帮助我

这是代码:这里JP是桌面窗格的变量名。

private void BAddEmpActionPerformed(java.awt.event.ActionEvent evt) {
        o=new EntryEmp();
        JP.add(o);
        o.setVisible(true);  
    }                                       

    private void BSearchEmpActionPerformed(java.awt.event.ActionEvent evt) {
        Employee_search ob1=new Employee_search();
        JP.add(ob1);
        ob1.setVisible(true);        
    }                                

2 个答案:

答案 0 :(得分:0)

我认为您应该能够将第一个窗格的可见性设置为false:

private void BSearchEmpActionPerformed(java.awt.event.ActionEvent evt) {
    Employee_search ob1=new Employee_search();
    JP.add(ob1);
    ob1.setVisible(true);
    if (o != null && o.getVisible == true){
        o.setVisible(false);
        //and possibly kill it:
        o = null;
    }

答案 1 :(得分:0)

在您添加了新的JInternalFrame并将其设为可见的JInternalFrame#toFront

相关问题