It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center
                            
                        
                    
                
                                7年前关闭。
            
                    
我遇到的问题是我想填充一个椭圆形,但是我将浮点数用作我的“ x”和“ y”值。这是我所拥有的:

@Override
public void paintComponent(Graphics g)
{
.
.
.
for(Coordinates cord : tempVertices)
{
    g.fillOval(cord.x,cord.y,DIAMETER,DIAMETER);
}
// DIAMETER = 10

// Coordinate Class is just a variable with an 'x' and 'y' value stored in floats
// Floats range from 0 to 1, so type casting won't work...

// tempVertices is just an ArrayList with Coordinates values


我正在使用NetBeans IDE 7.2,但我不知道如何覆盖fillOval方法,并且不能使用来自import org.newdawn.slick.*;的导入(它无法识别)。是否有更好的Graphics选项或更简单的方法来实现此简单的fillOval

最佳答案

您可能正在寻找fill()Graphics2D方法,该方法接受任何Shape

g.fill(new Ellipse2D.Float(cord.x, cord.y, DIAMETER, DIAMETER));


您还将要探索任何受支持的java.awt.RenderingHints

07-24 13:09