According to that answer in jGuru you can define the source of each resource, only of the components you are interested in - in case the label and the button.
UIManager.put("Button.font", /* font of your liking */);
UIManager.put("ToggleButton.font", /* font of your liking */);
UIManager.put("RadioButton.font", /* font of your liking */);
UIManager.put("CheckBox.font", /* font of your liking */);
UIManager.put("ColorChooser.font", /* font of your liking */);
UIManager.put("ComboBox.font", /* font of your liking */);
UIManager.put("Label.font", /* font of your liking */);
UIManager.put("List.font", /* font of your liking */);
UIManager.put("MenuBar.font", /* font of your liking */);
UIManager.put("MenuItem.font", /* font of your liking */);
UIManager.put("RadioButtonMenuItem.font", /* font of your liking */);
UIManager.put("CheckBoxMenuItem.font", /* font of your liking */);
UIManager.put("Menu.font", /* font of your liking */);
UIManager.put("PopupMenu.font", /* font of your liking */);
UIManager.put("OptionPane.font", /* font of your liking */);
UIManager.put("Panel.font", /* font of your liking */);
UIManager.put("ProgressBar.font", /* font of your liking */);
UIManager.put("ScrollPane.font", /* font of your liking */);
UIManager.put("Viewport.font", /* font of your liking */);
UIManager.put("TabbedPane.font", /* font of your liking */);
UIManager.put("Table.font", /* font of your liking */);
UIManager.put("TableHeader.font", /* font of your liking */);
UIManager.put("TextField.font", /* font of your liking */);
UIManager.put("PasswordField.font", /* font of your liking */);
UIManager.put("TextArea.font", /* font of your liking */);
UIManager.put("TextPane.font", /* font of your liking */);
UIManager.put("EditorPane.font", /* font of your liking */);
UIManager.put("TitledBorder.font", /* font of your liking */);
UIManager.put("ToolBar.font", /* font of your liking */);
UIManager.put("ToolTip.font", /* font of your liking */);
UIManager.put("Tree.font", /* font of your liking */);
Or you can change the value of the objects in UIManager.getDefault().keys()
that are instances of FontUIResource
.
Important: This solution will depend on the Look and Feel of its application.
If you’re using the Nimbus, for example, the changes did not take effect.
public void setDefaultFont(Font defaultFont){
FontUIResource font = new FontUIResource(defaultFont);
Enumeration uiManagerKeys = UIManager.getDefaults().keys();
while(uiManagerKeys.hasMoreElements()){
Object key = uiManagerKeys.nextElement(),
value = UIManager.get(key);
if(null != value && value instanceof FontUIResource)
UIManager.put(key, font);
}
}
And use it like this:
Font font = new Font("Arial", Font.PLAIN, 25);
setDefaultFont(font);
Result in Windows 10:
You can create a template form and then just inherit the properties of this template form in your new forms.
– gato
For example, I want to put an Arial pattern and 14 size with bold. I would like ALL the labels and buttons I create to start with this pattern, because it’s fucked up to have to keep changing every single time you create a new label or button, for example.
– Conrado Saud
Your question implies that you would like to change the sources of the Netbeans IDE, not a Java application. If you are using the Netbeans GUI builder, then you are working with Swing. I edited the question, can you reverse if the edition does not present improvements.
– Renan Gomes