MDP
MDP

Reputation: 4267

Different look and feel of java application from the look and feel of Operating System

I've been asked to modify a java desktop application (I've never worked on java desktop application).

I have been gaven the project that I opened with Netbeans 8.0.2. Something weird happens.

If I launch the app from Netbeans (after doing "clean and build") with right click on the project - > run I get this look and feel:

enter image description here

If I launch the app from command line with java -jar C:\Users\...\NetBeansProjects\Clean\appaName.jar I get this look and feel (that is the correct one, since it is the look and feel of my OS, windows 10):

enter image description here

As you can see from the pics below, on Netbeans the Runtime Platform and JRE seem to be correclty set.

enter image description here enter image description here Does anybody know why? Be patience, I've never worked on desktop aplication.

Thank you

Upvotes: 3

Views: 145

Answers (1)

Joop Eggen
Joop Eggen

Reputation: 109547

Initialize the look & feel to the System one. (Though I like "Nimbus" more.)

This should best be done in the beginning.

public static void main(String[] args) {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    ...
}

Look in the NetBeans generated code for a main; as look&feel code might well be generated too.

Upvotes: 3

Related Questions