JTabbedPane ignoring setBackground

R

Russell Wallace

When I set up a JTabbedPane, it insists on displaying in blue - granted,
a rather pretty shade of blue, but one that does not go at all well with
the other interface colors; and setBackground does nothing, it only
changes the color of unselected tabs. Does anyone know how to change this?

Thanks,
 
K

Knute Johnson

Russell said:
When I set up a JTabbedPane, it insists on displaying in blue - granted,
a rather pretty shade of blue, but one that does not go at all well with
the other interface colors; and setBackground does nothing, it only
changes the color of unselected tabs. Does anyone know how to change this?

Thanks,

No. You can't. And how would you know what tab is selected?
 
R

Russell Wallace

Knute said:
No. You can't. And how would you know what tab is selected?

Use grey or something that fits with the other components... hmm, thanks
for the feedback... there must be _some_ way to do it, though, if
something that simple was unfixable Java wouldn't be much use for
desktop programs. Maybe a custom look and feel could do it, or
subclassing JTabbedPane and overriding something?
 
P

Paul van Rossem

Use grey or something that fits with the other components... hmm, thanks
for the feedback... there must be _some_ way to do it, though, if
something that simple was unfixable Java wouldn't be much use for
desktop programs. Maybe a custom look and feel could do it, or
subclassing JTabbedPane and overriding something?
Sure you can. Which part of the tabbed pane do you want to change? Tabs,
background, text? And what look and feel do you use (I don't get any
blue...)

Paul.
 
R

Russell Wallace

Paul said:
Sure you can. Which part of the tabbed pane do you want to change? Tabs,
background, text? And what look and feel do you use (I don't get any
blue...)

In the default (Java/Metal) look and feel, a pane with no tabs shows as
blue, then when you add e.g. a panel component with a tab, when
selected, the blue still shows as a thin line around the panel; that's
what I'm wondering how to change.

Checking some notes and links I had from a previous discussion some
years ago, yes, L&Fs do seem to be able to change pretty much any aspect
of the appearance, so that would be a general answer to how to do things
if there isn't a simpler way.
 
P

Paul van Rossem

In the default (Java/Metal) look and feel, a pane with no tabs shows as
blue, then when you add e.g. a panel component with a tab, when
selected, the blue still shows as a thin line around the panel; that's
what I'm wondering how to change.

Checking some notes and links I had from a previous discussion some
years ago, yes, L&Fs do seem to be able to change pretty much any aspect
of the appearance, so that would be a general answer to how to do things
if there isn't a simpler way.
You can change the L&F for this area with:

UIManager.put("TabbedPane.contentAreaColor",
new ColorUIResource(red, green, blue));

Paul.
 
R

Russell Wallace

Paul said:
You can change the L&F for this area with:

UIManager.put("TabbedPane.contentAreaColor",
new ColorUIResource(red, green, blue));

That works, thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top