How to adjust JFrame border thickness in Java

2.7k views Asked by At

I'm using Vista, my old Java app ran on Win XP has thin borders, about 2 pixels thick, but now on Vista, the borders deafults to thick lines, maybe 6,7 pixels thick, can I specify in Java how thick my JFrame borders should be ?

1

There are 1 answers

0
Ash On BEST ANSWER

By default borders are handled by the native windowing system. But in the JFrame API there is a method setDefaultLookAndFeelDecorated(boolean). It says that if set to true and if the current look and feel supports it, it will use the look and feel to draw the borders, title and buttons. I haven't ever tried this, since I don't know which look and feels support decoration. The first thing would be to find one that does, then set that via the UIManager or command-line -Ddefault.laf argument, and turn on look and feel decoration via the JFrame method.

If you use this option though, you'll probably get non-standard looking window decoration. Given the little bits of Vista eye candy (glow on hover over the buttons and the translucent title bar), are you sure you want to do that?

Another option is to use the JFrame.setUndecorated(boolean) method and handle rendering of borders, title bar, etc. yourself, but that's probably even more difficult.