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

Similar Messages

  • JTabbedPane SelectedTab Color

    I have this problem: I would like to change the Default Tab Background Color in a JTabbedPane (not the setBackgroundAt method!!!).
    Thanks to all

    The key is:
    UIManager.put("TabbedPane.selected", Color.green);
    .. as this example (found in www.esus.com/javaindex/j2se/jdk1.2/javaxswing/generalpurposecontainers/jtabbedpane/jtabbgcolor.html)
    shows:
    import javax.swing.plaf.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    public class Main extends JPanel {
    public Main() {
    setLayout(new BorderLayout());
    UIManager.put("TabbedPane.selected", Color.green);
    JTabbedPane tabbedPane = new JTabbedPane();
    for (int i=0;i<10;i++) {
    tabbedPane.addTab("Tab #" + i, new JLabel("Tab #" + i));
    tabbedPane.setBackgroundAt(i, new Color(25*i, 25*i, 25*i));
    add(tabbedPane, BorderLayout.CENTER);
    JPanel createPane(String s) {
    JPanel p = new JPanel();
    p.add(new JLabel(s));
    return p;
    public static void main(String[] args) {
    JFrame frame = new JFrame("JTabbedPane Selected Color Demonstration");
    frame.addWindowListener( new WindowAdapter() {
    public void windowClosing( WindowEvent e ) {
    System.exit(0);
    frame.getContentPane().add(new Main());
    frame.setSize(200, 100);
    frame.setVisible(true);
    bye!

  • 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

  • JTabbedPane Background Color

    Hello,
    How can i change the Background Color for the JTabbedPane?
    thanks

    play with this:
    UIManager.put("TabbedPane.selected", Color.cyan);

  • 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.

  • How can I change the 'selected' color of one JToggleButton only.

    Hi,
    This seems like a simple / trivial question, but I just can't figure it out. Is there a way that I can create a JToggleButton and change the selected color of only that JToggleButton.
    I'm trying to create a simple sidebar like component for navigation within my app. A group of JToggleButton[s] added to a ButtonGroup (with the proper layout / sizing) works great, but the default JToggleButton colors don't suit my needs. I know that I can change the colors using the UIManager / UIDefaults, but I don't want to change the defaults for every JToggleButton in my app. I only want to change the defaults for a few select JToggleButton[s].
    For example, I can do this:
    UIManager.put("ToggleButton.select", UIManager.getColor("Table.selectionBackground"));
    UIManager.put("ToggleButton.background", UIManager.getColor("Table.background"));but I'd rather do something like this:
    JToggleButton jtb = new JToggleButton("Toggle Button Text");
    jtb.setSelectedColor(UIManager.getColor("Table.selectionBackground"));
    jtb.setBackground(UIManager.getColor("Table.background"));The only thing is, I can't find any method that is the equivilant of 'setSelectedColor(Color)' for JToggleButton.
    I know I could do it by adding some listeners to the JToggleButton[s], but that seems a little complicated for something like changing a color.
    I'd also seen a solution in the forums where someone had extended the ButtonUI of the pluggable look and feel they were using. I'm not interested in modifying the look and feel I'm using. As far as I'm concerned, that would defeat the purpose of having a pluggable look and feel as I would have to duplicate my efforts for every look and feel I want to use.
    Any help would be appreciated,
    Ryan

    try this
    import javax.swing.*;
    import java.awt.*;
    class Testing extends JFrame
      public Testing()
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(250,75);
        setLocation(400,300);
        JPanel jp = new JPanel();
        JToggleButton jtb = new JToggleButton("Toggle me");
        jtb.setUI(new MyUI());
        jp.add(jtb);
        getContentPane().add(jp);
      public static void main(String args[]){new Testing().setVisible(true);}
    class MyUI extends javax.swing.plaf.metal.MetalToggleButtonUI
      public Color getSelectColor(){return Color.BLACK;}
    }

  • Photoshop CS2 crashes when opening selective color

    Every time I try to open image/adjust/selective color the program crashes.
    It has also started crashing after I save a file.
    I have tried uninstalling and re-installing the program, but to no avail.
    I'm using a Mac Mini OSX 10.4.1 with 1 GB ram.
    I've been running CS2 on this computer for 2 years without a hitch.
    Any fix or advice would be appreciated.

    I would suggest updating to 10.4.11 as there have be many bug fixes since 10.4.1

  • How to get "Selected" color for custom toolbar buttons?

    RH 8.0.2.208
    RoboHelp HTML
    WebHelp output
    I'm getting flack from internal QA folks about the custom toolbar buttons not having the same "selected" color as the default buttons (Contents, Index). I've copied the background color info from the <btnselected></btnselected> section for the built-in Contents to the <btnselected></btnselected> section for a custom toolbar button, but RH is ignoring it.
    Any hints?
    Leon

    You could try using the raw converter. Open one file and edit it (File>Open, pick the image and choose Camera Raw as the format before you click Open). Then open the next image and click the little four-lined square on the upper right side of the ACR window and choose Previous Conversion from the flyout menu.

  • Black and white selective coloring with brushes disappeared

    The down and dirty:
    Upgraded to Aperture 3.1.1
    Aperture then updated my library
    I open a file that I have selectively colored with black and white (a track and field runner and her lane is color, the field is black and white) and to my horror the thumbnail and "quick preview" is correctly colored, but the full resolution image is not
    How do I get my hard work back?

    I'd like to add one last bit that seems strange to me (and gives me hope that I can recover my edits). When I switch "quick preview" from on to off and the image zooms to the native resolution my edits are in tact for half a second before going away (the image fully loads - I'm not looking at an expanded rendering of the quick preview).
    Also, when I move the image at full zoom my B&W edits flash briefly until I stop moving the image.
    I tried repair permissions and repair database. Both failed.

  • I'm using an iMac running Os X Yosemite, Photoshop CS5 Extended, R2880 Epson printer  In the Print Settings dialog box, I can't select Color, Advanced BW or Grayscale unless I select "Printer Manages Color". The pull down menu is grayed out. Even with "pr

    I’m using an iMac running Os X Yosemite, Photoshop CS5 Extended, R2880 Epson printer  In the Print Settings dialog box, I can’t select Color, Advanced BW or Grayscale unless I select “Printer Manages Color”. The pull down menu is grayed out. Even with “printer manages color” the tif or jpg image comes out in color overlaid with black. (See example - printer1. image on left is close to what it should be). Photoshop has no updates pending. I’ve downloaded the latest Epson driver which was working fine just before the problem occurred

    Is your Photoshop CS5 updated to 12.1?
    Are you on Yosemite 10.10.1 or Yosemite 10.10.2?
    Did you apply the recent Epson software 2.1.9 update?
    What type of file is it (file format)?  What bit depth and what color space?
    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    a screen shot of your settings or of the image could be very helpful too.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • I have Photoshop CS5 and a Epson 3880 . The print setting dialogue box won't open when selecting color output PRINTER MANAGES COLORS

    I have Photoshop CS5 and a Epson 3880 . The print setting dialogue box won't open when selecting color output PRINTER MANAGES COLORS
    It does ope when selecting PHOTOSHOP MANAGES COLOURS . This is first time in 7 year this has happened.
    Any one with ideas/

    What is your screen resolution?
    What operating system?

  • Change selective color(pixels) of an image.

    I want to change the selective color of an image to another desired color. I want to this in pixel's scope. If there is an image with three colors red(FF0000), green(00FF00) and yellow(FFFF00); in this case i want to change the color of red to blue, then the program should change all red pixels to blue(0000FF).
    I have to do this in an applet. Till date, i tried to implement the library function getRGB and setRGB but failed to do it completely.
    Any help (algorithm, approach, or code) will be appreciated.
    Thanks

    Use the class RGBImageFilter. The API documentation has an example of use.
    http://java.sun.com/j2se/1.5.0/docs/api/java/awt/image/RGBImageFilter.html

  • How to create a selection or mask from a Selective Color layer

    Hi. I was wondering if it is possible to get a selection/mask out of a Selective Color Layer.
    For instance lets say I have a complicated photo and I put a Selective Color layer on.  I then pick Red and start adjusting. I can see the effect and how it changes the red and how it falls off in the photo. Is it at all possible to create a selection or a mask based off of that effect? 
    Thank you

    You can try this.  Once you get your selective color adjustment layer the way you like it, change it's blending mode to difference.  Add a B&W adjustment layer above that then a curves or levels adjustment layer above that.  Use the curves or levels adjustment layer to give the image more contrast by adjusting the top white values.  This will produce  an image that you can then make a selection from from the channel pallet.

Maybe you are looking for