这个GIF动画播放速度太快了,快到了正常速度的100倍。有没有解决方法?或者我只需再减缓“正常速度”的速度吗?
public class Test {
private static final String url = "http://i.stack.imgur.com/AnrWw.gif";
private void display() throws MalformedURLException {
JFrame f = new JFrame("Test");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(new JLabel(new ImageIcon(new URL(url))));
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
try {
new Test().display();
} catch (MalformedURLException ex) {
ex.printStackTrace(System.err);
}
}
});
}
}
ImageIcon
使用Toolkit.getDefaultToolkit().getImage(filename)
- MadProgrammersetBounds()
来定位标签(和按钮)。让布局管理器完成它的工作。这样即使将来更改图像,它仍然可以正常工作。 - camickr