Java Swing ignores attributes set to the specific components

40 views Asked by At

I'm working on an IntelliJ plugin using Gradle and the Java Swing library. I've realized that some of the attributes I'm setting are getting ignored like the Background or the color of the Border. For example:

textField.setBackgroundColor(Colors.customColor);
panel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Colors.anotherColor));

I've tried moving those declarations to the Event Dispatch Thread using SwingUtilities.invokeLater(), but it doesn't seem to make any difference. I've also tried calling the repaint() method afterwards, but it also doesn't help.

The other aspect of the problem is the light or dark mode of the IDE. At switching the mode, the colors get overridden. And since they are referenced to the components, I assumed it is enough to only call the repaint() method afterwards. Unfortunately, it is not. It seems that there are some concurrency issues, but I cannot find anything on the internet about it.

0

There are 0 answers