java - JButton's border don't go away even when set the Border to EmptyBorder -


i designing gui using eclipse on mac, , want make jbutton display icon set. looks fine on mac os, when export jar file, , rut in on windows os, jbutton looks this:

enter image description here

the borders emptyborder.

what did wrong? how can make square @ go away?

to answer question correctly, sscce required. anyway, believe you'll want invoke setcontentareafilled(false) on jbutton instances. should remove "square".

however, important note exact behavior of calling function varies on component-by-component , 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


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -