好的,所以我在编写这个程序时遇到了问题。我已经完成了第一部分,但我不知道如何完成它。我尝试了不同的解决方案和一切,但我仍然不知道。这是我到目前为止所拥有的。我需要做的是让它从四个角落开始。
public void paintComponent( Graphics g )
{
super.paintComponent( g );
int width = getWidth();
int height = getHeight();
int number, x, y, dx, dy;
x = 0;
y = height;
number = 15;
dx = width / number;
dy = height / number;
for ( int i = 1; i < number; i++ )
{
x += dx;
y -= dy;
g.drawLine( 0, 0, x, y );
}
}