JTabbedPane tab selection colors

I'm just wondering if there's an easier way to change the colors of the tabs in a JTabbedPane when moving between tabs?? I've tried the UIManager.put() with no luck.
public void stateChanged(ChangeEvent event)
     if (tabbedPane.getSelectedIndex() == 0)
          tabbedPane.setBackgroundAt(0, panelColor);
          tabbedPane.setBackgroundAt(1, null);
          tabbedPane.setBackgroundAt(2, null);
     else if (tabbedPane.getSelectedIndex() == 1)
          tabbedPane.setBackgroundAt(0, null);
          tabbedPane.setBackgroundAt(1, panelColor);
          tabbedPane.setBackgroundAt(2, null);
     else if (tabbedPane.getSelectedIndex() == 2)
          tabbedPane.setBackgroundAt(0, null);
          tabbedPane.setBackgroundAt(1, null);
          tabbedPane.setBackgroundAt(2, panelColor);

Try something like this:
public void stateChanged(ChangeEvent e)
     for (int i = 0; i < tabbedPane.getTabCount(); i++)
          tabbedPane.setBackgroundAt(i, Color.yellow);
          tabbedPane.setForegroundAt(i, Color.redl);
     int selected = tabbedPane.getSelectedIndex();
     tabbedPane.setBackgroundAt( selected, Color.blue );
     tabbedPane.setForegroundAt( selected, Color.green );
}Does this code work for you?
When I try this code the setForegroundAt() method works.
The setBackgroundAt() method works inside the for loop, but not outside. That is I see tabs with a background of yellow, but the selected tab still shows a background of grey, not blue. Does this happen for you.
I'm running the Windows LAF on Windows 98 and JDK1.3

