Problem : Change Nimbus Look and feel to Windows
Hello,
firstly sorry beacause i can't speak english a lot.
my problem is : my default look and feel now is NIMBUS , i want change it to Windows , so i add in main :
Java Code:
Code:
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
}
but when i do the exécution , i see the nimbus look not windows look.
Help me please.
Thanks.
Re: Problem : Change Nimbus Look and feel to Windows
Try the getSystemLookAndFeelClassName() method on UIManager.
Other than that, print the stack trace in the catch block in case youare getting an exception.
Re: Problem : Change Nimbus Look and feel to Windows
thanks for your answer , but i did't understand how i can't use getSystemLookAndFeelClassName()
Code:
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
UIManager.getSystemLookAndFeelClassName();
this is the right syntaxe??
want mean print tack in the catch ?
sorry because i'm begginer in Netbeans
THANKS
Re: Problem : Change Nimbus Look and feel to Windows
No, instead of the String you are passing in, use the result of getSystemLookAndFeelClassName().
It returns the system L&F (this is under the assumption that you are on a Windows system) classname as a String.
Re: Problem : Change Nimbus Look and feel to Windows
i write this code :
Code:
public void run() {
new New_User().setVisible(true);
String a = UIManager.getSystemLookAndFeelClassName();
System.out.println(a);}
the result is : com.sun.java.swing.plaf.windows.WindowsLookAndFeel .
but when i execute i see the nimbus designer :(think):
Re: Problem : Change Nimbus Look and feel to Windows
Have you changed the catch block to print the stack trace, in case there is an exception?
Re: Problem : Change Nimbus Look and feel to Windows
Code:
catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
ex.printStackTrace();
}
like this ?
Re: Problem : Change Nimbus Look and feel to Windows
Yes.
Otherwise you won't know if something has gone wrong.
Re: Problem : Change Nimbus Look and feel to Windows
same problem existe , when i execute i see the nimbus designer.
Code:
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(New_User.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
@SuppressWarnings("CallToThreadDumpStack")
public void run() {
try {
new New_User().setVisible(true);
String a = UIManager.getSystemLookAndFeelClassName();
} catch ( Exception ex) {
ex.printStackTrace();
}
} });}
Re: Problem : Change Nimbus Look and feel to Windows
There's nowhere in that code that you actually set the L&F to windows.
The only call up there to setLookAndFeel is only called on an L&F of "Nimbus".
Re: Problem : Change Nimbus Look and feel to Windows
Now it's ok , thanks for your help Tolls
Code:
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Windows".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(New_User.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
@SuppressWarnings("CallToThreadDumpStack")
public void run() {
new New_User().setVisible(true);
} });}