// DrawPanel.java: Fig 4.19 from Deitel & Deitel, Java: How to Program
// Draws two crossing lines on a panel
//
// Modified for CSC 121 - Spring 2005 
// Berry College - Nadeem Abdul Hamid

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 of panel
        int height = getHeight(); // total height of panel

        // draw a line from the upper-left to the lower-right
        g.drawLine( 0, 0, width, height );

        // draw a line from the lower-left to the upper-right
        g.drawLine( 0, height, width, 0 );

    } // end method paintComponent

} // end class DrawPanel


