Reputation: 21
So i am trying to change the look and feel of my java gui from nimbus to windows. Its works when i launch the program on netbeans but does not work when i build it and launch the jar file. I am using windows 10
my code:
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(MainFrm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(MainFrm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MainFrm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MainFrm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
MainFrm f = new MainFrm();
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
f.setVisible(true);
}
});
}
Thank you!
EDIT: my main project, where I had three forms. Where I changed only two to windows feel, I made all three to windows feel and it worked!. I guess this was the problem.
Upvotes: 0
Views: 518
Reputation: 21
My Project had three JFrames, Where I changed only two JFrame to windows look and feel, after changing all three JFrames to windows look and feel, the problem was fixed.
Upvotes: 2