1

I am using Java Swing to make an application and I've added JButton components to it.

I set the buttons to not be focusable and not paint focus, like so:

button.setFocusable(false);
button.setFocusPainted(false);

However, there is a blue "flash" whenever I click a button which I want to get rid of. I am on a Mac and using the cross platform UI. How can I remove this flash when clicking?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Brad Kyle
  • 27
  • 6
  • 1
    Those indications are there for good reason. What's your compelling reason for removing them? BTW - I see you have yet to accept an answer. Please start doing so. – Andrew Thompson Mar 23 '20 at 03:18
  • 1
    @AndrewThompson I plan to have a different method of indication and the "flash" just serves as a bad looking distraction. – Brad Kyle Mar 23 '20 at 04:36
  • *"I plan to have a different method of indication"* Cool. Thanks for clarifying. There are a number of ways to achieve that. Out of pure curiosity.. what is that method of indication? **More generally:** For better help sooner, [edit] to add a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). – Andrew Thompson Mar 23 '20 at 04:46
  • *"There are a number of ways to achieve that."* E.G. [This example](https://stackoverflow.com/a/10862262/418556) puts a red border around the 'pressed' icon. Also, does that example give you the tips you need to get rid of the 'flash'? – Andrew Thompson Mar 23 '20 at 04:54
  • @AndrewThompson I'll add an example when I'm back home, thanks for the advice. The other method of indication will be an animation hovering over the JButton because we're making games for a Java class project. – Brad Kyle Mar 23 '20 at 05:17
  • `jButton1.setContentAreaFilled(false);` – DevilsHnd - 退職した Mar 23 '20 at 07:40
  • *ill be an animation hovering over the JButton because we're making game* Maybe you can just use the setRolloverIcon(…) method. – camickr Mar 23 '20 at 16:35

0 Answers0