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

  • Home
  • SEARCH
  • 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 8320517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:40:35+00:00 2026-06-08T22:40:35+00:00

i’m developing a little GUI application with Java using Netbeans Editor. I’ve put in

  • 0

i’m developing a little GUI application with Java using Netbeans Editor.
I’ve put in a JFrame a simple Progress Bar.
I’m developing the project with JDK7

I want to change the background Color from default Orange to a personal one. I’ve already tried all the properties for the color changing but when i run the program the color still the same.

I’ve already tried using
ProgressBar1.setBackground(new java.awt.Color(0, 204, 255));

and

UIManager.put("ProgressBar.background", Color.YELLOW);
UIManager.put("ProgressBar.foreground", Color.MAGENTA);
UIManager.put("ProgressBar.selectionBackground", Color.red);
UIManager.put("ProgressBar.selectionForeground", Color.green);

Same result….. The background is always orange

Here the code of my test project

public class Frame extends javax.swing.JFrame
{

    public Frame()
    {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jProgressBar1 = new javax.swing.JProgressBar();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jProgressBar1.setBackground(new java.awt.Color(0, 204, 255));
        jProgressBar1.setValue(75);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jProgressBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>

    public static void main(String args[])
    {
        try
        {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Frame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Frame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Frame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Frame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Frame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify
    private javax.swing.JProgressBar jProgressBar1;
    // End of variables declaration
}

and this is the result when you launch the code
progress bar
(source: uploadscreenshot.com)

Orange color….

EDIT
With the following code

UIManager.getLookAndFeelDefaults().put("ProgressBar[Enabled].backgroundPainter", new FillPainter(Color.MAGENTA)); 
UIManager.getLookAndFeelDefaults().put("ProgressBar[Disabled].backgroundPainter", new FillPainter(Color.MAGENTA)); 
UIManager.getLookAndFeelDefaults().put("ProgressBar[Enabled+Indeterminate].progressPadding", new FillPainter(Color.ORANGE)); 
UIManager.getLookAndFeelDefaults().put("ProgressBar[Enabled].foregroundPainter", new FillPainter(Color.GREEN)); 
UIManager.getLookAndFeelDefaults().put("ProgressBar[Disabled].foregroundPainter", new FillPainter(Color.GREEN)); 
UIManager.getLookAndFeelDefaults().put("ProgressBar[Enabled+Finished].foregroundPainter", new FillPainter(Color.GREEN)); 
UIManager.getLookAndFeelDefaults().put("ProgressBar[Disabled+Finished].foregroundPainter", new FillPainter(Color.GREEN)); 
UIManager.getLookAndFeelDefaults().put("ProgressBar[Disabled+Indeterminate].foregroundPainter", new FillPainter(Color.GREEN)); 
UIManager.getLookAndFeelDefaults().put("ProgressBar[Enabled+Indeterminate].foregroundPainter", new FillPainter(Color.GREEN)); `

after this line

javax.swing.UIManager.setLookAndFeel(info.getClassName());

I’ve successfully change the color of background.
But now the color is “plain”, there is no gradient like the orange color.

progress bar
(source: uploadscreenshot.com)

Is it possible to change color with the same effect of the original color?

  • 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-08T22:40:38+00:00Added an answer on June 8, 2026 at 10:40 pm
    1. maybe (Color and Font) issue talking about Nimbus Look and Feel

    2. have to check this thread

    3. value for

    ProgressBar[Disabled+Finished].foregroundPainter
    ProgressBar[Disabled+Indeterminate].foregroundPainter
    ProgressBar[Disabled].backgroundPainter
    ProgressBar[Disabled].foregroundPainter
    ProgressBar[Enabled+Finished].foregroundPainter
    ProgressBar[Enabled+Indeterminate].foregroundPainter
    ProgressBar[Enabled+Indeterminate].progressPadding
    ProgressBar[Enabled].backgroundPainter
    ProgressBar[Enabled].foregroundPainter

    .
    4. maybe easiest for you will be to change nimbusOrange from the top of Nimbus defaults, but this change is everywhere,

    funny output to the GUI with changed Control Color, for example

    UIManager.getLookAndFeelDefaults().put(“nimbusOrange”, (new Color(127, 255, 191)));

    .
    5. for example

    enter image description here

    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.EventQueue;
    import java.awt.Graphics2D;
    import javax.swing.*;
    
    public class MyPopupWithNimbus {
    
        public MyPopupWithNimbus() {
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(200, 200);
            JPanel panel = new JPanel(new BorderLayout());
            panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
            JList list = new JList();
            panel.add(list);
            JProgressBar progress = new JProgressBar();
            progress.setStringPainted(true);
            progress.setString("60 pct");
            progress.setValue(60);
            frame.add(panel);
            frame.add(progress, BorderLayout.SOUTH);
            JPopupMenu menu = new JPopupMenu();
            menu.add(new JMenuItem("A"));
            menu.add(new JMenuItem("B"));
            menu.add(new JMenuItem("C"));
            JMenu jmenu = new JMenu("D");
            jmenu.add(new JMenuItem("E"));
            menu.add(jmenu);
            frame.setVisible(true);
            menu.show(frame, 50, 50);
        }
    
        public static void main(String[] args) {
    
            try {
                for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(laf.getName())) {
                        UIManager.setLookAndFeel(laf.getClassName());
                        UIManager.getLookAndFeelDefaults().put("nimbusOrange", (new Color(127, 255, 191)));
                        UIManager.getLookAndFeelDefaults().put("PopupMenu[Enabled].backgroundPainter",
                                new FillPainter(Color.ORANGE));
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            EventQueue.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    MyPopupWithNimbus aa = new MyPopupWithNimbus();
                }
            });
        }
    }
    
    class FillPainter implements Painter<JComponent> {
    
        private final Color color;
    
        FillPainter(Color c) {
            color = c;
        }
    
        @Override
        public void paint(Graphics2D g, JComponent object, int width, int height) {
            g.setColor(color);
            g.fillRect(0, 0, width - 1, height - 1);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.