Archived

This topic is now archived and is closed to further replies.

encom

[java] Look and feel

Recommended Posts

Hi I have 2 questions : - How to set windowsXP skin to my java app ? - I have some java progs on my computer, they uses java metalic theme, its ugly, i would like to force theme to use windows laf. how to do that, how to force every javaApp to use windows LAF, not default LAF (metal). thanks

Share this post


Link to post
Share on other sites
Well, you can only use Windows lnf on Windows, so I dont recommend it. But, you can make it so that, it takes the system default, thusly Windows uses win-lnf, and so forth,

http://java.sun.com/docs/books/tutorial/uiswing/misc/plaf.html

Share this post


Link to post
Share on other sites
Here is the part of the tutorial that ManiacMac is talking about:
quote:

Specifying the Look and Feel: swing.properties
Yet another way to specify the current look and feel is to use the swing.properties file to set the swing.defaultlaf property. This file is located in the lib directory of the Java release. For example, if you''re using the Java interpreter in javaHomeDirectory\bin, then the swing.properties file (if it exists) is in javaHomeDirectory\lib. Here is an example of the contents of a swing.properties file:
# Swing properties

swing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel




By setting the Windows look and feel, you may get the XP look. This file will only set the default look and feel. If someone programatically sets a look and feel, it will override whatever you have in this file.

Note that usually when you just double click on a java app, the place where java/javaw gets executed from is the JRE/bin so you will want to set the swing.properties file in the JRE/lib directory in this case.



First make it work,
then make it fast.

--Brian Kernighan

The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities. We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)

Do not interrupt your enemy when he is making a mistake. - Napolean Bonaparte

Share this post


Link to post
Share on other sites
I have tried it and it worked for me. You may not have it in the correct place. Run the following program and check the output:

public class TestApp {
public static void main(String args[]) {
System.out.println("java.home="+System.getProperty("java.home"));
}
}


On my machine I get:

java.home=C:\apps\JBuilder7\jdk1.3.1\jre

so I have to place the swing.properties file in:

java.home=C:\apps\JBuilder7\jdk1.3.1\jre\lib

Also make sure where you are running it from. If you run this inside your IDE, it may be different than the command line.

swing.properties is for setting user defaults that override the normal Java swing defaults. It will only exist if you create it.


First make it work,
then make it fast.

--Brian Kernighan

The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities. We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)

Do not interrupt your enemy when he is making a mistake. - Napolean Bonaparte

[edited by - CaptainJester on October 22, 2003 2:01:37 PM]

Share this post


Link to post
Share on other sites
Go into your control panel and open the Java Plugin control. Go to the advanced tab and in the Java Runtime Parameters area put:

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



First make it work,
then make it fast.

--Brian Kernighan

The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities. We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)

Do not interrupt your enemy when he is making a mistake. - Napolean Bonaparte

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Do you ALWAYS want it to look like windows even if you are running in say Linux? If you want it to always look like the system it is running on just do:

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

Share this post


Link to post
Share on other sites
I do not have linux on my pc, but thanks for the tip, it will be usefull. I use java app on both windows and macos x, the laf is so different, and i dont like the default java theme.

Share this post


Link to post
Share on other sites