2012-01-20 57 views
0

internalFrameIconified僅在internalFrameDeiconified後才起作用嗎?
當我iconfy它diplayes最小化..它是一個Java錯誤?
我們可以在最小化之前調用最大化方法嗎?最大化內部幀

// add the intrenal window frame event.. 
     InternalFrameListener internalFrameListener = new InternalFrameListener() { 
     InternalFrameEvent e; 
     public void internalFrameOpened(InternalFrameEvent e) { 
      System.out.println("Opened"); 
     } 

     public void internalFrameClosing(InternalFrameEvent e) { 
     } 

     public void internalFrameClosed(InternalFrameEvent e) { 
      System.out.println("Closed"); 
     } 

     public void internalFrameIconified(InternalFrameEvent e) { 
      System.out.print("Maximised"); 
     } 

     public void internalFrameDeiconified(InternalFrameEvent e) { 
     System.out.print("Minimised"); 
     } 

     public void internalFrameActivated(InternalFrameEvent e) { 
     System.out.println("Activated"); 
     } 

     public void internalFrameDeactivated(InternalFrameEvent e) { 
     System.out.println("DeActivated"); 
     } 
    }; 
    interFrame.addInternalFrameListener(internalFrameListener); 

回答

1

您只需從正確的方法打印錯誤的消息。

public void internalFrameIconified(InternalFrameEvent e) { 
     System.out.print("Maximised"); // Should be "Iconified" 
    } 

    public void internalFrameDeiconified(InternalFrameEvent e) { 
     System.out.print("Minimised"); // Should be "Deiconified" 
    } 

    //... 

等等...

我的意思是,在打印的文本不對應於什麼與內部框架發生。
當內部框架是取消圖標InternalFrameListener打印的相應方法「Mininmised」,因爲你讓他來打印錯誤信息。
InternalFrameListener的其他方法相同。
這就是爲什麼你不明白到底發生了什麼。

這裏是InternalFrameListener與正確打印出正確的代碼:

InternalFrameListener internalFrameListener = new InternalFrameListener() { 

    public void internalFrameOpened(InternalFrameEvent e) { 
     System.out.print("Opened"); 
    } 

    public void internalFrameClosing(InternalFrameEvent e) { 
     System.out.print("Closing"); 
    } 

    public void internalFrameClosed(InternalFrameEvent e) { 
     System.out.print("Closed"); 
    } 

    public void internalFrameIconified(InternalFrameEvent e) { 
     System.out.print("Iconified"); 
    } 

    public void internalFrameDeiconified(InternalFrameEvent e) { 
     System.out.print("Deiconified"); 
    } 

    public void internalFrameActivated(InternalFrameEvent e) { 
     System.out.print("Activated"); 
    } 

    public void internalFrameDeactivated(InternalFrameEvent e) { 
     System.out.print("Deactivated"); 
    } 
}; 
interFrame.addInternalFrameListener(internalFrameListener); 
+0

@ MockerTim我很抱歉,我是一個新手,以java..Can請你解釋一下? – xyz

+0

@ Mocker蒂姆謝謝......現在我明白了.. – xyz