【问题标题】:For a method like fillOval what does 'x' and 'y' denote ? What coordinates are they?对于像 fillOval 这样的方法,'x' 和 'y' 表示什么?它们是什么坐标?
【发布时间】:2025-12-23 16:50:16
【问题描述】:

对于Graphics 类的方法:fillOvalxy 表示什么?文档说:

x - the x coordinate of the upper left corner of the oval to be filled.
y - the y coordinate of the upper left corner of the oval to be filled.

我不明白这一点。什么意思?

【问题讨论】:

    标签: java swing graphics


    【解决方案1】:

    在一张纸上,画一个矩形。然后在矩形内画一个椭圆,尽可能填满矩形(椭圆应该接触矩形的所有 4 个边一次)。

    正方形的左上角是(x,y)

    【讨论】:

    • 在这个picture中,所有9个按钮都已绘制,同时保留x,y as (0,0)。这是什么意思?
    • @saplingPro 也许在画圆圈之间有一个transformation?如果它们真的在相同的坐标上绘制,那么看起来只会是一个圆圈。
    • 也许画圆圈之间有一个转换..我不明白这个
    • @saplingPro 我添加了一个链接。如果对如何在“相同坐标”(即(0,0))处绘制所有按钮仍有疑问,请在主要问题中添加一个显示呈现它的代码的链接并添加这个(子)问题也是主要问题 - 我怀疑正在应用转换。
    • 我告诉你,我先用IDE来放置按钮,然后这些按钮的形状被更改为JButton b = new RoundButton()。圆形按钮类包含制作按钮的所有代码。这就是你所说的转换吗?
    【解决方案2】:
    x - the x coordinate of the upper left corner of the oval to be filled.
    y - the y coordinate of the upper left corner of the oval to be filled.
    

    看图:

    【讨论】:

      最近更新 更多