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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:01:58+00:00 2026-05-26T00:01:58+00:00

I am designing a GUI using Eclipse on Mac, and I want to make

  • 0

I am designing a GUI using Eclipse on Mac, and I want to make the JButton to display only the Icon I set. It looks fine on Mac OS, but when I export it to a jar file, and rut in on Windows OS, the JButton looks like this:

enter image description here

The borders are all EmptyBorder.

What did I do wrong? How can I make the square at the back go away?

  • 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-26T00:01:58+00:00Added an answer on May 26, 2026 at 12:01 am

    To answer this question correctly, an SSCCE will most likely be required. Anyway, I believe that you’ll want to invoke setContentAreaFilled(false) on your JButton instances. That should effectively remove the “square”.

    However, it is important to note that the exact behavior of calling this function varies on a component-by-component and L&F-by-L&F basis.


    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    
    public final class JButtonDemo {
        public static void main(String[] args){
            SwingUtilities.invokeLater(new Runnable(){
                @Override
                public void run() {
                    createAndShowGUI();             
                }
            });
        }
    
        private static void createAndShowGUI(){
            final JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.add(new JIconButton());
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    
        private static final class JIconButton extends JButton{
            private static final long serialVersionUID = 7274140930080397481L;
    
            public JIconButton(){
                super(UIManager.getIcon("OptionPane.informationIcon"));
                setContentAreaFilled(false);
                setFocusPainted(false);
                setBorder(BorderFactory.createEmptyBorder());
            }
        }
    }
    

    enter image description here

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

Sidebar

Related Questions

I'm designing a really simple GUI but without any luck. Basically the outer layout
I'm designing a Java application using SWT. I have some tables which will display
I'm currently designing my first ever GUI for Windows. I'm using MFC and Visual
i'm using C++ managed 2010 for designing a GUI in a form.h file. The
I am currently designing a GUI to control some software. I am using fltk,
I'm designing a gui based on org.eclipse.swt.widgets.TabItem . Is there a way to show
Designing a new system from scratch. I'll be using the STL to store lists
Designing forms has always been fun, but getting them to send email on the
When designing LINQ classes using the LINQ to SQL designer I've sometimes needed to
I'm designing GUI (graphical user interface) system for a game engine (C++). Idea is

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.