//code Draw panel
import java.awt.Graphics;
import javax.swing.JPanel;
public class DrawPanel extends JPanel
{
// draws an X from the corners of the panel
public void paintComponent( Graphics g )
{
// call paintComponent to ensure the panel displays correctly
super.paintComponent( g );
int width = getWidth(); // total width
int height = getHeight(); // total height
int i = 0, j = 0, k = 0;
for ( i = 1; i <= 15 ; i++)
{
g.drawLine( 0, 0, j, height - k);
j += width / 15;
k += height / 15;
}
j = 0;
k = 0;
for ( i = 1; i <= 15 ; i++)
{
g.drawLine( 0, height, j, k);
j += width / 15;
k += height /15;
}
j = 0;
k = 0;
for ( i = 1; i <= 15 ; i++)
{
g.drawLine( width, 0, width - j, height - k);
j += width / 15;
k += height / 15;
}
j = 0;
k = 0;
for ( i = 1; i <= 15 ; i++)
{
g.drawLine( width, height, width - j, k);
j += width / 15;
k += height / 15;
}
} // end method paintComponent
} // end class DrawPanel