好像没有dispose,只是把子窗口remove了,是的吗?如果我要在做菜单项(JMenuItem)的侦听的时候,需要判断好几种情况,如何写代码呢?伪代码如下:if(myJInternalFrame!=null){
myJInternalFrame.movetoFront();
}elseif(myJInternalFrame==null){
parentPane.add(new MyJInternalFrame());
}
可是如果点击了子窗口的右上角的关闭按钮,这个myJInternalFrame并不是null的如何实现上面的代码啊?

解决方案 »

  1.   

    下面这个是关闭时候执行的代码。
    默认关闭模式:HIDE_ON_CLOSE    public void doDefaultCloseAction() {
            fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSING);
            switch(defaultCloseOperation) {
              case DO_NOTHING_ON_CLOSE:
        break;
              case HIDE_ON_CLOSE:
                setVisible(false);
        if (isSelected())
                    try {
                        setSelected(false);
                    } catch (PropertyVetoException pve) {}
          
        /* should this activate the next frame? that's really
           desktopmanager's policy... */
                break;
              case DISPOSE_ON_CLOSE:
                  try {
    fireVetoableChange(IS_CLOSED_PROPERTY, Boolean.FALSE,
       Boolean.TRUE);
    isClosed = true;
    firePropertyChange(IS_CLOSED_PROPERTY, Boolean.FALSE,
       Boolean.TRUE);
    dispose();
          } catch (PropertyVetoException pve) {}
                  break;
              default: 
                  break;
            }
        }