日期:2014-05-20 浏览次数:20702 次
public class Test { public static void main(String[] args) { Toolkit tk = Toolkit.getDefaultToolkit(); Image image1 = tk.getImage("f:/TestDir/test.jpg"); int width1 = image1.getWidth(null); System.out.println(width1); } }
public class Test2 { public static void main(String[] args) { Toolkit tk = Toolkit.getDefaultToolkit(); Image image1 = tk.getImage("f:/TestDir/test.jpg"); Image image2 = new ImageIcon("f:/TestDir/test.jpg").getImage(); int width1 = image1.getWidth(null); System.out.println(width1); int width2 = image2.getWidth(null); System.out.println(width2); } }