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 8172737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:52:59+00:00 2026-06-06T21:52:59+00:00

I know this question has been answered before, but it’s just not working for

  • 0

I know this question has been answered before, but it’s just not working for me. I followed the instructions from here: How to change JProgressBar color?

import javax.swing.*;
import java.awt.*;

public class ProgressBarTest extends JFrame {

    public static void main(String args[]) {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        UIManager.put("ProgressBar.background", Color.orange);
        UIManager.put("ProgressBar.foreground", Color.black);
        UIManager.put("ProgressBar.selectionBackground", Color.red);
        UIManager.put("ProgressBar.selectionForeground", Color.green);
        JProgressBar progressBar = new JProgressBar(0,100);
        progressBar.setValue(50);
        f.add(progressBar, BorderLayout.PAGE_END);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setVisible(true);
    }

}

All I am getting is the same old colors.

AquaProgressBarUI

I’m using Mac OS X 10.7.3 and Java 1.6. I tried the CrossPlatformLookAndFeel and it works with the new colors. However I want this in the default look and feel. How can I do this?

  • 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-06-06T21:53:01+00:00Added an answer on June 6, 2026 at 9:53 pm

    To override Look & Feel defaults, make the change before constructing the GUI on the event dispatch thread, as shown below.

    On the com.apple.laf.AquaLookAndFeel, the progress bar’s UI delegate is an instance of com.apple.laf.AquaProgressBarUI. As you have found, it ignores many defaults in favor of the native component. If a novel color scheme is required, consider supplying your own UI delegate, as shown here.

    AquaProgressBarUI:

    AquaProgressBarUI

    CustomProgressUI:

    CustomProgressUI

    ProgressBar UI Defaults:

    ProgressBar.background: com.apple.laf.AquaNativeResources$CColorPaintUIResource[r=238,g=238,b=238]
    ProgressBar.border: javax.swing.plaf.BorderUIResource@47f08ed8
    ProgressBar.cellLength: 1
    ProgressBar.cellSpacing: 0
    ProgressBar.cycleTime: 3000
    ProgressBar.font: sun.swing.SwingLazyValue@6446d228
    ProgressBar.foreground: javax.swing.plaf.ColorUIResource[r=0,g=0,b=0]
    ProgressBar.horizontalSize: javax.swing.plaf.DimensionUIResource[width=146,height=12]
    ProgressBar.repaintInterval: 20
    ProgressBar.selectionBackground: javax.swing.plaf.ColorUIResource[r=255,g=255,b=255]
    ProgressBar.selectionForeground: javax.swing.plaf.ColorUIResource[r=0,g=0,b=0]
    ProgressBar.verticalSize: javax.swing.plaf.DimensionUIResource[width=12,height=146]
    ProgressBarUI: com.apple.laf.AquaProgressBarUI
    

    SSCCE:

    import java.awt.*;
    import javax.swing.*;
    
    public class ProgressBarTest extends JFrame {
    
        public static void main(String args[]) {
            UIManager.put("ProgressBar.repaintInterval", 100);
            UIManager.put("ProgressBar.border",
                BorderFactory.createLineBorder(Color.blue, 2));
            EventQueue.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    JFrame f = new JFrame();
                    f.setLayout(new GridLayout(0, 1, 5 , 5));
                    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    f.add(createBar());
                    f.add(createBar());
                    f.add(createBar());
                    f.pack();
                    f.setLocationRelativeTo(null);
                    f.setVisible(true);
                }
    
                private JProgressBar createBar() {
                    JProgressBar progressBar = new JProgressBar(0, 100);
                    progressBar.setValue(50);
                    return progressBar;
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this type of question has been asked and answered before but I
I know this question has been answered before in this thread , but I
This question has been asked before, but not answered. Is there a list anywhere
So this question has been asked before , but not answered in great detail.
I know a similar question has been answered before here , but I just
I know this question has been asked and answered before, but none of the
I know this question has been asked and answered before. But when I try
I know this question has been asked before, but non of the solutions solve
I know this question has been posted before... but I haven't found any answer
I know this question has been asked before, but I haven't been able to

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.