[java] Look and feel
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
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
http://java.sun.com/docs/books/tutorial/uiswing/misc/plaf.html
Here is the part of the tutorial that ManiacMac is talking about:
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
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
Hi,
swing.properties doesnt exist, i have created it, and placed it in the directory.
It doesnt work !
swing.properties doesnt exist, i have created it, and placed it in the directory.
It doesnt work !
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:
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]
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]
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
-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
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());
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement