// OvalPanelX2.java // Customized JPanel class import java.awt.*; import javax.swing.*; public class OvalPanelX2 extends JPanel { private int width = 10; private int height = 10; public void paintComponent( Graphics g ) { super.paintComponent( g ); g.fillOval( 10, 10, width, height ); } public void setWidth( int w ) { width = ( w >= 0 ? w : 10 ); // default value is 10 repaint( ); } public void setHeight( int h ) { height = ( h >= 0 ? h : 10 ); // default value is 10 repaint( ); } // following methods are used by layout managers public Dimension getPreferredSize( ) { return new Dimension( 900, 600 ); } public Dimension getMinimumSize( ) { return getPreferredSize( ); } }