Swing JCheckbox: Focus with customized icons

I've used


to set custom icons for my JCheckbox. But now, if the focus moves to one of the checkboxes, there is no border shown around them or anything else, which tells that the checkbox has focus.

Does anyone know, how to give some feedback when a customized checkbox has focus?



Your problem definitely depends on Look and Feel (L&F) that you are using in your application (if you don't setup one - i guess you are using MetalLookAndFeel?).

Anyway, there might be a lot of solutions:

  1. Check that your JCheckBox is actually focusable and focus painted. Be aware that some L&F might switch off focus painting - check checkBox.setFocusPainted() method.

  2. If you are not satisfied with default focus painting - you might want to create your own CheckBoxUI that paints a better focus indicator. That requires some basic knowledge in UIs creation though.

  3. If you want to paint focus indication straight on the check icon itself you can create your own Icon-based implementation that paints it together with current check state. I have posted a custom Icon example in other topic about state-dependant icon if you want to see a real example.

There might be other solutions but they depends on the L&F you are using...


I want to create an index for an specific sql call in which I join two tables and I don't know how to insert the outer column. This is what I currently have: <changeSet id="1234" author="name" &...

I am trying to create a splash screen that displays a gif animation. The thing about my Splash screen I want to actually make it appear after the main() function returns (Main() just creates a login ...

I am using ant to make a build system for our android project which has two build targets, Dev and Release. This involves replacing the default -package-resources target with my own one in my build....

I need to convert some string date to another format string date String current = "Tue Apr 16 10:59:11 EDT 2019"; I want to get result date String in format ISO-8601 in accordance with the pattern - ...