2013-12-18 65 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。它会根据图标可用的空间调整图像大小。