2013-12-18 110 views
-1

嗨,我想重新調整圖像圖標,我試圖使用getScaled方法,但它不工作,我附加了下面的代碼副本。Java,GridBagLayout

public Example(){ 
     JLabel l = new JLabel(new ImageIcon(getClass().getResource("gui/CheckLib.png"))); 
     Image resize = l.getScaled(200, 180, 18); 
     l.setIcon(new ImageIcon(resize)); 

     setLayout(new GridBagLayout()); 
     GridBagConstraints c = new GridBagConstraints(); 
     c.anchor = GridBagConstraints.SOUTHEAST; 
     c.weightx = 1; 
     c.fill = GridBagConstraints.HORIZONTAL; 
     add(l); 
+0

你是什麼意思,它不工作? – hichris123

回答

1

您可以試試Darryl的Stretch Icon。它會根據圖標可用的空間調整圖像大小。