Transparent JButton

Buttons are specific in the context of transparency - in order to make them transparent, you do not call setOpaque(false), but instead you have to do three things - remove margins, remove border and prevent filling of the content area (this should have been actually controlled by the opaque property, but it is not). Here is a snippet that does everything:

Insets noInsets=new Insets(0,0,0,0);
// store the icon you want to display in imageIcon	
JButton buttonHelp=new JButton(imageIcon);	

Comments? Corrections? Contact us or Login to edit pages directly (registration is free and takes less than displaying a JLabel)
  howto/transparent_jbutton.txt · Last modified: 2006/04/09 18:26 by (ricky_clarkson)
Recent changes | RSS changes | Table of contents | News Archive | Terms And Conditions | Register