Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

image in glassPane

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Here is my problem. I've made a glassPane extending JPanel which overrides a JFrame and blocks all the key/mouse events. What I want to do is to set an image to be displayed in the glassPane while it is visible. I've tried all the other components(JTextField, JLabel etc) and are been displayed just fine expept one. Guess what! The one that I want to use , an image! So my question is: Is something special with the image? How can I implement what I want?
Thanks a lot
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thougt I understood a few things about swing, but after reading


"...I've made a glassPane extending JPanel which overrides a JFrame..."


I am not so sure!
With impatience I wait for a reply of one of the ranch-hands!
 
Sheriff
Posts: 22573
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How did you add the image? Using an ImageIcon and JLabel, or some other way?
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post code! This works for me. Notice that you may have to explicitly reset
your glasspane to be visible after you add it.
 
Agapios Hartzoulakis
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry if I wasn't quite clear.I didn't mean to make you forget what you already know!
Well, I'm using a class gor the glassPane that I found in another site and it works just fine for me except from the detail with the image.
The class is:

in the constructor of the main frame


I guess I have to change the paint method so that my image to be shown (the image is in the same folder as the rest of the .java files)
I hope to be more clear this time.
Thanks in advance
 
Agapios Hartzoulakis
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
At last I found my error by reading some other topics. Thanks anyway
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic