Answer the question
In order to leave comments, you need to log in
How to change the theme in an arbitrary Java application?
Hello!
I am a complete layman in Java, just a user. But I want to figure it out once and for all: how to change and customize themes in Java applications? And is it possible to do this if the Java application itself does not provide for work with themes?
For example, I use the NetBeans IDE. In it, you can only customize the appearance of the code editing area. And you can’t customize the theme of the entire NetBeans - the color of the frames, the lines in the trees, the fonts - you can’t. And I, for example, need to change the color of all Java frames. How to do it?
The only thing I dug up is the use of the Java option --laf. For example, you can start NetBeans with this command:
./netbeans --laf com.sun.java.swing.plaf.gtk.GTKLookAndFeel
Answer the question
In order to leave comments, you need to log in
1. This simple code will display the lafs installed in the system
import javax.swing.UIManager;
public class Plaf {
public static void main(String[] args) {
UIManager.LookAndFeelInfo plaf[] = UIManager.getInstalledLookAndFeels();
for (int i = 0; i < plaf.length; i++)
System.out.println(plaf[i].getName() + "\n" + plaf[i].getClassName());
}
}
Metal
javax.swing.plaf.metal.MetalLookAndFeel
Nimbus
com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel
CDE/Motif
com.sun.java.swing.plaf.motif.MotifLookAndFeel
Mac OS X
com.apple.laf.AquaLookAndFeel
> 1. This simple code will display the lafs installed in the system. Did
n't understand what a normal user should do with this code? Do you need to compile? Doesn't the java program have a ready-made command or option?
.
> Although I heard that the Nimbus theme allows you to change the color scheme, but I have not tried it myself.
Hmm, so it allows or not? How? Google is silent. It seems that the exact science of computer science has turned into magic: it may be possible, but no one knows.
.
>About TinyLaf. You are lucky, the software is well documented, read the docs. The readme file described the process of connecting themes.
I did not find a description of the process of connecting themes to a third-party Java application there. It only describes how to connect to the code/assembly.
The person just asks how to change themes in any application :) You need to pass the swing.defaultlaf
parameter to the java program,
for example
java -jar -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel myApp.jar
If the theme comes from a third-party jar, then the jar must be in the classpath
In general, I do not see a serious problem in this ...
First of all, I will say that it makes no sense to receive a list of existing topics.
For each specific jdk version, they are always and everywhere the same.
For example, for jdk6, as already written above, they will be like this:
metal javax.swing.plaf.metal.MetalLookAndFeel Nimbus com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel CDE/Motif com.sun.java.swing.plaf.motif.MotifLookAndFeel
MacOS X com.apple.laf.AquaLookAndFeel
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question