// DrawJPanel2Tester.java
// Applet tests the JPanel used as a dedicated drawing area
// APPLET CODE="DrawJPanel2Tester" HEIGHT=500 WIDTH=700
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class DrawJPanel2Tester extends JApplet implements ActionListener {
	private Container c;
	private DrawJPanel2 pD;
	private JPanel pGUI;
	private JLabel wLabel, hLabel;
	private JTextField wField, hField;
	private int wid, hgt;

	public void init( ) {
		c = getContentPane( );
		pD = new DrawJPanel2( );

		pGUI = new JPanel( );
		pGUI.setLayout( new GridLayout( 1, 6, 10, 10 ) );
		wLabel = new JLabel( "Enter the width:" );
		wField = new JTextField( "50", 10 );
		wField.addActionListener( this );
					
		hLabel = new JLabel( "Enter the height:" );
		hField = new JTextField( "50", 10 );
		hField.addActionListener( this );

		// add GUI components to pGUI panel
		pGUI.add( wLabel );
		pGUI.add( wField );
		pGUI.add( hLabel );
		pGUI.add( hField );

		// add the panels to the container c		
		c.add( pGUI, BorderLayout.NORTH );
		c.add( pD, BorderLayout.CENTER );

		wid = Integer.parseInt( wField.getText( ) );
		hgt = Integer.parseInt( hField.getText( ) );
		pD.drawingStuff( wid, hgt );
	}

	public void actionPerformed( ActionEvent e ) {
		wid = Integer.parseInt( wField.getText( ) );
		hgt = Integer.parseInt( hField.getText( ) );
		pD.drawingStuff( wid, hgt );
	}
}