VasilM

AWTHomework2b

Apr 10th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. package awtHomework2b;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4.  
  5. class GraphicsPanel extends Panel {
  6.     public void paint( Graphics g ) {
  7.         g.setColor( Color.blue );
  8.         g.fillRect( 10, 10, 300, 300);
  9.         g.setColor( getBackground());
  10.         g.fillRoundRect(25, 25, 270, 270, 20, 20);
  11.         g.setColor( Color.red );
  12.         g.fillRect( 40, 40, 120, 120 );
  13.         g.setColor( Color.blue );
  14.         g.fillOval( 40, 40, 240, 240 );
  15.         g.setColor( getBackground());
  16.         g.fillArc( 40, 40, 240, 240, 90, 90);
  17.     }
  18. }
  19.  
  20. public class AWTHomework2b extends Frame {
  21.    
  22.     public AWTHomework2b() {
  23.         GraphicsPanel gp = new GraphicsPanel();
  24.         this.setTitle("GraphicsDemo");
  25.         this.setSize(340,360);
  26.         this.add( gp );
  27.         this.setVisible(true);
  28.         this.addWindowListener( new WindowClosing());
  29.     }
  30.        
  31.     public static void main(String[] args) {
  32.         new AWTHomework2b();
  33.     }  
  34.    
  35.     class WindowClosing extends WindowAdapter {
  36.         public void windowClosing( WindowEvent e) {
  37.             System.exit(0);
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment