Package net.sf.freecol.client.gui.panel
Class Utility
- java.lang.Object
-
- net.sf.freecol.client.gui.panel.Utility
-
public final class Utility extends java.lang.ObjectStatic utilities for panels and dialogs.
-
-
Field Summary
Fields Modifier and Type Field Description static javax.swing.border.BorderBEVEL_BORDERUseful static borders.private static javax.swing.border.BorderCELLBORDERprivate static javax.swing.border.BorderCOLOR_CELL_BORDERprivate static intDEFAULT_TEXT_COLUMNSHow many columns (em-widths) to use in the text area.private static javax.swing.border.BorderDIALOG_BORDERstatic java.awt.InsetsEMPTY_MARGINThe margin to use for a link button.static javax.swing.border.BorderETCHED_BORDERstatic java.lang.StringFONTSPEC_SUBTITLEFont specification for panel subtitles.static java.lang.StringFONTSPEC_TITLEFont specification for panel titles.private static javax.swing.border.BorderLEFTCELLBORDERstatic javax.swing.border.BorderPROGRESS_BORDERprivate static javax.swing.border.BorderSIMPLE_LINE_BORDERprivate static javax.swing.text.StyleContextSTYLE_CONTEXTA style context to use for panels and dialogs.private static javax.swing.border.BorderTOPCELLBORDERprivate static javax.swing.border.BorderTOPLEFTCELLBORDER
-
Constructor Summary
Constructors Constructor Description Utility()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static javax.swing.border.BorderblankBorder(int top, int left, int bottom, int right)Get a border consisting of empty space.static javax.swing.JComboBox<java.net.InetAddress>createServerInetAddressBox()Returns a combo box for selecting a possible server address.private static javax.swing.JTextAreacreateTextArea(java.lang.String text)Creates a text area with standard settings suitable for use in FreeCol panels, without setting its size.static java.awt.ColorgetBorderColor()Get the standard border color.static javax.swing.border.BordergetCellBorder()static javax.swing.border.BordergetColorCellBorder()static javax.swing.JTextAreagetDefaultTextArea(java.lang.String text)Gets a text area with standard settings suitable for use in FreeCol panels.static javax.swing.JTextAreagetDefaultTextArea(java.lang.String text, int columns)Gets a text area with standard settings suitable for use in FreeCol panels, which adapt their size based on what they contain.static javax.swing.JTextAreagetDefaultTextArea(java.lang.String text, java.awt.Dimension size)Gets a text area with standard settings suitable for use in FreeCol panels, which can not adapt their size.static javax.swing.JTextPanegetDefaultTextPane()Get aJTextPanewith default styles.static javax.swing.JTextPanegetDefaultTextPane(java.lang.String text)Get aJTextPanewith default styles and given text.static javax.swing.border.BordergetDialogBorder()static javax.swing.border.BordergetLeftCellBorder()static javax.swing.JButtongetLinkButton(java.lang.String text, javax.swing.Icon icon, java.lang.String action)Return a button suitable for linking to another panel (e.g.static java.awt.ColorgetLinkColor()Get the color to use for links.static javax.swing.JButtongetMessageButton(java.lang.String key, java.lang.String val, Player player, FreeColGameObject source)Make a suitable link button for a given key.private static java.util.List<java.net.InetAddress>getPossibleServerAddresses()static javax.swing.border.BordergetProductionBorder()static javax.swing.border.BordergetSimpleLineBorder()static javax.swing.border.BordergetTopCellBorder()static javax.swing.border.BordergetTopLeftCellBorder()static javax.swing.border.BordergetTrivialLineBorder()static java.awt.ColorgetWarningColor()Get the color to use for things the player probably should not do.static voidinitStyleContext(java.awt.Font font)static voidlocalizeBorder(javax.swing.JComponent component, StringTemplate template)Localize the a titled border.static javax.swing.border.TitledBorderlocalizedBorder(java.lang.String key)Get a titled border with Messages.message(key) as text.static javax.swing.border.TitledBorderlocalizedBorder(java.lang.String key, java.awt.Color color)Get a titled border with Messages.message(key) as text and a given colored line border.static javax.swing.border.TitledBorderlocalizedBorder(Named named)Get a titled border for a Named object.static javax.swing.border.TitledBorderlocalizedBorder(Named named, java.awt.Color color)Get a titled border for a Named object and a given colored line border.static FreeColButtonlocalizedButton(java.lang.String key)Get a JButton with Messages.message(key) as text.static javax.swing.JButtonlocalizedButton(StringTemplate template)Get a JButton with Messages.message(template) as text.static javax.swing.JCheckBoxMenuItemlocalizedCheckBoxMenuItem(java.lang.String key, boolean value)Get a JCheckBoxMenuItem with Messages.message(key) as text.static javax.swing.JLabellocalizedHeader(java.lang.String key, java.lang.String fontSpec)Gets a default header for panels containing a localized message.static javax.swing.JLabellocalizedHeaderLabel(java.lang.String key, int alignment, java.lang.String fontSpec)Gets a label containing a localized message using the header font.static javax.swing.JLabellocalizedHeaderLabel(Named named, java.lang.String fontSpec)static javax.swing.JLabellocalizedHeaderLabel(StringTemplate template, int alignment, java.lang.String fontSpec)static javax.swing.JLabellocalizedLabel(java.lang.String key)Get a JLabel with Messages.message(key) as text.static javax.swing.JLabellocalizedLabel(FreeColSpecObjectType fcgot)Get a JLabel for a FreeColSpecObjectType.static javax.swing.JLabellocalizedLabel(StringTemplate template)Get a JLabel with Messages.message(template) as text.static javax.swing.JLabellocalizedLabel(StringTemplate template, javax.swing.Icon icon, int alignment)Get a JLabel with Messages.message(template) as text.static javax.swing.JMenulocalizedMenu(java.lang.String key)Get a JMenu with Messages.message(key) as text.static javax.swing.JMenulocalizedMenu(StringTemplate template)Get a JMenu with Messages.message(template) as text.static javax.swing.JMenuItemlocalizedMenuItem(java.lang.String key)Get a JMenuItem with Messages.message(key) as text.static javax.swing.JMenuItemlocalizedMenuItem(java.lang.String key, javax.swing.Icon icon)Get a JMenuItem with Messages.message(key) as text.static javax.swing.JMenuItemlocalizedMenuItem(StringTemplate template)Get a JMenuItem with Messages.message(template) as text.static javax.swing.JMenuItemlocalizedMenuItem(StringTemplate template, javax.swing.Icon icon)Get a JMenuItem with Messages.message(template) as text.static javax.swing.JRadioButtonMenuItemlocalizedRadioButtonMenuItem(StringTemplate template, boolean value)Get a JRadioButtonMenuItem with Messages.message(template) as text.static javax.swing.JTextArealocalizedTextArea(java.lang.String key)Get a text area containing a localized message.static javax.swing.JTextArealocalizedTextArea(java.lang.String key, int columns)Get a text area containing a localized message.static javax.swing.JTextArealocalizedTextArea(StringTemplate template)Get a text area containing a localized message.static javax.swing.JTextArealocalizedTextArea(StringTemplate template, int columns)Get a text area containing a localized message.static javax.swing.JPanellocalizedTextPanel(StringTemplate template, javax.swing.ImageIcon icon)Get a panel with a localized message and icon.static voidlocalizeToolTip(javax.swing.JComponent comp, java.lang.String key)Localize the tool tip message for a JComponent.static voidlocalizeToolTip(javax.swing.JComponent comp, StringTemplate template)Localize the tool tip message for a JComponent.static voidpadBorder(javax.swing.JComponent component, int top, int left, int bottom, int right)
-
-
-
Field Detail
-
BEVEL_BORDER
public static final javax.swing.border.Border BEVEL_BORDER
Useful static borders.
-
ETCHED_BORDER
public static final javax.swing.border.Border ETCHED_BORDER
-
PROGRESS_BORDER
public static final javax.swing.border.Border PROGRESS_BORDER
-
COLOR_CELL_BORDER
private static javax.swing.border.Border COLOR_CELL_BORDER
-
DIALOG_BORDER
private static javax.swing.border.Border DIALOG_BORDER
-
SIMPLE_LINE_BORDER
private static javax.swing.border.Border SIMPLE_LINE_BORDER
-
TOPCELLBORDER
private static javax.swing.border.Border TOPCELLBORDER
-
CELLBORDER
private static javax.swing.border.Border CELLBORDER
-
LEFTCELLBORDER
private static javax.swing.border.Border LEFTCELLBORDER
-
TOPLEFTCELLBORDER
private static javax.swing.border.Border TOPLEFTCELLBORDER
-
DEFAULT_TEXT_COLUMNS
private static final int DEFAULT_TEXT_COLUMNS
How many columns (em-widths) to use in the text area.- See Also:
- Constant Field Values
-
EMPTY_MARGIN
public static final java.awt.Insets EMPTY_MARGIN
The margin to use for a link button.
-
STYLE_CONTEXT
private static javax.swing.text.StyleContext STYLE_CONTEXT
A style context to use for panels and dialogs.
-
FONTSPEC_TITLE
public static java.lang.String FONTSPEC_TITLE
Font specification for panel titles.
-
FONTSPEC_SUBTITLE
public static java.lang.String FONTSPEC_SUBTITLE
Font specification for panel subtitles.
-
-
Method Detail
-
initStyleContext
public static void initStyleContext(java.awt.Font font)
-
getBorderColor
public static java.awt.Color getBorderColor()
Get the standard border color.- Returns:
- The border
Color.
-
getLinkColor
public static java.awt.Color getLinkColor()
Get the color to use for links.- Returns:
- The link
Color.
-
getWarningColor
public static java.awt.Color getWarningColor()
Get the color to use for things the player probably should not do.- Returns:
- The warning
Color.
-
getColorCellBorder
public static javax.swing.border.Border getColorCellBorder()
-
getDialogBorder
public static javax.swing.border.Border getDialogBorder()
-
getProductionBorder
public static javax.swing.border.Border getProductionBorder()
-
getSimpleLineBorder
public static javax.swing.border.Border getSimpleLineBorder()
-
getTrivialLineBorder
public static javax.swing.border.Border getTrivialLineBorder()
-
getTopCellBorder
public static javax.swing.border.Border getTopCellBorder()
-
getCellBorder
public static javax.swing.border.Border getCellBorder()
-
getLeftCellBorder
public static javax.swing.border.Border getLeftCellBorder()
-
getTopLeftCellBorder
public static javax.swing.border.Border getTopLeftCellBorder()
-
getLinkButton
public static javax.swing.JButton getLinkButton(java.lang.String text, javax.swing.Icon icon, java.lang.String action)Return a button suitable for linking to another panel (e.g. ColopediaPanel).- Parameters:
text- aStringvalueicon- anIconvalueaction- aStringvalue- Returns:
- a
JButtonvalue
-
getMessageButton
public static javax.swing.JButton getMessageButton(java.lang.String key, java.lang.String val, Player player, FreeColGameObject source)Make a suitable link button for a given key. Colonies and Europe-like objects are obvious, locations and units are dependent on the message source. TODO: Are there more useful possibilities?- Parameters:
key- The message key to make a link for.val- The text for the link.player- ThePlayerto make a link for.source- The message sourceFreeColGameObject.- Returns:
- A
JButtonfor the link, or null if no good choice found.
-
createTextArea
private static javax.swing.JTextArea createTextArea(java.lang.String text)
Creates a text area with standard settings suitable for use in FreeCol panels, without setting its size.- Parameters:
text- The text to display in the text area.- Returns:
- A suitable text area.
-
getDefaultTextArea
public static javax.swing.JTextArea getDefaultTextArea(java.lang.String text)
Gets a text area with standard settings suitable for use in FreeCol panels.- Parameters:
text- The text to display in the text area.- Returns:
- A suitable text area.
-
getDefaultTextArea
public static javax.swing.JTextArea getDefaultTextArea(java.lang.String text, int columns)Gets a text area with standard settings suitable for use in FreeCol panels, which adapt their size based on what they contain.- Parameters:
text- The text to display in the text area.columns- The em-width number of columns to display the text in.- Returns:
- A suitable text area.
-
getDefaultTextArea
public static javax.swing.JTextArea getDefaultTextArea(java.lang.String text, java.awt.Dimension size)Gets a text area with standard settings suitable for use in FreeCol panels, which can not adapt their size.- Parameters:
text- The text to display in the text area.size- The size of the area to display the text in.- Returns:
- A suitable text area.
-
getDefaultTextPane
public static javax.swing.JTextPane getDefaultTextPane()
Get aJTextPanewith default styles.- Returns:
- The default
JTextPaneto use.
-
getDefaultTextPane
public static javax.swing.JTextPane getDefaultTextPane(java.lang.String text)
Get aJTextPanewith default styles and given text.- Parameters:
text- The text to display.- Returns:
- A suitable
JTextPane.
-
blankBorder
public static javax.swing.border.Border blankBorder(int top, int left, int bottom, int right)Get a border consisting of empty space.- Parameters:
top- Top spacing.left- left spacing.bottom- Bottom spacing.right- Right spacing.- Returns:
- A blank border.
-
padBorder
public static void padBorder(javax.swing.JComponent component, int top, int left, int bottom, int right)
-
createServerInetAddressBox
public static javax.swing.JComboBox<java.net.InetAddress> createServerInetAddressBox()
Returns a combo box for selecting a possible server address.- Returns:
- The combo box.
-
getPossibleServerAddresses
private static java.util.List<java.net.InetAddress> getPossibleServerAddresses()
-
localizeBorder
public static void localizeBorder(javax.swing.JComponent component, StringTemplate template)Localize the a titled border.- Parameters:
component- TheJComponentto localize.template- TheStringTemplateto use.
-
localizedBorder
public static javax.swing.border.TitledBorder localizedBorder(Named named)
Get a titled border for a Named object.- Parameters:
named- TheNamedto use.- Returns:
- The
TitledBorder.
-
localizedBorder
public static javax.swing.border.TitledBorder localizedBorder(Named named, java.awt.Color color)
Get a titled border for a Named object and a given colored line border.- Parameters:
named- TheNamedto use.color- The color to use.- Returns:
- The
TitledBorder.
-
localizedBorder
public static javax.swing.border.TitledBorder localizedBorder(java.lang.String key)
Get a titled border with Messages.message(key) as text.- Parameters:
key- The key to use.- Returns:
- The
TitledBorder.
-
localizedBorder
public static javax.swing.border.TitledBorder localizedBorder(java.lang.String key, java.awt.Color color)Get a titled border with Messages.message(key) as text and a given colored line border.- Parameters:
key- The key to use.color- The color to use.- Returns:
- The
TitledBorder.
-
localizedButton
public static FreeColButton localizedButton(java.lang.String key)
Get a JButton with Messages.message(key) as text.- Parameters:
key- The key to use.- Returns:
- The
JButton.
-
localizedButton
public static javax.swing.JButton localizedButton(StringTemplate template)
Get a JButton with Messages.message(template) as text.- Parameters:
template- TheStringTemplateto use.- Returns:
- The
JButton.
-
localizedCheckBoxMenuItem
public static javax.swing.JCheckBoxMenuItem localizedCheckBoxMenuItem(java.lang.String key, boolean value)Get a JCheckBoxMenuItem with Messages.message(key) as text.- Parameters:
key- The key to use.value- The initial value.- Returns:
- The
JCheckBoxMenuItem.
-
localizedHeader
public static javax.swing.JLabel localizedHeader(java.lang.String key, java.lang.String fontSpec)Gets a default header for panels containing a localized message.- Parameters:
key- The message key to use.fontSpec- A font-specification for the font to use.- Returns:
- A suitable
JLabel.
-
localizedHeaderLabel
public static javax.swing.JLabel localizedHeaderLabel(java.lang.String key, int alignment, java.lang.String fontSpec)Gets a label containing a localized message using the header font.- Parameters:
key- The message key to use.alignment- The alignment.fontSpec- A font specification.- Returns:
- A suitable
JLabel.
-
localizedHeaderLabel
public static javax.swing.JLabel localizedHeaderLabel(StringTemplate template, int alignment, java.lang.String fontSpec)
-
localizedHeaderLabel
public static javax.swing.JLabel localizedHeaderLabel(Named named, java.lang.String fontSpec)
-
localizedLabel
public static javax.swing.JLabel localizedLabel(FreeColSpecObjectType fcgot)
Get a JLabel for a FreeColSpecObjectType.- Parameters:
fcgot- TheFreeColSpecObjectTypeto use.- Returns:
- The
JLabel.
-
localizedLabel
public static javax.swing.JLabel localizedLabel(java.lang.String key)
Get a JLabel with Messages.message(key) as text.- Parameters:
key- The key to use.- Returns:
- The
JLabel.
-
localizedLabel
public static javax.swing.JLabel localizedLabel(StringTemplate template)
Get a JLabel with Messages.message(template) as text.- Parameters:
template- TheStringTemplateto use.- Returns:
- The
JLabel.
-
localizedLabel
public static javax.swing.JLabel localizedLabel(StringTemplate template, javax.swing.Icon icon, int alignment)
Get a JLabel with Messages.message(template) as text.- Parameters:
template- TheStringTemplateto use.icon- The icon to use.alignment- The alignment.- Returns:
- The
JLabel.
-
localizedMenu
public static javax.swing.JMenu localizedMenu(java.lang.String key)
Get a JMenu with Messages.message(key) as text.- Parameters:
key- The key to use.- Returns:
- The
JMenu.
-
localizedMenu
public static javax.swing.JMenu localizedMenu(StringTemplate template)
Get a JMenu with Messages.message(template) as text.- Parameters:
template- TheStringTemplateto use.- Returns:
- The
JMenu.
-
localizedMenuItem
public static javax.swing.JMenuItem localizedMenuItem(java.lang.String key)
Get a JMenuItem with Messages.message(key) as text.- Parameters:
key- The key to use.- Returns:
- The
JMenuItem.
-
localizedMenuItem
public static javax.swing.JMenuItem localizedMenuItem(java.lang.String key, javax.swing.Icon icon)Get a JMenuItem with Messages.message(key) as text.- Parameters:
key- The key to use.icon- The icon to use.- Returns:
- The
JMenuItem.
-
localizedMenuItem
public static javax.swing.JMenuItem localizedMenuItem(StringTemplate template)
Get a JMenuItem with Messages.message(template) as text.- Parameters:
template- TheStringTemplateto use.- Returns:
- The
JMenuItem.
-
localizedMenuItem
public static javax.swing.JMenuItem localizedMenuItem(StringTemplate template, javax.swing.Icon icon)
Get a JMenuItem with Messages.message(template) as text.- Parameters:
template- TheStringTemplateto use.icon- The icon to use.- Returns:
- The
JMenuItem.
-
localizedRadioButtonMenuItem
public static javax.swing.JRadioButtonMenuItem localizedRadioButtonMenuItem(StringTemplate template, boolean value)
Get a JRadioButtonMenuItem with Messages.message(template) as text.- Parameters:
template- TheStringTemplateto generate the text.value- The initial value.- Returns:
- The
JRadioButtonMenuItem.
-
localizedTextArea
public static javax.swing.JTextArea localizedTextArea(java.lang.String key)
Get a text area containing a localized message.- Parameters:
key- The message key.- Returns:
- A suitable
JTextArea.
-
localizedTextArea
public static javax.swing.JTextArea localizedTextArea(java.lang.String key, int columns)Get a text area containing a localized message.- Parameters:
key- The message key.columns- The em-width number of columns to display the text in.- Returns:
- A suitable
JTextArea.
-
localizedTextArea
public static javax.swing.JTextArea localizedTextArea(StringTemplate template)
Get a text area containing a localized message.- Parameters:
template- TheStringTemplateto use.- Returns:
- A suitable
JTextArea.
-
localizedTextArea
public static javax.swing.JTextArea localizedTextArea(StringTemplate template, int columns)
Get a text area containing a localized message.- Parameters:
template- TheStringTemplateto use.columns- The em-width number of columns to display the text in.- Returns:
- A suitable
JTextArea.
-
localizedTextPanel
public static javax.swing.JPanel localizedTextPanel(StringTemplate template, javax.swing.ImageIcon icon)
Get a panel with a localized message and icon.- Parameters:
template- TheStringTemplateto use.icon- AnImageIconto use.- Returns:
- The resulting
JPanel.
-
localizeToolTip
public static void localizeToolTip(javax.swing.JComponent comp, java.lang.String key)Localize the tool tip message for a JComponent.- Parameters:
comp- TheJComponentto localize.key- The key to use.
-
localizeToolTip
public static void localizeToolTip(javax.swing.JComponent comp, StringTemplate template)Localize the tool tip message for a JComponent.- Parameters:
comp- TheJComponentto localize.template- TheStringTemplateto use.
-
-