I want to change the default look and feel of all the jframe forms I'll create from here on out instead of having to manually edit every look and feel code of every jframe I create from 'Nimbus' to 'Windows'.
So what I want to happen is that from when I startup Netbeans to when I create a new Jframe, the code for the look and feel of that Jframe I just created will automatically be set to "Windows" rather than "Nimbus".
I want the look and feel code to look like this right after I click 'New > Jframe form':
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Windows".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
}
Note: I am not trying to theme Netbeans itself, I just want the Jframe that I create to have the windows look and feel by default so I don't have to go through the source tab and change Nimbus to Windows for every Jframe I create.
First of all take a look to this topic: The Use of Multiple JFrames, Good/Bad Practice?
Note: I am not trying to theme Netbeans itself, I just want the Jframe that I create to have the windows look and feel by default so I don't have to go through the source tab and change Nimbus to Windows for every Jframe I create.
What you want to change is called template: every file you can create through the New File wizard has an associated template. Having said this NetBeans gives the developers the ability to update/create default templates. Go to Tools -> Templates and look for Swing GUI Forms -> JFrame
You have two options here:
I'd go with Option 2 just to keep the original template unmodified..
When you edit the template just modify this line (or watherever you want actually):
Finally to create a new "custom" JFrame
just find your template in Swing GUI Forms -> MyJFrameTemplate as shown below:
Reading @Misgevolution's comment below I think there's something to be clarified. This auto-generated main
method is there just for test purposes making developers be able to "run" top-level containers. A Java application only needs one main
class so this test-only main
methods should be deleted when you will deploy your application. As suggested in other answers the L&F should be established only once at the start-up, not in every top-level container.