Java矩形问题
我创建了矩形并插入了X、Y、width和height等值。当我调用fillRect或drawRect时,它表示方法fillRect不适用于参数(double、double、double、double) 当我使用整数变量而不是数字时也会发生这种情况。有什么建议吗?谢谢。和Java矩形问题,java,user-interface,awt,draw,java-2d,Java,User Interface,Awt,Draw,Java 2d,我创建了矩形并插入了X、Y、width和height等值。当我调用fillRect或drawRect时,它表示方法fillRect不适用于参数(double、double、double、double) 当我使用整数变量而不是数字时也会发生这种情况。有什么建议吗?谢谢。和drawRect方法采用int参数,而不是double。您有两个选择: 如果使用的是Graphics2D,请使用而不是fillRect 将参数强制转换为int g.fillRect((int) rectangle.getX(),(
drawRect
方法采用int
参数,而不是double
。您有两个选择:
Graphics2D
,请使用而不是fillRect
int
g.fillRect((int) rectangle.getX(),(int) rectangle.getY(),
(int) rectangle.getWidth(),(int) rectangle.getHeight());
drawRect
方法采用int
参数,而不是double
。您有两个选择:
Graphics2D
,请使用而不是fillRect
int
g.fillRect((int) rectangle.getX(),(int) rectangle.getY(),
(int) rectangle.getWidth(),(int) rectangle.getHeight());