Java
Home

O Objeto Paint

 

/*
* Main.java
*
* Created on 12 de Fevereiro de 2007, 19:15
*/

package objeto_paint;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

/**
*
* @author adrw
*/

public class Main extends JFrame {

   /** Creates a new instance of Main */
   public Main()
   {
      super( "Usando Cores");

      setSize( 400, 130 );
      setVisible( true );
   }


   public void paint( Graphics g )
   {
      super.paint( g );

      g.setColor( new Color(255, 0, 0 ) );
      g.fillRect( 25, 25, 100, 20 );
      g.drawString( "Color: " + g.getColor(), 130, 40 );

      g.setColor( Color.blue );
      g.fillRect( 25, 50, 100, 20 );
      g.drawString( "Color: " + g.getColor(), 130, 65 );

      g.setColor( new Color(0.0f, 1.0f, 0.0f ) );
      g.fillRect( 25, 75, 100, 20 );
      g.drawString( "Color: " + g.getColor(), 130, 90 );

   }

   /**
   * @param args the command line arguments
   */

   public static void main(String[] args)
   {
      Main app = new Main();

      app.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

   }

}