Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 562683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:34:50+00:00 2026-05-13T12:34:50+00:00

I have been going nuts trying to figure this out. I am trying to

  • 0

I have been going nuts trying to figure this out.

I am trying to elimenate a light blue background that appears in a JTabbedPane. I’ve tried everything and nothing seems to work.

Below is my code. If you run it, it will show the tab, when selected with a light blue background and a thing blue border at the top. I want to control this color. But how?

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.ColorUIResource;
public class Main extends JFrame {
  JTabbedPane tab=new JTabbedPane();
  public Main() {
     setSize(300,300);
     setTitle("Test Tab pane");
     tab.add("First",new myPanel("First"));
     tab.add("Second",new myPanel("Second"));
     tab.add("Third",new myPanel("Third"));
     tab.add("Fourth",new myPanel("Fourth"));
     tab.addChangeListener(new ChangeTab());
     getContentPane().add(tab,BorderLayout.CENTER);
     setVisible(true);
     for(int i=0;i<tab.getTabCount();i++){
          if(i != tab.getSelectedIndex())
            tab.setBackgroundAt(i,Color.orange);
            tab.setForeground(Color.BLACK);
     }
     tab.setOpaque(true);
     UIManager.put("TabbedPane.contentAreaColor ",ColorUIResource.GREEN);
     UIManager.put("TabbedPane.selected",ColorUIResource.GREEN);
     UIManager.put("TabbedPane.background",ColorUIResource.GREEN);
     UIManager.put("TabbedPane.shadow",ColorUIResource.GREEN);
  }

  public static void main(String[] args) {
    Main main = new Main();
  }

  class ChangeTab implements ChangeListener{
    public void stateChanged(ChangeEvent e){
        tab.validate();
        System.out.println(tab.getSelectedIndex());
        for(int i=0;i<tab.getTabCount();i++){
          if(i != tab.getSelectedIndex())
            tab.setBackgroundAt(i,Color.orange);
        }

    }
  }

  class myPanel extends JPanel{
    public myPanel(String str){
       add(new JLabel(str));
    }
  }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:34:50+00:00Added an answer on May 13, 2026 at 12:34 pm

    I used your example code, and what worked for me was moving the calls to UIManager.put() to a point where they would be executed before the JTabbedPane constructor was executed.

    public class Main extends JFrame {
        JTabbedPane tab;
    
        public Main() {
           // ... other stuff
           UIManager.put("TabbedPane.contentAreaColor ",ColorUIResource.GREEN);
           UIManager.put("TabbedPane.selected",ColorUIResource.GREEN);
           UIManager.put("TabbedPane.background",ColorUIResource.GREEN);
           UIManager.put("TabbedPane.shadow",ColorUIResource.GREEN);
    
           // now construct the tabbed pane
           tab=new JTabbedPane();
    
           // ... other stuff
     }
    

    There’s also some other properties available (for the Metal L&F, at least):

    UIManager.put("TabbedPane.borderColor", Color.RED);
    UIManager.put("TabbedPane.darkShadow", ColorUIResource.RED);
    UIManager.put("TabbedPane.light", ColorUIResource.RED);
    UIManager.put("TabbedPane.highlight", ColorUIResource.RED);
    UIManager.put("TabbedPane.focus", ColorUIResource.RED);
    UIManager.put("TabbedPane.unselectedBackground", ColorUIResource.RED);
    UIManager.put("TabbedPane.selectHighlight", ColorUIResource.RED);
    UIManager.put("TabbedPane.tabAreaBackground", ColorUIResource.RED);
    UIManager.put("TabbedPane.borderHightlightColor", ColorUIResource.RED);
    

    These let you control most of the colours in the tab area.

    I found with these settings there was still a very small blue-ish grey border around the content. I have searched for how to set this colour to no avail. The only solution I could find to get rid of this was:

    UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0));
    

    Which is a sub-optimal solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been going mad trying to figure out why my scripts weren't working,
I have been going crazy trying to figure out how to query a php
I have been going nuts with this.. I have gnupg installed on my CentOS
I have been going nuts over this issue for some time and I am
I have been asked to write an application that is going to act as
I've been going around in circles for hours with this. I have a UserProfile
Have been trying to encrypt an xml file to a string so that I
I have been going through the web about this exception. I found many articles
i have been going through some code and came across a statement that somehow
I have been going over rails scheduling tasks options and stumbled upon this piece

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.