Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

JLabel and ImageIcon question

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am new to applets.
As of now I have the following:
ImageIcon bluePic = new ImageIcon("blue.gif");
JLabel instr = new JLabel("Hello", bluePic, JLabel.CENTER);
contentPane.add(instr);
The above produces the text i.e. "Hello" next to the image. I would like this Hello to be displayed "on the image itself" and not next to it. Is there any way to achieve this?
I basically have an applet whose label values changes frequently (JMS), thus I would only like to change the text again and again, but would like the text to appear on top of the image and not beside it.
I would be grateful if somebody could help me out.
Sanjit
P.S: One possible solution would be to set the background of the Label (the imageicon is for a blue background). Is there any way to set the background color of a JLabel??
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can set the background of any component. The example below shows with a label.

Regards,
Manfred.
 
This tiny ad is suggesting that maybe she should go play in traffic.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic