You've already called initComponents
before changing the look at feel. This will install what ever is the currently installed look and feel into those components.
Without having to go and instruct each component to update its UI, you could simply swap the installation of the look and feel with the initComponents
method, for example...
try {
UIManager.setLookAndFeel ( "javax.swing.plaf.nimbus.NimbusLookAndFeel" );
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
initComponents();
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
Now, having said that. You really should have been within the context of the EDT before you called the auth
constructor and auth
shouldn't really be making decisions about the Look and Feel. What happens if you want to use this frame again with a different look and feel?
Instead could do something more like
public class main {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
UIManager.setLookAndFeel ( "javax.swing.plaf.nimbus.NimbusLookAndFeel" );
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
new auth();
}
});
}
}
public class auth extends JFrame {
public auth() {
initComponents();
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
}
You should also consider taking a look through Code Conventions for the Java Programming Language, it will make your code much easier to read ;)