import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * Ikkunaluokka.
 */
public class RuudunkokoFrame extends JFrame
{

  /**
   * Konstruktori.
   */
  public RuudunkokoFrame()
  {
    JPanel contentPane = ( JPanel ) getContentPane();
    contentPane.setLayout( new BorderLayout() );
    setDefaultCloseOperation( WindowConstants.DISPOSE_ON_CLOSE );
    setSize( new Dimension( 400, 300 ) );
    setTitle( "Ruudun koon tarkastelu" );
  }

  /**
   * Ikkunan piirtometodi.
   * @param grfx piirtokonteksti
   */
  public void paint( Graphics grfx )
  {
    super.paint( grfx );

    Dimension frameSize = getSize();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

    // asettaa fontin
    Font font = new Font( "SansSerif", Font.BOLD, 13 );
    grfx.setColor( Color.black );
    grfx.setFont( font );

    // pirtää tekstit
    String text1 = screenSize.width + " ruudun leveys";
    String text2 = screenSize.height + " ruudun korkeus";
    String text3 = frameSize.width + " ikkunan leveys";
    String text4 = frameSize.height + " ikkunan korkeus";

    grfx.drawString( text1, 10, frameSize.height / 2 - 20 );
    grfx.drawString( text2, 10, frameSize.height / 2 );
    grfx.drawString( text3, 10, frameSize.height / 2 + 20 );
    grfx.drawString( text4, 10, frameSize.height / 2 + 40 );
  }

}