Similar Messages

  • Updating a JTabbedPane's selected tab color dynamically

    Hi
    I have set the selected tab color for my JTabbedPane
    using:
    UIManager.put("TabbedPane.selected", Color.RED);Now I would like to change the color dynamically to green.
    However, just calling:
    UIManager.put("TabbedPane.selected", Color.GREEN);doesn't work.
    It seems that if the JTabbedPane is visible while I change the color through the UIManager, it has no effect.
    On the other hand, all the other JTabbedPanes in my application (which are not visible - in hidden dialogs), are effected.
    How can I effect ALL the JTabbedPanes in my application at the same time?

    Try to call
    SwingUtilities.updateComponentTreeUI(selectedPane);
    best regards
    Stas

  • JTabbedPane selection color

    is it possible to change the default JTabbedPane selection color? (light gray)
    It doesnt seem to give you the ability to set a Renderer

    If altering the UI for your JTabbedPane is an option for you then this becomes pretty easy, just override the "paintTabBackground" method of BasicTabbedPaneUI. This isn't an option for a lot of people though... since that would pretty much limit you to one UI.
    Otherwise you will have set the background of the tab manually... the following code is an example of how to do this... unfortunatly... MetalTabbedPaneUI overrides the paintTabBackground method and DOESN'T use the manual backgrounds for selected tabs, it ALWAYS uses the default selectedColor from the UIManager... looks like an oversite to me... anyway... this code works fine with the Windows Look and Feel...
    import javax.swing.*;
    import javax.swing.event.ChangeListener;
    import javax.swing.event.ChangeEvent;
    import java.awt.*;
    * <pre>
    * SBTabbedPane
    * </pre>
    public class SBTabbedPane extends JTabbedPane {
         private Color tback;
         private int tsel = -1;
         private Color sback;
         public SBTabbedPane() {
              addChangeListener(new ChangeListener() {
                   public void stateChanged(ChangeEvent e) {
                        redoback();
         public void setSelectionBackground(Color c) {
              sback = c;
              redoback();
         private void redoback() {
              if (tsel >= 0) {
                   setBackgroundAt(tsel, tback);
              int i = getSelectedIndex();
              if (sback != null && i >= 0) {
                   tback = getBackgroundAt(i);
                   tsel = i;
                   System.out.println("SET BACK: " + tsel + ": " + sback);
                   setBackgroundAt(tsel, sback);
         public static final void main(String[] args) {
              try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              } catch (Exception e) {}
              SBTabbedPane test = new SBTabbedPane();
              test.setSelectionBackground(new Color(255,0,0));
              test.add("Tab 1", new JLabel("HELLO"));
              test.add("Tab 2", new JLabel("WORLD"));
              JFrame testframe = new JFrame("Test Window");
              testframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              testframe.getContentPane().setLayout(new BorderLayout(0, 0));
              testframe.getContentPane().add(test);
              testframe.pack();
              testframe.setVisible(true);
    }Hope this helps a little...
    Josh Castagno
    http://www.jdc-software.com

  • Tab Set Label Colors - How do I change the selected tab label color?

    No matter what color I tell it to use for the Labels - Selected color I get white.  Is this a known bug in the system or am I not doing something correct.  I have a tab set component and a label based menu selector component on my display.  I've set up the labels and backgrounds for both components exactly the same but I can only get white for the selected tab set label.
    Edited by: Maureen LaComb on Feb 19, 2009 5:38 PM

    Hi, Maureen
    You can set the color of Tab Set by using the Following Steps.
    --> Select the Tab Set
    --> From the the Properties Window
    --> Select Appearance
    --> There are Two Tabs "Text" and "Color"
    --> From the Color Tab you can Select the Background Color
    --> Tab BackGrounds Or Labels from here you can select the color.
    But this setting will Apply to all the Tabs in a Tab Set, I think you can't set the Specific Setting for a single Tab in a Tab Set.
    Please Reply if any Issue,
    Kind Regards,
    Faisal

  • Setting the tab text color in JTabbedPane

    How do I set the text color of tabs? I have to make the text color of one tab to blue and the other tab text color to red. Thanks.

    I tried giving the below but text color is the default it did not change. 'this' is the JTabbedPane. Any other suggessions? Thanks.
    this.setForegroundAt(0,Color.blue);
    this.setForegroundAt(1,Color.red);

  • JTabbedPane - BOLD selected tab title text.

    I want to BOLD the selected tab's title text while keeping the unselected tabs' title text in normal font. Anyone know how to achieve this effect?

    I think the simplest  way is to use JTabbedPane.setTabComponentAt, add your own labels, add a ChangeListener to the JTabbedPane and change the labels fonts when tab selection changes.

  • JTabbedPane - Catching tab selection change

    I want to catch each tab selection change in my JTabbedPane.
    When I used ChangeListener, my program was unable to correctly
    indicate selected tab in some cases, i.e.:
    JTabbedPane contains two tabs: 0,1.
    Tab 0 was selected.
    Tab 0 was deleted.
    In this case JTabbedPane selects tab 1, but selected index remains
    unchanged and stateChanged is not called. How can I catch this?

    This trick is working, but you see, the problem is more
    complicated. The problem is that stateChanged() doesn't work
    when index remains unchanged. This is also true for insertTab().
    Both insertTab() and removeTabAt() (and maybe smth. else) causes this problem.
    Maybe, possible solution will be to override some method of
    JTabbedPane, responsible for activating a tab like this...?
    tabbedPane = new JTabbedPane {
        activateTab(...) {
            super.activateTab(...);
            firePropertyChange(...);
    }But what is the methods prototype and can it be overriden
    at all??
    In the deep sources of swing :) I've found such tricks:
    In JTabbedPane.insertTab():accessibleContext.firePropertyChange(
        AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
        null, component);In JTabbedPane.removeTabAt():accessibleContext.firePropertyChange(
        AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
        component, null);I'm almost convinced that this is the point. But!
    I've never worked with Accesibility :(
    And I couldn't find out what to do having only swing sources.
    Need help.

  • How do I add selective color to black and white photo?

    New to Photoshop Elements 12.  How do I add selective color to a black and white photo?

    The easiest way is to use the Smart Brush tool in Expert tab.
    On the tool's option bar, in the drop-down select "Revers Effects", then select the "Reverse" option. Be sure that "Inverse" is ticked.
    Paint over the object that is to retain color, the rest will become b/w.

  • Set tab boder color

    Hi,
            I need to set the selected border color of a tab navigator from css during run time. Can anybody help me.
    regards,
    Jayagopal.

    UIManager.put("TabbedPane.background", Color.RED);
    UIManager.put("TabbedPane.selected", Color.RED);
    Place those lines in your application entry point (e.g. main() method).

  • Question about HSL Develop Controls vs. Photoshop Selective Color

    Im an advanced Photoshop user and I enjoy shooting landscapes, macros and abstracts. Ive just started to experiment with Lightroom and have used it to process several hundred shots from a recent trip to the California Coast.
    Even though my usage of the next Develop controls in Lightroom is still pretty limited, I find the new Basic Develop and Tone Controls to be very intuitive to use and Im getting better results than I could from Adobe Camera Raw 3.7 and earlier. Therefore, kudos to the Lightroom team.
    But, I also have some questions regarding the HSL controls and what seems to be an omission of some useful functionality. To help with framing my question lets assume that we have shot of a waterfall in the forest. The waterfall is in partial shade and the rest of the scene is in partial to full sun. Also the histogram for image indicates that a blend of several bracketed images isnt needed to deal with the overall dynamic range within the scene.
    If I was processing this shot in Photoshop, I would likely adjust the overall White Balance / Exposure / Black Clip / Contrast / Brightness in Camera Raw and then finish the image within Photoshop. Since the water of the waterfall described above is in the shade, it will likely have a color cast relative to the White Balance that I set for the rest of the image that is full sun.
    With Photoshop, I would often set a couple of sample points and then use a Selective Color layer to correct for the color cast in the whites of the water and to neutralize the blacks in the shade. I would also sometimes increase the amount of black in the Selective Color Blacks tab to enhance the image contrast. These adjustments could have layer masks associated with them but for this example lets assume that the dont need any mask. Thus, I would hope that I could accomplish the same type of globally based whites and blacks color cast removal within Lightroom but I cant seem to find a way to accomplish this.
    With Lightroom, I see that there are a set of HSL controls that should be able to handle much of what Selective Color could handle on a global level within Photoshop but I dont see any controls to deal with the Whites or Blacks. Am I missing something? Is there a way to accomplish the type of correction that I described above with Lightroom or am I going to have to take the image out to Photoshop and use Curves and/or Selective Color?
    Dave

    Fred, Richard - Thanks for responding.
    I've tried the TAT tool but it only controls the colors controlled by the sliders in the HSL palette. Therefore, it doesn't seem to have any affect on the hue of the whites or blacks in a picture.
    Regarding selective editing, I realize the the controls within Lightroom are global but unless I use a Layer Mask the Selective Color functionality within Photoshop is also global. That is, if I change the hue of the blacks then all blacks are affected. Hence, it seems to me that the HSL controls within Lightroom and the CYMK controls within Selective color can be used to do much the same thing. The big difference is that the Selective Color control set include the ability to adjust blacks and whites but this isn't included within Lightroom.
    I also posted my message in the ACR forum as ACR 4.0 is going to include the same set of controls that the Develop module in Lightroom contains. Someone there suggested that I might be able to use the split toning controls to warm up the shadows and I will give this a try. I also plan to post in the Feature Requests Forum.
    Thanks again for your help.
    Dave

  • Photoshop CC selective color UNDO BUG

    do this in photoshop CC:
    - open an image
    - layer -> new adj layer -> selective color
    preset: custom
    colors: reds
    cyan -100%
    press ctrl+z for UNDO
    it restores the effect on the image but it doesnt update the setting to 0%
    same thing in all adjustment layers, exposure, levels, curves..
    this sucks!
    doesn't work even through history tab
    my hardware?
    core2duo 3.16
    6gb ddr2 1066
    nvidia 9600gt with the latest drivers
    ssd
    windows7 64bit
    any ideas?

    i had this issue too.
    press CTRL + K
    or go to edit -> prefrences -> general
    go to performance section
    and press the DEFAULT button
    and assign a scratch disk (c:) for example
    press ok
    restart photoshop and you're done probably
    well that worked for me though.

  • Change Highlight Selection Color

    The default color when a cell or item is selected is a light cyan. On my computer it is very hard to discern text because the light cyan highlight color and the white text run together. How can I adjust the highlight/selection color so that text is legible?

    The selected item color is actually determined by your OS. To change it in Windows XP:
    Right click on your desktop
    Properties
    Appearance Tab
    Advanced
    Item Drop down: Chose "Selected Items"
    Change the color to whatever you like

  • Action written in CS4 won't run correctly in Elements 11 - specif. the "selective color" layer

    I created an action using Adobe Photoshop CS4, and it runs correctly in CS4.  When I save and load the action into Elements 11,  there is a problem with the selective color layer.  The selective color layer shows up in the layer stack along with the expected message that it can't be edited b/c it was created in the full version of Photoshop. However, the layer itself does not have any color/changes in it.
    In Photoshop, the selective color layer makes the photo look pink.  When I run the action in Elements11,the selective color layer does absolutely nothing to the photo.  I do have the eye turned "on" to view the layer, and it's set at the correct blending options & opacity (normal, 100%). 
    If I run the action in Photoshop, save the file with all the action-created layers, and reopen the file in Elements 11, THEN the selective color layer shows its correct pink color.  But when I run the action as a stand-alone action in Elements11, it does not.
    Can anyone offer help as to why this is happening? Is there something special I need to do to make the action work correctly in Elements 11? My understanding was that it should RUN and create the layers correctly, although some of them will not be editable in Elements11. However, as it stands, it is not creating them with the correct color.
    Thanks in advance for your help!

    You probaly need to record the action in a little different way in photoshop cs4 to get the selective color adjustment layer to work.
    Try something like this:
    1. In photoshop cs4 add an selective color adjustment layer, but don't do any adjustments and stop recording the action.
    2. Undo the selective color adjustment layer and then double click on on the selective color adjustment layer step in the actions panel
       and when the dialog opens set your adjustments and click ok.
    Now it should work in pse 11:

  • Select- Color Range- Results in Blue Screen (PC)  (driver out of date)

    I've been using the CS6 beta about two days.  While experimenting with color range I experienced two consecutive blue screen crashes.  The first time it happened,I was working with the color range selector and was replacing the selected areas with another color using the paint bucket.  About the third time I attempted this, my PC blue screened.  The second time, I opened a photo, went to Select>Color Range and got an immediate blue screen crash.
    I then went back to CS5 and I've been playing with the same scenario with no apparent problems.
    My PC is a store built computer.  It consists of an MSI 990-FXA GD80 motherboard, an AMD Phenom 1100t CPU, Asus GTX550 Ti graphics card and 8 gig of RAM.  It boots from a 60 gig SSD and my programs reside on a 500 gig hard drive.  The OS is Windows 7 Professional 64 bit.  CS6 is using the hard drive for its scratch disk and Photoshop is using 4339 mb of the 7232 mb of available RAM - I haven't changed that.  I'm running CS6 as administrator because the way it installed, it would only run in that fashion.
    One disappointment during the installation was CS6 made no attempt to read my preferences from the CS5 install.  That may be covered in another post, I've not yet looked.
    Please keep us informed as new betas are released, because I would like some time to work with this puppy before plunking down big bux for the upgrade.  As it is now, I'm going back to CS5.  I get mighty nervous when my super computer blue screens!
    Gerry
    gswetsky AT bellsouth DOT net

    The GPU is often at root of issues like yours. I've had so many problems with Nvidia drivers for their gaming-oriented adapters (like yours) that I finally went with one of their workstation cards. I have a Quadro card with just enough RAM to make Photoshop happy. The workstation drivers are optimized for reliability, the consumer card drivers are optimized for gaming and that often means they're less stable and reliable with Photoshop.

  • Multi color gradient for touch and selected color of spark mobile list

    multi color gradient for touch and selected color of spark mobile list
    how to get dat?

    or how about a bitmap as the background for the touch and selected color for the items in a list.

Maybe you are looking for

  • TS2755 I Message not working

    I have an iPhone 4 and my imessage no longer works. I have tried to reset the phone, turned the messge off and back on and everything I have seen online to try but nothing works. Just a few months ago I got a new iMac, could that be a problem? Any id

  • Hooking up an external NTSC Device

    I have a Sony GV D900 mini Dv deck that I'm trying to view my desktop as I edit. I hook the deck up to the TV via s-video and from the deck to the computer via firewire when I print to video I see my image on the computer and the TV but when I'm in F

  • How can my co-worker and I set it up so we can see each others calendar like what is available in Outlook?

    One of my co-workers and I work very closely and schedule appointments for one another. In doing so it would really be convenient if I could open up his calendar to see when he would be available and he schedules meetings for us both as well. I know

  • ORA-01482: unsupported character set

    Hello, does anybody have an experience with error message "ORA-01482: unsupported character set" which is displayed instead of the content of page region, which is of type select SQL. The strange thing with this is that e.g. LOVs are rendered/display

  • Using 'what size' what in Library (and other folders) to delete?

    In Library I notice a lot of 'packages' and 'receipts' folders/files - 'pkg' files - can they be dumped? There seems to be similar files in 'previous system' - can they be dumped too? What is the 'private/var' folder? - can anything be dumped from th