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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:12:32+00:00 2026-05-29T11:12:32+00:00

I have this tiny flag that I am using for an icon on the

  • 0

I have this tiny flag that I am using for an icon on the default JButton. But when I load it it keeps the white box that is around it which shows up on the JButton’s blue background (at least that’s the color for me). I was wondering how I remove this white color.

Tiny Flag

  • 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-29T11:12:33+00:00Added an answer on May 29, 2026 at 11:12 am

    Of course, Siddhartha Shankar provided the correct answer, and mKorbel suggested a good (lateral thinking) alternative, but I was compelled to post this simply because ‘we have the technology’. 😉

    TransparentIcon

    import java.awt.image.BufferedImage;
    import java.awt.*;
    import javax.swing.*;
    
    import java.net.URL;
    import javax.imageio.ImageIO;
    
    class TransparentIcon {
    
        public static void main(String[] args) throws Exception {
            URL url = new URL("https://i.stack.imgur.com/DD7gI.gif");
            final BufferedImage bi = ImageIO.read(url);
    
            final BufferedImage tr = new BufferedImage(
                bi.getWidth(),
                bi.getHeight(),
                BufferedImage.TYPE_INT_ARGB);
    
            Color cTrans = new Color(255,255,255,0);
    
            for (int x=0; x<bi.getWidth(); x++) {
                for (int y=0; y<bi.getHeight(); y++) {
                    Color c = new Color( bi.getRGB(x,y) );
                    Color cNew = (c.equals(Color.WHITE) ? cTrans : c);
                    tr.setRGB(x,y,cNew.getRGB());
                }
            }
    
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    JPanel p = new JPanel(new GridLayout(1,0,5,5));
                    p.add(new JButton(new ImageIcon(bi)));
                    p.add(new JButton(new ImageIcon(tr)));
    
                    JOptionPane.showMessageDialog(null, p);
                }
            });
        }
    }
    

    BTW – you can combine my suggestion with that of Siddhartha by using ImageIO.write(), using the image formed from these shenanigans.

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

Sidebar

Related Questions

I have a joomla project. In this the text editor is tiny mace. But
I have posted this to ServerFault, but the Node.js community seems tiny there, so
I have this tiny script for now that checks if any change is made
I have this tiny Qt project with a project file like this: TEMPLATE =
I have this code in jQuery, that I want to reimplement with the prototype
I have this string 'john smith~123 Street~Apt 4~New York~NY~12345' Using JavaScript, what is the
I have this RewriteRule that works too well :-) RewriteRule ^([^/]*)/$ /script.html?id=$1 [L] The
I have this working ok(ish) in my game at the moment, but i'm not
OK, I've been using sqlite3 as development successfully for this tiny rails 3.1 project,
I have this tiny little issue with the datagrid. In my grid I have

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.