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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:39:11+00:00 2026-05-14T15:39:11+00:00

I use JButtons in my application. They need to have different colors. First I

  • 0

I use JButtons in my application. They need to have different colors. First I used that btn.setBackground(col);. It works on my computer and on another computer my button just gray (not red, as it’s supposed to be).

Trying to solve this problem I decided to use images. I do it in the following way: tmp = new JButton(newIcon);

Again, it works fine on my computer and on another computer I see just gray buttons.

Does anybody have any ideas what can be the reason of the problem and how it can be solved? I heard it can be related to “look-and-feel of the native system”. But I do not know what it means and what should I do if it is the case? Can anybody pleas, help me with that?

  • 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-14T15:39:11+00:00Added an answer on May 14, 2026 at 3:39 pm

    Swing has the concept of pluggable look and feels. Some of those look and feels mimic the look of native components from Windows, GTK+, etc. Even on Windows there are two separate look and feels – Classic and Vista I think. Maybe you’re using different OSes on your two systems and an GUI designer that sets the look and feels automatically. Most don’t however – the default look and feel Metal(before Java 1.6.10) and Nimbus look the same on every OS.

       // build the look and feel section
        final LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
        List<String> lookAndFeelNames = new ArrayList<String>();
        lookAndFeelNames.add("System");
    
        for (LookAndFeelInfo lookAndFeelInfo : lookAndFeelInfos) {
            if (!lookAndFeelInfo.getName().equals("CDE/Motif")) {
                lookAndFeelNames.add(lookAndFeelInfo.getName());
            }
        }
    
      if (selectedLookAndFeel.equals("System")) {
                        try {
                            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                        } catch (ClassNotFoundException ex) {
                            java.util.logging.Logger.getLogger(SpellbookFrame.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (InstantiationException ex) {
                            java.util.logging.Logger.getLogger(SpellbookFrame.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (IllegalAccessException ex) {
                            java.util.logging.Logger.getLogger(SpellbookFrame.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (UnsupportedLookAndFeelException ex) {
                            java.util.logging.Logger.getLogger(SpellbookFrame.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    } else {
                        for (LookAndFeelInfo lookAndFeelInfo : lookAndFeelInfos) {
                            if (lookAndFeelInfo.getName().equals(selectedLookAndFeel)) {
                                try {
                                    UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
                                } catch (ClassNotFoundException e1) {
                                    e1.printStackTrace();
                                } catch (InstantiationException e1) {
                                    e1.printStackTrace();
                                } catch (IllegalAccessException e1) {
                                    e1.printStackTrace();
                                } catch (UnsupportedLookAndFeelException e1) {
                                    e1.printStackTrace();
                                }
                            }
                        }
                    }
    
                    SwingUtilities.updateComponentTreeUI(tabbedPane);
                    SwingUtilities.updateComponentTreeUI(parent);
    

    The first part of the code build a list of the available look and feel names and the second acts upon one of them being selected. But since you want always to use the same laf you can use something like:

    UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dynamic application that need to create a window interface with checkbox.
In my Java application I have to custom-paint a control and for that I
I want to set the background color of JButton. For that I use setBackground()
I have a GUI in java swing with a JTable and JButtons that implements
I have a JPanel that uses a FlowLayout and contains many JButtons. The buttons
I have two JPanels. In the first one I have 3 JButtons and the
I have a Swing application that deals with date and time, so a lot
I use outputPanel.setLayout(new BoxLayout(outputPanel, BoxLayout.Y_AXIS)); and then I add elements (for example JLabels, JButtons)
I need to position a JLabel over some JButtons, vertically, like a game menu.
Let me start by saying that I have been reading the drag'n drop tutorial

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.