cdx.scorebot.util.swing
Class GUIHelper

java.lang.Object
  extended by cdx.scorebot.util.swing.GUIHelper

public abstract class GUIHelper
extends java.lang.Object

Provides some functionality to help GUIs set defaults, etc.

Author:
David Underhill

Field Summary
static java.awt.Color DEFAULT_BG_COLOR
          default background color
static java.awt.Color DEFAULT_FG_COLOR
          default foreground color
static java.awt.Font DEFAULT_FONT
          default font
static java.awt.Font DEFAULT_FONT_BOLD
          default font bolded
static java.awt.Font DEFAULT_FONT_SMALL
          smaller font size version of the default font
 
Constructor Summary
GUIHelper()
           
 
Method Summary
static void addListenersToSubcomponents(FileMenuFrame f, java.util.Vector<BoundComponent> compons)
          Adds a listener to each component so that when it is saved the change variable in f is flagged as true
static int confirmDialog(java.lang.String title, java.lang.String msg, int type)
          Displays an input dialog box
static void displayError(java.lang.Exception e)
          Displays an error message from a thrown Excpetion
static void displayError(java.lang.String msg)
          Displays an error message
static void displayMessage(java.lang.String msg)
          Displays a message
static void displayMessage(java.lang.String title, java.lang.String msg)
          Displays a message
static int getColumnAtCaret(javax.swing.text.JTextComponent component)
           
static java.lang.String getInput(java.lang.String msg)
          Displays an input dialog box with no default value set
static java.lang.String getInput(java.lang.String msg, java.lang.String defaultValue)
          Displays an input dialog box
static int getLineAtCaret(javax.swing.text.JTextComponent component)
           
static java.util.Vector<BoundComponent> getSubcomponents(BoundComponent c)
          Gets all bound objects this component holds including itself
static void scrollToTopOnChange(javax.swing.text.JTextComponent txtCompon)
          Adds a listener to the specified JTextComponent so that whenever it is changed it will scroll to the top of its text area.
static void scrollToTopOnChangeExceptIfTyping(javax.swing.text.JTextComponent txtCompon)
          Adds a listener to the specified JTextComponent so that whenever it is changed it will scroll to the top of its text area (except if the change is due to a user typing).
static void setGUIDefaults()
          Sets the defaults for GUIs in this project - all components created *AFTER* this is called will be created with these defaults unless specifically overridden.
static void setUIBgColor(java.awt.Color color)
          Sets the default background color for all Swing componenets
static void setUIFont(javax.swing.plaf.FontUIResource f)
          Sets the default font for all Swing componenets
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BG_COLOR

public static final java.awt.Color DEFAULT_BG_COLOR
default background color


DEFAULT_FG_COLOR

public static final java.awt.Color DEFAULT_FG_COLOR
default foreground color


DEFAULT_FONT

public static final java.awt.Font DEFAULT_FONT
default font


DEFAULT_FONT_BOLD

public static final java.awt.Font DEFAULT_FONT_BOLD
default font bolded


DEFAULT_FONT_SMALL

public static final java.awt.Font DEFAULT_FONT_SMALL
smaller font size version of the default font

Constructor Detail

GUIHelper

public GUIHelper()
Method Detail

setGUIDefaults

public static void setGUIDefaults()
Sets the defaults for GUIs in this project - all components created *AFTER* this is called will be created with these defaults unless specifically overridden.


setUIFont

public static void setUIFont(javax.swing.plaf.FontUIResource f)
Sets the default font for all Swing componenets


setUIBgColor

public static void setUIBgColor(java.awt.Color color)
Sets the default background color for all Swing componenets


displayError

public static void displayError(java.lang.Exception e)
Displays an error message from a thrown Excpetion

Parameters:
e - the exception whose message will be shown in a JOptionPane MessageDialog box

displayError

public static void displayError(java.lang.String msg)
Displays an error message

Parameters:
msg - the message which will be shown in a JOptionPane MessageDialog box

getInput

public static java.lang.String getInput(java.lang.String msg)
Displays an input dialog box with no default value set

Parameters:
msg - the message which will be shown in a JOptionPane InputDialog box
Returns:
value specified by the user

getInput

public static java.lang.String getInput(java.lang.String msg,
                                        java.lang.String defaultValue)
Displays an input dialog box

Parameters:
msg - the message which will be shown in a JOptionPane InputDialog box
defaultValue - the default value for the InputDialog box
Returns:
value specified by the user

confirmDialog

public static int confirmDialog(java.lang.String title,
                                java.lang.String msg,
                                int type)
Displays an input dialog box

Parameters:
title - the title of the message box
msg - the message which will be shown in a JOptionPane MessageDialog box
type - what kind of JOptionPane to use
Returns:
value chosen by the user

displayMessage

public static void displayMessage(java.lang.String msg)
Displays a message

Parameters:
msg - the message which will be shown in a JOptionPane MessageDialog box

displayMessage

public static void displayMessage(java.lang.String title,
                                  java.lang.String msg)
Displays a message

Parameters:
title - the title of the message box
msg - the message which will be shown in a JOptionPane MessageDialog box

getSubcomponents

public static java.util.Vector<BoundComponent> getSubcomponents(BoundComponent c)
Gets all bound objects this component holds including itself


addListenersToSubcomponents

public static void addListenersToSubcomponents(FileMenuFrame f,
                                               java.util.Vector<BoundComponent> compons)
Adds a listener to each component so that when it is saved the change variable in f is flagged as true


scrollToTopOnChange

public static void scrollToTopOnChange(javax.swing.text.JTextComponent txtCompon)
Adds a listener to the specified JTextComponent so that whenever it is changed it will scroll to the top of its text area.

Parameters:
txtCompon - the JTextComponent to add the listener to

scrollToTopOnChangeExceptIfTyping

public static void scrollToTopOnChangeExceptIfTyping(javax.swing.text.JTextComponent txtCompon)
Adds a listener to the specified JTextComponent so that whenever it is changed it will scroll to the top of its text area (except if the change is due to a user typing).

Parameters:
txtCompon - the JTextComponent to add the listener to

getColumnAtCaret

public static int getColumnAtCaret(javax.swing.text.JTextComponent component)

getLineAtCaret

public static int getLineAtCaret(javax.swing.text.JTextComponent component)