2010-11-27 57 views
0

的大小,所以這裏的代碼:設置我希望能夠調整JFrame中,當我點擊一個按鈕,一個JFrame

public void mouseClicked(MouseEvent arg0) { 
     try { 

      JPanel source = (JPanel)arg0.getSource(); 
      JPanel parent = (JPanel)source.getParent().getParent().getParent().getParent(); 
      parent.getParent().setSize(new Dimension(1400,800)); 
         ((JLayeredPane) parent.getParent()).revalidate(); 
} 

,但上面的代碼不會調整我的JFrame,這是爲什麼?

回答

1

試試這個:

SwingUtilities.windowForComponent(source); // where source is your button 
window.setSize(new Dimension(1400,800)); 
+0

什麼是窗口? – aherlambang 2010-11-27 23:22:16

相關問題