• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

About Jpanel paintcomponent

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello all
I am try to display the graphics elements like line with the button component and I choose to display that in Panel using paintComponent But It is display that two time and It is not working properly.

could any one tell me what to do in that case and there is any mecanism to get the graphics object instead of using paintcomponent() fuction because i think that the problem is occuring with that function.


Thanks in advance
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use the JComponent method getGraphics to get a reference to the graphics context. What you draw with it will not survive past the next system–triggered repainting episode. For persistence, it is recommended that you do all drawing from within the paintComponent method for JComponents.

You mentioned Panel which is an AWT component. For AWT components you use the paint method. It is recommended that we not mix Swing and AWT components.
reply
    Bookmark Topic Watch Topic
  • New Topic