But this also sets the background of the navigation arrows (if there
are more tabs than can be displayed). How do I set only the selected
tab color without changing the button colors? (Using Java1.6)
--
Fred K
Can you use WRAP_TAB_LAYOUT for your tabLayoutPolicy? See also:
<http://download.oracle.com/javase/tutorial/uiswing/examples/components/index.html#TabComponentsDemo>
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
My app may have many, many tabs. Wrapping is impractical - takes up
too much real estate.
A new problem: we are now using Nimbus Look-and-feel and the statement
UIManager.put( "TabbedPane.selected", color );
no longer works. It merely sets the color of the navigation arrows (if
they exist), and does nothing to the selected tab.
--
Fred K
> On Aug 22, 11:12 am, "John B. Matthews" <nos...@nospam.invalid> wrote:
> > In article
> > <2488a5a5-932a-4817-9dc0-ffa3f02ec...@p37g2000prp.googlegroups.com>,
> >
> > Fred <fred.l.kleinschm...@boeing.com> wrote:
> > > I want to set the color of the selected tab in a JTabbedPane. I
> > > use: UIManager.put( "TabbedPane.selected", color );
> >
> > > But this also sets the background of the navigation arrows (if
> > > there are more tabs than can be displayed). How do I set only the
> > > selected tab color without changing the button colors? (Using
> > > Java1.6)
> >
> > Can you use WRAP_TAB_LAYOUT for your tabLayoutPolicy? See also
> > TabComponentsDemo:
> >
> > <http://download.oracle.com/javase/tutorial/uiswing/examples/components/index.html>
>
> My app may have many, many tabs. Wrapping is impractical - takes up
> too much real estate.
>
> A new problem: we are now using Nimbus Look-and-feel and the
> statement UIManager.put( "TabbedPane.selected", color ); no longer
> works. It merely sets the color of the navigation arrows (if they
> exist), and does nothing to the selected tab.
I don't see "TabbedPane.selected" among the Nimbus defaults, but it
looks like you have plenty of options. Apparently, you can even replace
the relevant Painters:
<http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/info.html>
<http://www.jasperpotts.com/blog/category/nimbus/page/2/>
<http://jasperpotts.com/blogfiles/nimbusdefaults/nimbus.html>
I can't help but notice the similarity between the two interfaces:
<http://download.oracle.com/javase/7/docs/api/javax/swing/Painter.html>
<http://download.oracle.com/javase/7/docs/api/javax/swing/Icon.html>
That's the problem. This (using "TabbedPane.selected") is how we've
done
it for all other L&F's, and it's how the tutorials have always said
to
do it. But for some reason the develolpers of Nimbus chose not to
make
this available.
> but it
> looks like you have plenty of options. Apparently, you can even replace
> the relevant Painters:
>
> <http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/info.html>
> <http://www.jasperpotts.com/blog/category/nimbus/page/2/>
> <http://jasperpotts.com/blogfiles/nimbusdefaults/nimbus.html>
>
> I can't help but notice the similarity between the two interfaces:
>
> <http://download.oracle.com/javase/7/docs/api/javax/swing/Painter.html>
> <http://download.oracle.com/javase/7/docs/api/javax/swing/Icon.html>
>
The problem in using the painter is that I need to know how the Nimbus
painter draws it so that in my override of the paint method I can do
exsactly the same thing, just with a different background color. If I
just draw a rectangle, its shape will be different than all of the
other tabs, which use some kind of rounded rectangle for the outer
part of the tab, and rectangular corners for the inner part of the
tab.
One should be able to do such a simple thing in a single line.
--
Fred K
> > but it looks like you have plenty of options. Apparently, you can
> > even replace the relevant Painters:
> >
> > <http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/info.html>
> > <http://www.jasperpotts.com/blog/category/nimbus/page/2/>
> > <http://jasperpotts.com/blogfiles/nimbusdefaults/nimbus.html>
> >
> > I can't help but notice the similarity between the two interfaces:
> >
> > <http://download.oracle.com/javase/7/docs/api/javax/swing/Painter.html>
> > <http://download.oracle.com/javase/7/docs/api/javax/swing/Icon.html>
> >
>
> The problem in using the painter is that I need to know how the
> Nimbus painter draws it so that in my override of the paint method I
> can do exsactly the same thing, just with a different background
> color. If I just draw a rectangle, its shape will be different than
> all of the other tabs, which use some kind of rounded rectangle for
> the outer part of the tab, and rectangular corners for the inner part
> of the tab.
Can you usefully invoke the existing Painter, perhaps in conjunction
with a suitable AlphaComposite?
> One should be able to do such a simple thing in a single line.
I disagree. I see the defaults as belonging to the UI delegate or the
user. I rarely alter them unless it affects usability in some critical
way, e.g. unacceptably low contrast. Even then, I question my own color
choice before tinkering with the delegate's design.
OK, sometimes I can't resist a custom SliderUI:
<http://stackoverflow.com/questions/6996263>
I like that!
--
Knute Johnson