Package jmri.util.swing
Class FontComboUtil
java.lang.Object
jmri.util.swing.FontComboUtil
This utility class provides methods that initialise and return a JComboBox
containing a specific sub-set of fonts installed on a users system.
This file is part of JMRI.
Optionally, the JComboBox can be displayed with a preview of the specific font in the drop-down list itself.
This file is part of JMRI.
JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.
JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- Since:
- 2.13.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturn a JComboBox containing all available font families.getFontCombo(boolean previewOnly) Return a JComboBox containing all available font families.getFontCombo(int which) Return a JComboBox containing the specified set of font families.getFontCombo(int which, boolean previewOnly) Return a JComboBox containing the specified set of font families.getFontCombo(int which, int size) Return a JComboBox containing the specified set of font families.getFontCombo(int which, int size, boolean previewOnly) Return a JComboBox containing the specified set of font families.getFonts(int which) static booleanisReady()Determine if usable; starts the process of making it so if neededstatic booleanisSymbolFont(String font) Determine if the specified font family is a symbol fontstatic voidMethod to initialise the font lists on first access
-
Field Details
-
ALL
- See Also:
-
MONOSPACED
- See Also:
-
PROPORTIONAL
- See Also:
-
CHARACTER
- See Also:
-
SYMBOL
- See Also:
-
-
Constructor Details
-
FontComboUtil
public FontComboUtil()
-
-
Method Details
-
getFonts
-
isSymbolFont
Determine if the specified font family is a symbol font- Parameters:
font- the font family to check- Returns:
- true if a symbol font; false if not
-
prepareFontLists
Method to initialise the font lists on first access -
getFontCombo
Return a JComboBox containing all available font families. The list is displayed using a preview of the font at the standard size.- Returns:
- List of all available font families as a
JComboBox - See Also:
-
getFontCombo
Return a JComboBox containing all available font families. The list is displayed using a preview of the font at the standard size and with the option of the name alongside in the regular dialog font.- Parameters:
previewOnly- set to True to show only a preview in the list; False to show both name and preview- Returns:
- List of specified font families as a
JComboBox - See Also:
-
getFontCombo
Return a JComboBox containing the specified set of font families. The list is displayed using a preview of the font at the standard size.- Parameters:
which- the set of fonts to return;MONOSPACED,PROPORTIONAL,CHARACTER,SYMBOLorALL- Returns:
- List of specified font families as a
JComboBox - See Also:
-
getFontCombo
Return a JComboBox containing the specified set of font families. The list is displayed using a preview of the font at the standard size and with the option of the name alongside in the regular dialog font.- Parameters:
which- the set of fonts to return;MONOSPACED,PROPORTIONAL,CHARACTER,SYMBOLorALLpreviewOnly- set to True to show only a preview in the list; False to show both name and preview- Returns:
- List of specified font families as a
JComboBox - See Also:
-
getFontCombo
Return a JComboBox containing the specified set of font families. The list is displayed using a preview of the font at the specified point size.- Parameters:
which- the set of fonts to return;MONOSPACED,PROPORTIONAL,CHARACTER,SYMBOLorALLsize- point size for the preview- Returns:
- List of specified font families as a
JComboBox - See Also:
-
getFontCombo
Return a JComboBox containing the specified set of font families. The list is displayed using a preview of the font at the specified point size and with the option of the name alongside in the regular dialog font.Available font sets:
- Monospaced fonts
MONOSPACED - Proportional fonts
PROPORTIONAL - Character fonts
CHARACTER - Symbol fonts
SYMBOL - All available fonts
ALL
Typical usage:
JComboBox fontFamily = FontComboUtil.getFontCombo(FontComboUtil.MONOSPACED); fontFamily.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myObject.setFontFamily((String) ((JComboBox)e.getSource()).getSelectedItem()); } }); fontFamily.setSelectedItem(myObject.getFontFamily());- Parameters:
which- the set of fonts to return;MONOSPACED,PROPORTIONAL,CHARACTER,SYMBOLorALLsize- point size for the previewpreviewOnly- true to show only a preview in the list; false to show both name and preview- Returns:
- List of specified font families as a
JComboBox
- Monospaced fonts
-
isReady
Determine if usable; starts the process of making it so if needed- Returns:
- true if ready for use; false otherwise
-