473,503 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JLabel background color

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
1 8301
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5893
by: prabhat | last post by:
Hi, I am getting this weird behavior. I have couple of gif and jpg files that I would like to display in JLabel. It displays one jpg image but it does not display other gifs and jpgs. Any idea why...
0
2064
by: Mike | last post by:
Hello, Is there a way of setting text for a JLabel after a certain amount of empty characters. For example, I want to avoid doing this JLabel label = new JLabel(); label.setText(" ...
6
3238
by: James Nugent | last post by:
Hi everyone, My app need to manipulate JLabels that have been added to the pane. All I need to do is simple stuff like make them disappear or change their background color. Unfortunately (and...
2
25447
by: reon | last post by:
Hi in this code when i clicked login button...it shows output as login... But when i clicked each time its repeating .. i want to see that only ones ... I want to clear the previous login before...
5
6838
Shinzon
by: Shinzon | last post by:
ok so far I have got: JFrame frame = new JFrame( "Matt's DVD's" ); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frame.setSize( 420, 170 ); // set frame size ...
5
6895
Shinzon
by: Shinzon | last post by:
Ok so I have been working on this for a moment now and wondering how to add multiple jlabels to a jframe. the code looks like this: JLabel jl = new JLabel("DVD ID #= " + dvd); //Displays DVD...
3
2335
nanhiPari
by: nanhiPari | last post by:
hello everyone i need to create DYNAMIC JLABElS(say 5)..yes i know it sounds easy but i also have to give them Events n then want to refer each of them when ever Mouse is Clicked on a Specific...
1
1993
by: tommyny04 | last post by:
I have a method addPlayer that's supposed to add a JLabel to a JPanel and update the JPanel. The JLabel is just a label with a player's name in it. The code I've wrote doesn't work and I'm not sure...
6
6046
by: thesti | last post by:
hi, i have a JLabel inside a JPanel of which layout manager is BoxLayout. i will display an image with the JLabel at runtime, when the application first start, it will appear as an empty box...
0
7087
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7281
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1514
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
737
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
383
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.