Results 1 to 2 of 2

Thread: Graphics? [resolved]

Threaded View

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Graphics? [resolved]

    Anybody know how i can do this?
    Im just trying to simply make a
    circle on a canvas. I can get it to work
    as an applet but that's about it.
    Thanks
    Code:
       import javax.swing.*;
       import java.awt.*;
       import java.awt.event.*; 
      
       public class Shape {
         public static void main(String[] args){
           new Circle(); 
        }
    
        Canvas c; 
        JFrame jf;
      }
     
      class Circle extends Shape{
      
       public Circle() {
        c = new Canvas();
        jf = new JFrame("Circle!");
        jf.addWindowListener(new WindowAdapter(){
           public void windowClosing(WindowEvent e){
              System.exit(0);
           }
        });
    
         Dimension size = jf.getSize();
         Insets i = jf.getInsets(); 
         int height = size.height - i.top - i.bottom;
         int width = size.width - i.left - i.right;
    
        c.setSize(height,width);
        jf.getContentPane().add(c);
        jf.setSize(400,300);
        jf.setVisible(true);
      }
     
       public void paint(Graphics g){
        g.setColor(Color.red);
        g.drawOval(50,50,50,50); 
       }
      }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width