Thread: Graphics
View Single Post
  #2 (permalink)  
Old 01-25-2008, 07:24 PM
roots's Avatar
roots roots is offline
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 263
roots is on a distinguished road
This could be one of the way that you define your own JComponent for your graphics object.
Code:
public class SmilePanel extends JComponent { public void paint(Graphics g) { super.paint(g); g.setColor(Color.red); g.drawOval(85, 75, 75, 75); g.setColor(Color.blue); g.drawOval(100, 95, 10, 10); g.drawOval(135, 95, 10, 10); g.drawArc(102, 115, 40, 25, 0, -180); g.drawString("Changing Face", 80, 175); } @Override public Dimension getPreferredSize() { Dimension dimension = new Dimension(200,200); // Change to required size return dimension; } } ... getContentPane().add(new SmilePanel());
__________________
dont worry newbie, we got you covered.
Reply With Quote