- Java code
public DoubleBufferWithBufferedImage() { setSize(300, 300); Dimension d = getSize(); // w = (int)d.getWidth(); // h = (int)d.getHeight(); w = d.width; h = d.height; buffer = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); }
d.width和d.getWidth()什么关系?
------解决方案--------------------
width是Dimension的成员变量,是int类型
getWidth方法,返回值是double类型,估计d.width = (int)d.getWidth();
------解决方案--------------------