I am a beginner, I am in my first java course so please take it easy on me. But I have written this code drawing 15 lines. I am stuck on how to make another loop to start the lines again in each corner.
Here is my code thus far, and the result I am looking for. If anyone can help me or write show me the extra input needed to reach this picture please let me know.
import java.awt.Graphics;
import javax.swing.JPanel;
import javax.swing.JFrame;
public class DrawOneSetOfLines extends JPanel
{
public static void main(String args[])
{
DrawOneSetOfLines panel = new DrawOneSetOfLines();
JFrame application = new JFrame();
application.setDefaultCloseOperation(JFrame.EXIT_O N_CLOSE);
application.add(panel);
application.setSize(250, 250);
application.setVisible(true);
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
int linesToDraw = 15;
int width = getWidth();
int height = getHeight();
int number, y, x, dy, dx;
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 );
}
}
}