The Source for Java Technology Collaboration
User: Password:



Alexander Potochkin

Alexander Potochkin's Blog

Swing team reveals their secrets !

Posted by alexfromsun on April 01, 2006 at 12:00 AM | Comments (14)

Everybody knows that Swing and AWT behaviour can be changed with command line properties,
for example you may set the desirable Look and Feel with help of the following command line property

swing.defaultlaf

see here for more info, e.g. the following command:

java -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel <YourApp>

allows you to have the Windows LaF to be set for your application by default;
or let's take the

java.awt.headless

which switches your application to a mysterious headless mode (don't try it at home, by the way)

But the same time it is not widely known that Swing has much more exciting undocumented properties, and even Swing team members are not aware of the complete list of them.

You might spend a lot of time implementing a feature, and after that bump into the property wich can solve the problem straight away

Remember the famous grayrect improvement which is implemented for Mustang?

It turned out that the the only thing you should do to solve the problem is set the

swing.grayrect.color

from Gray (it was the default value) to Transparent, with:

java -Dswing.grayrect.color=Transparent

your will never see the gray rect and what is the most interesting that it works even for java 1.1 !

if you don't like the grayrect to be transparent, you can fill it with you favourite color,
for instance

swing.grayrect.color=Violet turns the boring grayrect to a beautiful Violet !

Here the list of additional properties, with valid values which are devided with | symbol, the default value marked with asterisk:

swing.runtwiceasfast=true*|false

Make the Swing two times faster

swing.completeleremoveawt=true|false*

This one is in progress, AWT team doubts that we really need it

swing.bugsnumber=ALOT | MEDIUM | AFEW* | NONE

NONE value is not completely tested yet, so I don't recommend trying it out

java2d.speedofpainting=LOW | MEDIUM | FAST* | UNIMAGINABLE

If you set UNIMAGINABLE value for this property the Swing components will be painted so fast that it will hardly be possible to notice them

I am absolutely sure that there are more properties to be added in this list,
so if you know any ones which are not mentioned here, please let me know !


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Could a list like this be included with the Javadoc for the JDK?

    leouser

    Posted by: leouser on March 31, 2006 at 08:23 AM


  • alexfromsun wrote:

    > swing.bugsnumber=ALOT | MEDIUM | AFEW* | NONE

    > NONE value is not completely tested yet, so I don't recommend trying it out


    This is true, but of course our goal is always to switch the default to NONE as soon as possible. As with all of these undocumented properties, they are subject to change between versions.

    Posted by: shan_man on March 31, 2006 at 08:38 AM

  • Very funny!

    I have always wanted the gray rect to be a different color ;-)

    Posted by: rabbe on March 31, 2006 at 08:38 AM

  • Why didn't you document the swing.uselessram property? I use that one all the time.

    Just a note, setting swing.bugsnumber causes many of my workarounds to fail.

    Posted by: rabbe on March 31, 2006 at 08:42 AM

  • A much lesser known way to remove the Gray rect is to hold down Alt-Shift while the application is loading. Be aware though, because it will also mean that the new Multi-Threaded Direct3D mode for Dual Core CPUs is enabled (Windows only).

    Posted by: mgrev on March 31, 2006 at 09:56 AM

  • mgrev: Actually pressing Alt+Shift switches locale for the input. On my computer it turns the keyboard into French and as a result the application does not start since it goes on strike.

    Posted by: gfx on March 31, 2006 at 10:12 AM

  • I think it's the difference between "Alt-Shift" and "Alt+Shift". And I think the Multi-Threaded Direct3D mode for Dual Core CPUs also works for 64-bit Gentoo if you have the latest TransGaming Cedega installed.

    Posted by: tjpalmer on March 31, 2006 at 10:49 AM

  • While we are talking short cuts. Did you know that on windows you can take the gray rect fix one step further. If you press Alt+F4 the whole application window will turn transparent. To make it visible again just double click the application icon.

    Posted by: mgrev on March 31, 2006 at 11:19 AM

  • A company I used to work for had a configuration option "FlickerFree", which I believe defaulted to off. Some manager then insisted it be changed to a more positive name. (I should point out that it was not necessary because of any defects in the company's software.)

    Posted by: tackline on March 31, 2006 at 05:29 PM

  • i think alex is making us april-fool ;-)

    Posted by: hithacker on April 01, 2006 at 06:59 AM

  • @hihacker: no I don't think so, I tried the swing twice as fast property and it did make things go twice as fast. I was quite surprised. :D

    leouser

    Posted by: leouser on April 01, 2006 at 11:15 AM

  • After applying a couple of the settings:
    swing.bugsnumber=NONE
    swing.runtwiceasfast=true

    I noticed that my application actually ran twice as fast and that it had no more bugs. Thanks for the post, this has helped a lot!

    Posted by: sanduskyca on April 27, 2006 at 04:42 PM

  • Hi leouser
    Hi sanduskyca

    I am happy that secret properties are not a secret any more :-)

    Hi mgrev
    Your observation that [ pressing Alt+F4 makes the whole application window transparent ] is very cool !

    Thanks
    alexp

    Posted by: alexfromsun on April 28, 2006 at 01:58 AM

  • All these options are pretty good and very much useful.I tried all and to my surprise all are working well.

    Any option like swing.autobugfix4me=TRUE*|FALSE is available?D

    Posted by: jobinesh on September 18, 2006 at 01:09 AM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds