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); } }



Reply With Quote
