Thread: Graphics
View Single Post
  #1 (permalink)  
Old 01-25-2008, 01:16 PM
Joe2003 Joe2003 is offline
Member
 
Join Date: Jan 2008
Posts: 14
Joe2003 is on a distinguished road
Graphics
Hey

Im trying to add some graphics to an JFrame. I have already made a jframe with loads of panels that hold seperate content. Anyway I want to add a picture, eg this smile app I riped off the net :-

Code:
public TestDraw() { setLayout(new FlowLayout()); setTitle("Changing Face"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(250,220); setLocation(300,300); getContentPane().setBackground(Color.yellow); setVisible(true); } 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); }
So the class holding the above functions must extend the JFrame, fair enough, but is it possible to add this kind of content to a JPanel? Main problem I have, is that the area im drawing "things" in is a 660 x 430 space within a rather crowded window, and the size of the image may vary (its mapping software) so I dont want to start drawing over other widgets?

any pointers?

thanks
Reply With Quote
Sponsored Links