【发布时间】:2019-09-04 03:31:54
【问题描述】:
我正在JFrame (854 x 480) 中创建游戏。我想在屏幕的右上角画一个Rectangle。像这样:
int x, y;
Rectangle rect;
public Foo() {
x = 0;
y = 0;
rect = new Rectangle(x, y, 63, 27);
}
....
public void draw(Graphics g) {
g.drawRect(rect.x, rect.y, rect.width, rect.height);
}
但是当我这样做时,框会从屏幕上拉出(x 坐标是正确的,但 y 坐标太高了:
当我将 y 坐标更改为 27(矩形的高度)时,它会向下移动到我想要的位置:
知道为什么会这样吗?或者如何解决?
【问题讨论】:
标签: java jframe drawrectangle