2
我遇到的问题是我想填充一个椭圆形,但我使用浮点数作为我的'x'和'y'值。以下是我有:如何在Java中重写fillOval函数?
@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
?
什么是'g'?看起来你想重写“别人的”代码? – John3136
这是在一个重载的paintComponent(图形克)功能... –
你可以只投你的浮标整数? 'g.fillOval((int)(coord.x),(int)(coord.y)...' – John3136