Results 1 to 11 of 11
  1. #1
    Ridha is offline Member
    Join Date
    Jan 2013
    Posts
    28
    Rep Power
    0

    Default 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:

    Java 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.
    Last edited by Ridha; 01-30-2013 at 12:22 PM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default 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.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Ridha is offline Member
    Join Date
    Jan 2013
    Posts
    28
    Rep Power
    0

    Default Re: Problem : Change Nimbus Look and feel to Windows

    thanks for your answer , but i did't understand how i can't use getSystemLookAndFeelClassName()
    Java 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

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default 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.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    Ridha is offline Member
    Join Date
    Jan 2013
    Posts
    28
    Rep Power
    0

    Default Re: Problem : Change Nimbus Look and feel to Windows

    i write this code :
    Java 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

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default 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?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    Ridha is offline Member
    Join Date
    Jan 2013
    Posts
    28
    Rep Power
    0

    Default Re: Problem : Change Nimbus Look and feel to Windows

    Java Code:
    catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
       ex.printStackTrace();
    }
    like this ?

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default Re: Problem : Change Nimbus Look and feel to Windows

    Yes.
    Otherwise you won't know if something has gone wrong.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    Ridha is offline Member
    Join Date
    Jan 2013
    Posts
    28
    Rep Power
    0

    Default Re: Problem : Change Nimbus Look and feel to Windows

    same problem existe , when i execute i see the nimbus designer.
    Java 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();
                 }
                } });}
    Last edited by Ridha; 01-31-2013 at 08:22 AM.

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default 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".
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  11. #11
    Ridha is offline Member
    Join Date
    Jan 2013
    Posts
    28
    Rep Power
    0

    Default Re: Problem : Change Nimbus Look and feel to Windows

    Now it's ok , thanks for your help Tolls
    Java 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);
                } });}
    Last edited by Ridha; 01-31-2013 at 08:30 AM.

Similar Threads

  1. How to work Nimbus Look & feel in java
    By justbeller in forum AWT / Swing
    Replies: 5
    Last Post: 01-18-2011, 01:08 PM
  2. How to work Nimbus Look & feel in java
    By justbeller in forum Java 2D
    Replies: 1
    Last Post: 01-18-2011, 06:59 AM
  3. table renderer problem in nimbus look and feel
    By Allgorythm in forum New To Java
    Replies: 0
    Last Post: 02-22-2010, 12:20 PM
  4. vista look and feel in windows 2000 using java
    By zion892 in forum New To Java
    Replies: 1
    Last Post: 11-23-2009, 07:30 AM
  5. Replies: 1
    Last Post: 01-16-2009, 10:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •