• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JLabel and ImageIcon question

 
Sanjit Singh
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??
 
Manfred Leonhardt
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic