0

I add several JButtons to JPanel, and setOpaque(false) for JPanel. When I move mouse onto the JButton, here appears a square under the button,and quickly disappears,which makes me feel awful.Does anyone know what is wrong? (sorry for my poor English)

  • I think that could be good qestion, please edit your question with a [SSCCE](http://sscce.org/) – mKorbel Apr 21 '12 at 18:02

1 Answers1

1

False is the default value for setOpaque as stated in the JComponent javadoc.

This is related to the effort it made to draw the components on the screen, when the property is set to true, then all the pixels of the component are drawn onscreen.

  • _Must_ be draw; see also the [opacity](http://java.sun.com/products/jfc/tsc/articles/painting/index.html#props) property and this [example](http://stackoverflow.com/a/3518047/230513). – trashgod Apr 21 '12 at 21:33
  • Thank you very much,and I think I understand it in some way.But there is still something confusing to me.could anyone tell me the difference between setOpaque(false) and paint a JPanel whith new Color(0,0,0,0) – Captain Jason Apr 22 '12 at 16:37