Problems with Look and Feel
I have a pop up window with a toolbar containing buttons. This works fine on Windows 10 and Debian linux, however on Feren Linux some of the buttons have a black background. I have tried setting the background to white but this is ignored. I suspect that the Look and Feel of MD is overriding this. Is this possible?
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Sean Reilly on 31 Jan, 2021 09:43 PM
Hi Mike,
The look and feel is responsible for setting colours in components, so that'd be the place to look. Which theme is in use?
Thanks,
Sean
--
Sean Reilly
Developer, The Infinite Kind
https://infinitekind.com
2 Posted by Stuart Beesley ... on 31 Jan, 2021 09:56 PM
.
3 Posted by Mike Bray (Quot... on 01 Feb, 2021 06:31 AM
I have saved the L&F, set it to the cross platform one and then reinstated it around the pop-up window. This does the trick.
4 Posted by Stuart Beesley ... on 01 Feb, 2021 06:34 AM
Would you mind sharing the snippet of code that you used..?
Support Staff 5 Posted by Sean Reilly on 01 Feb, 2021 07:23 AM
I've been doing a lot of work around L&F lately, so it'd be best if you didn't change the L&F. Instead could you override
public void updateUI()
in the button and use it to set the color in your popup, making sure to callsuper.updateUI()
at the beginning of your override?--
Sean Reilly
Developer, The Infinite Kind
https://infinitekind.com
6 Posted by Mike Bray (Quot... on 01 Feb, 2021 08:20 AM
OK, I will give it a go. Just as an aside the enclosed image below the problem we are trying to overcome:
By changing the L&F I achieved the second image.
Stuart, in this is my code: The window containing the buttons is MYJRViewer
Support Staff 7 Posted by Sean Reilly on 01 Feb, 2021 08:39 AM
Ok, on most platforms by default we use getSystemLookAndFeelClassName which I think might call through to GTK on linux, if available. I'll change it to use getCrossPlatformLookAndFeelClassName, except in Dark Mode which uses the open source Darcula L&F.
On the mac you'll want it to use the system look and feel and using the cross platform L&F will make it look really bad.
So please don't change the L&F at all, and let me know if the updateUI() override isn't working for you.
Thanks,
Sean
8 Posted by Mike Bray (Quot... on 01 Feb, 2021 08:45 AM
OK, I will let you know what happens
9 Posted by Mike Bray (Quot... on 01 Feb, 2021 04:26 PM
Hi Sean, subclassing the JButton and JToggleButton classes and setting the background in the updateUI method seems to have worked, we are getting the same results on Windows 10, Debian, Feren and Mint Linux and Big Sur macOs. I have removed the changes to Look and Feel.
10 Posted by Stuart Beesley ... on 01 Feb, 2021 04:44 PM
Hi Mike, could you share the code you used to do this please? Thx
11 Posted by Mike Bray (Quot... on 03 Feb, 2021 09:25 AM
Hi Stuart there isn't much to see, all I do is subclass the buttons and use them in my code. For JasperReports I have had to create own versions of JasperViewer, JRViewer and JRViewerToolbar so I can change the tool bar to use my subclassed buttons.
in JRViewerToolbar
Mike Bray (Quote Loader Author) closed this discussion on 03 Feb, 2021 09:26 AM.
Stuart Beesley (Mr Toolbox) re-opened this discussion on 06 Feb, 2021 04:51 PM
12 Posted by Stuart Beesley ... on 06 Feb, 2021 04:51 PM
FYI - I've just realised that I had a different problem, and also that I've seen and fixed your problem (setting the background) before (in Python) without overriding the button... I had to call theButton.setOpaque(True) before setBackground(color) would work....
System closed this discussion on 08 May, 2021 05:00 PM.