By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,492 Members | 1,289 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,492 IT Pros & Developers. It's quick & easy.

JLabel background color

P: n/a
I have the following code to put a label on a tabbed panel.
It does not set the background though.
If I put in a "slabel.getBackground()" it returns the color
I chose for the set.
It is like the background is transparent, the
color of the tabbed panel is there. The text is ok.
(checkboxes and radiobuttons work ok.)
It doesn't matter if the setBounds() is before or
after the setBackground()
Any advice appreciated.
===
class ButtonPanel extends JPanel {
public static ButtonPanel bpanel = null;

JLabel slabel = new JLabel(bname);
slabel.setBackground(bkg);
slabel.setFont(bfont);
slabel.setBounds(...);
bpanel.add(slabel);
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
found the problem
need to add slabel.setOpaque(true);
then all seems well
"Phil..." <ry***@ieee.org> wrote in message news:Mp77b.293033$Oz4.81570@rwcrnsc54...
I have the following code to put a label on a tabbed panel.
It does not set the background though.
If I put in a "slabel.getBackground()" it returns the color
I chose for the set.
It is like the background is transparent, the
color of the tabbed panel is there. The text is ok.
(checkboxes and radiobuttons work ok.)
It doesn't matter if the setBounds() is before or
after the setBackground()
Any advice appreciated.
===
class ButtonPanel extends JPanel {
public static ButtonPanel bpanel = null;

JLabel slabel = new JLabel(bname);
slabel.setBackground(bkg);
slabel.setFont(bfont);
slabel.setBounds(...);
bpanel.add(slabel);
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.