Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to change the fonts in all menus and buttons?  RSS feed

 
Ahmet Aksoy
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to be able to change the fonts of all menu items, and the buttons in runtime.
How can I do? (The same font will be applied to all of the components).
Ahmet Aksoy
 
Ahmet Aksoy
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found the solution as follows:

void changeFonts(Font sf){
UIManager.put("Button.font",sf);
UIManager.put("ToggleButton.font",sf);
UIManager.put("RadioButton.font",sf);
UIManager.put("CheckBox.font",sf);
UIManager.put("ColorChooser.font",sf);
UIManager.put("ToggleButton.font",sf);
UIManager.put("ComboBox.font",sf);
UIManager.put("ComboBoxItem.font",sf);
UIManager.put("InternalFrame.titleFont",sf);
UIManager.put("Label.font",sf);
UIManager.put("List.font",sf);
UIManager.put("MenuBar.font",sf);
UIManager.put("Menu.font",sf);
UIManager.put("MenuItem.font",sf);
UIManager.put("RadioButtonMenuItem.font",sf);
UIManager.put("CheckBoxMenuItem.font",sf);
UIManager.put("PopupMenu.font",sf);
UIManager.put("OptionPane.font",sf);
UIManager.put("Panel.font",sf);
UIManager.put("ProgressBar.font",sf);
UIManager.put("ScrollPane.font",sf);
UIManager.put("Viewport",sf);
UIManager.put("TabbedPane.font",sf);
UIManager.put("TableHeader.font",sf);
UIManager.put("TextField.font",sf);
UIManager.put("PasswordFiled.font",sf);
UIManager.put("TextArea.font",sf);
UIManager.put("TextPane.font",sf);
UIManager.put("EditorPane.font",sf);
UIManager.put("TitledBorder.font",sf);
UIManager.put("ToolBar.font",sf);
UIManager.put("ToolTip.font",sf);
UIManager.put("Tree.font",sf);

config.applyLookAndFeel(config.LOOK_AND_FEEL);
}
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Swing forum...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!