File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Add Graphics to Jpanel

 
Behrouz Hosseini
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again,
I just wondering how I can add a Graphics object like rectangle to a JPanel?
I have following classes and I can add the Label object into MyPanel but I cant add drawing object (MyRect) into Jpanel.I know that I am not constructing any thing in MyRect() constructor! so it make sence for me that nothing will happen in MyPanel when I call for MyRect constructor but I don't' know how to call the paintComponent with it's parameters in MyPanel class!
Could you please let me know is it possible to add a drawing into a panel?
so what's wrong with this code?



Best Regards,
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
debugging 101:

after adding/displaying, print out the panel's size
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic