// CornerLines.java - a solution to CS 5JA assignment 3, part 2, Winter 2009 // Draws lines fanning from the corners to the middle of the panel. // updated by cmc, 1/24/09 import java.awt.Graphics; import javax.swing.JPanel; public class CornerLines extends JPanel { public void paintComponent( Graphics g ) { super.paintComponent( g ); int increments = 15; int width = getWidth(); int height = getHeight(); int widthStep = width / increments; int heightStep = height / increments; int count = 0; while ( count < increments ) { // lines fanning from the top-left (part 2a of assignment 3) g.drawLine( 0, 0, count * widthStep, height - count * heightStep ); // lines fanning from the bottom-right g.drawLine( width, height, count * widthStep, height - count * heightStep ); // lines fanning from the bottom-left g.drawLine( 0, height, count * widthStep, count * heightStep ); // lines fanning from the top-right g.drawLine( width, 0, count * widthStep, count * heightStep ); count++; } } }