tags:

views:

120

answers:

3

I have a main frame which has a menu bar and let user to change the font of all the texts in my program.I can just set the font for the main frame but how can i set that change for all my frames and dialogs???

+1  A: 

You can use some king of UIManager for recording the font to use, then a Change Font action to update the font in UIManager before updating your UI Swing Component.

This thread has much more on the different possible solution on this topic.

VonC
A: 

The Swing application framework has a powerful Resource manager that allows you to customise fonts and other appearance settings via properties files. It has lots of flexibility allowing you to specify these kinds of settings per dialog. An introduction to the resource manager can be found here.

Clinton
A: 

We simply do this to override the font for most of components we use.

    Font font = /*some font*/;

    UIManager.put("Button.font", font); //frozen
    UIManager.put("ToggleButton.font", font); //frozen
    UIManager.put("RadioButton.font", font); //frozen
    UIManager.put("CheckBox.font", font); //frozen
    UIManager.put("ColorChooser.font", font); //frozen
    UIManager.put("ComboBox.font", font); //frozen
    UIManager.put("Label.font", font); //frozen
    UIManager.put("List.font", font); //frozen
    UIManager.put("MenuBar.font", font); //frozen
    UIManager.put("MenuItem.font", font); //frozen
    UIManager.put("RadioButtonMenuItem.font", font); //frozen
    UIManager.put("CheckBoxMenuItem.font", font); //frozen
    UIManager.put("Menu.font", font); //frozen
    UIManager.put("PopupMenu.font", font); //frozen
    UIManager.put("OptionPane.font", font); //frozen
    UIManager.put("Panel.font", font); //frozen
    UIManager.put("ProgressBar.font", font); //frozen
    UIManager.put("ScrollPane.font", font); //frozen
    UIManager.put("Viewport.font", font); //frozen
    UIManager.put("TabbedPane.font", font); //frozen
    UIManager.put("Table.font", font); //frozen
    UIManager.put("TableHeader.font", font); //frozen
    UIManager.put("TextField.font", font); //frozen
    UIManager.put("PasswordField.font", font); //frozen
    UIManager.put("TextArea.font", font); //frozen
    UIManager.put("TextPane.font", font); //frozen
    UIManager.put("EditorPane.font", font); //frozen
    UIManager.put("TitledBorder.font", font); //frozen
    UIManager.put("ToolBar.font", font); //frozen
    UIManager.put("ToolTip.font", font); //frozen
    UIManager.put("Tree.font", font); //frozen
    UIManager.put("OptionPane.messsageFont", font); // frozen
    UIManager.put("OptionPane.buttonFont", font); //frozen
Neil Wightman