Stephan van Hulst wrote:Are those the exceptions that are actually thrown, or is the compiler complaining that you're not handling them?
You can just do something like this in your main method:
Stephan van Hulst wrote:Yes. Technically it doesn't have to be at the very start of the application, but it must be before the AWT Toolkit is initialized, which happens as soon as you touch anything related to AWT or Swing.
Stephan van Hulst wrote:I think you're confused though. The cross-platform look-and-feel (Metal) is the one that Java uses by default. Going by the screenshot you posted, you're already using the cross-platform look-and-feel.
Instead, try using the system look-and-feel with UIManager.getSystemLookAndFeelClassName(). This will give your application a look-and-feel that is more native to the platform it is running on.
Carey Brown wrote:You are setting the alpha value in your Color to '0' which means 'transparent', I think you wanted '255' which would be 'opaque'.
Bod McLeon wrote:But surely if it was transparent, you would just see the gray frame beneath it? I wanted it to be transparent so I didn't have to specify an exact colour to match up with the background.
Stephan van Hulst wrote:
Bod McLeon wrote:But surely if it was transparent, you would just see the gray frame beneath it? I wanted it to be transparent so I didn't have to specify an exact colour to match up with the background.
No. JPanel.isOpaque() returns true by default. That means that the container that holds the panel assumes that the panel will completely paint all of its contents and so they will not paint whatever is 'underneath'. If you want to use transparency in your panel, you must first call setOpaque(false).
However, I think the real problem is that you are fighting the look-and-feel by using your own custom colors, borders, and maybe even layout manager. Instead of fighting it, rely on the look-and-feel to get it right.
Can you show us your code so we might give you some advice on how to continue?
Bod McLeon wrote:Also, I needed a quick and dirty GUI so I used Eclipse's Windows Builder hence why there is a lot of repeated, messy and probably totally stupid code.. but hey, it works ¯\_(ツ)_/¯.
Carey Brown wrote:If you must match the desktop color you can get it with AWT's Robot.getPixelColor(x,y), then use the color with alpha set to 255.
Stephan van Hulst wrote:
Bod McLeon wrote:Also, I needed a quick and dirty GUI so I used Eclipse's Windows Builder hence why there is a lot of repeated, messy and probably totally stupid code.. but hey, it works ¯\_(ツ)_/¯.
Does it though? :P
Anyway, your code confirms my suspicions. You're setting custom colors and borders all over the place. As you've seen, this doesn't work well when running the application on a different platform.
A better option is to get rid of all this custom skinning and find a custom cross-platform look-and-feel that you like. It seems like you're going for a slick dark theme; a simple Google search for "Java dark look and feel" yielded FlatLaf, which looks promising.
Stephan van Hulst wrote:I don't think Windows has the concept of a disabled progress bar. What does it mean for a progress bar to be disabled?
Again, you're fighting the native look and feel. Windows users are not used to disabled progress bars. Why force it on them? Can't you convey your information in a more meaningful way?