• 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

Drawing on a JPanel fails

 
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am drawing strings on a JPanel after I draw the image of a JPG. The paint component method is

I first draw the image of the JPG and this is working; then I call drawOnGlassPane to draw entered strings. Initially, I was drawing on the glass pane of the parent but since it didn't work I tried the graphics of the JPanel

The line "graphics.drawString(enteredText, xCoordinate, yCoordinate);" is being executed.
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I doubt it is the problem but you should not be using drawImmediately inside the paintComponent(() method.

Post your SSCCE that demonstrates the problem.
 
Alejandro Barrero
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rob. No that's not the problem. It is a weird problem with Eclipse or MyEclipse, because the code works fine in another workspace or project. I am writing to them. I DON'T KNOW HOW TO SET THIS TO RESOLVED.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alejandro Barrero wrote:No that's not the problem.


Even if it's not *the* problem, it most certainly is *a* problem.

To repeat what Rob said: You should not be using drawImmediately(...) inside the paintComponent(...) method
 
reply
    Bookmark Topic Watch Topic
  • New Topic