org.xnap.gui.util
Class GUIHelper

java.lang.Object
  extended by org.xnap.gui.util.GUIHelper

public class GUIHelper
extends java.lang.Object

Helps with gui related tasks. We can not have Preferences.java depend on java.awt.


Field Summary
static int POPUP_MENU_HEIGHT_INSET
          Kicker offset.
protected static Preferences prefs
           
 
Constructor Summary
GUIHelper()
           
 
Method Summary
static void bindEmacsKeysToTable(javax.swing.JTable jta)
          Adds some Emacs like keybindings to a table for moving between rows.
static boolean bindEnterKey(javax.swing.JComponent c, javax.swing.Action action)
          Adds a mapping between the enter key and action to the input map of c.
static boolean bindEnterKeyLocally(javax.swing.JComponent c, javax.swing.Action action)
          Does the same as bindEnterKey(JComponent, Action) but uses the default input map and not the window input map.
static boolean bindEscapeKey(javax.swing.JComponent c, javax.swing.Action action)
          Adds a mapping between the escape key and action to the input map of c.
static boolean bindKey(javax.swing.JComponent c, javax.swing.KeyStroke ks, javax.swing.Action action, boolean whenInFocusedWindow)
          Adds a mapping between ks and action to the input map of c.
static javax.swing.border.Border createDefaultBorder(java.lang.String title)
          Returns an etched default border.
static javax.swing.border.Border createEmptyBorder()
          Returns an empty border.
static javax.swing.border.Border createEmptyBorder(int inset)
          Returns an empty border.
static javax.swing.border.Border createEtchedBorder()
          Returns an empty border.
static javax.swing.JComponent createHeader(java.lang.String title)
          Creates and answers a label with separator; useful to separate paragraphs in a panel.
static javax.swing.border.Border createLoweredBorder()
           
static javax.swing.border.Border createRaisedBorder()
           
static javax.swing.JComponent createSeparator(java.lang.String title)
           
static javax.swing.border.Border createTitledBorder(java.lang.String title, int inset)
          Returns a titled border.
static void expandAllNodes(javax.swing.JTree jt)
           
static javax.swing.KeyStroke getMenuKeyStroke(int keyCode)
           
static void initialize()
           
static java.lang.String label(java.lang.String text)
          Wraps HTML tags around text so the maximum width is limited to a senseful value.
static void limitSize(javax.swing.JComponent c)
           
static void restrictWidth(javax.swing.JComponent jc)
           
static void scrollToEnd(javax.swing.text.JTextComponent jt)
           
static void setAccelerator(javax.swing.JMenuItem jmi, int keyCode)
           
static void setMnemonics(java.awt.Container c)
           
static void setMnemonics(java.awt.Container c, java.util.HashSet l)
           
static void setMnemonics(javax.swing.JTabbedPane pane)
           
static boolean shouldScroll(javax.swing.JScrollBar jsb)
          Returns true, if jsb is at the maximum value.
static void showFile(javax.swing.text.JTextComponent jta, java.lang.String filename, java.lang.String altText)
          Loads text from file and sets it to jta.
static void showPopupMenu(javax.swing.JPopupMenu jpm, java.awt.Component source, int x, int y)
           
static void showPopupMenu(javax.swing.JPopupMenu jpm, java.awt.Component source, int x, int y, int yOffset)
           
static java.lang.String tableRow(java.lang.String key, java.lang.String value)
          Formats key, value as a HTML table row, the key is highlighted as bold.
static java.lang.String tt(java.lang.String text)
          Wraps HTML tags around text so the maximum width is limited to a sensible value.
static java.lang.String tt(java.lang.String text, int width)
          Wraps HTML tags around text so the maximum width is limited to a senseful value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POPUP_MENU_HEIGHT_INSET

public static final int POPUP_MENU_HEIGHT_INSET
Kicker offset.

See Also:
Constant Field Values

prefs

protected static Preferences prefs
Constructor Detail

GUIHelper

public GUIHelper()
Method Detail

bindEnterKey

public static boolean bindEnterKey(javax.swing.JComponent c,
                                   javax.swing.Action action)
Adds a mapping between the enter key and action to the input map of c.

Returns:
true, if successful; false, otherwise

bindEnterKeyLocally

public static boolean bindEnterKeyLocally(javax.swing.JComponent c,
                                          javax.swing.Action action)
Does the same as bindEnterKey(JComponent, Action) but uses the default input map and not the window input map.

Returns:
true, if successful; false, otherwise

bindEscapeKey

public static boolean bindEscapeKey(javax.swing.JComponent c,
                                    javax.swing.Action action)
Adds a mapping between the escape key and action to the input map of c.

Returns:
true, if successful; false, otherwise

bindKey

public static boolean bindKey(javax.swing.JComponent c,
                              javax.swing.KeyStroke ks,
                              javax.swing.Action action,
                              boolean whenInFocusedWindow)
Adds a mapping between ks and action to the input map of c.

Returns:
true, if successful; false, otherwise

createDefaultBorder

public static javax.swing.border.Border createDefaultBorder(java.lang.String title)
Returns an etched default border.


createEmptyBorder

public static javax.swing.border.Border createEmptyBorder(int inset)
Returns an empty border.


createEmptyBorder

public static javax.swing.border.Border createEmptyBorder()
Returns an empty border.


createEtchedBorder

public static javax.swing.border.Border createEtchedBorder()
Returns an empty border.


createLoweredBorder

public static javax.swing.border.Border createLoweredBorder()

createRaisedBorder

public static javax.swing.border.Border createRaisedBorder()

createHeader

public static javax.swing.JComponent createHeader(java.lang.String title)
Creates and answers a label with separator; useful to separate paragraphs in a panel. This is often a better choice than a TitledBorder.

The current implementation doesn't support component alignments.

Copyright (c) 2003 JGoodies Karsten Lentzsch. All Rights Reserved. Modified by Steffen Pingel for XNap.

Parameters:
text - the title's text
alignment - text alignment: left, center, right
Returns:
a separator with title label

createSeparator

public static javax.swing.JComponent createSeparator(java.lang.String title)

createTitledBorder

public static javax.swing.border.Border createTitledBorder(java.lang.String title,
                                                           int inset)
Returns a titled border.


expandAllNodes

public static void expandAllNodes(javax.swing.JTree jt)

initialize

public static void initialize()

restrictWidth

public static void restrictWidth(javax.swing.JComponent jc)

scrollToEnd

public static void scrollToEnd(javax.swing.text.JTextComponent jt)

shouldScroll

public static boolean shouldScroll(javax.swing.JScrollBar jsb)
Returns true, if jsb is at the maximum value.


getMenuKeyStroke

public static javax.swing.KeyStroke getMenuKeyStroke(int keyCode)

setAccelerator

public static void setAccelerator(javax.swing.JMenuItem jmi,
                                  int keyCode)

setMnemonics

public static void setMnemonics(javax.swing.JTabbedPane pane)

setMnemonics

public static void setMnemonics(java.awt.Container c)

setMnemonics

public static void setMnemonics(java.awt.Container c,
                                java.util.HashSet l)

showFile

public static void showFile(javax.swing.text.JTextComponent jta,
                            java.lang.String filename,
                            java.lang.String altText)
Loads text from file and sets it to jta.

If file is not found or could not be read, sets altText instead.


showPopupMenu

public static void showPopupMenu(javax.swing.JPopupMenu jpm,
                                 java.awt.Component source,
                                 int x,
                                 int y,
                                 int yOffset)

showPopupMenu

public static void showPopupMenu(javax.swing.JPopupMenu jpm,
                                 java.awt.Component source,
                                 int x,
                                 int y)

label

public static java.lang.String label(java.lang.String text)
Wraps HTML tags around text so the maximum width is limited to a senseful value.

Returns:
text, enclosed in table html tags

tt

public static java.lang.String tt(java.lang.String text,
                                  int width)
Wraps HTML tags around text so the maximum width is limited to a senseful value.

Returns:
text, enclosed in table html tags

tt

public static java.lang.String tt(java.lang.String text)
Wraps HTML tags around text so the maximum width is limited to a sensible value.

Returns:
text, enclosed in table html tags

tableRow

public static java.lang.String tableRow(java.lang.String key,
                                        java.lang.String value)
Formats key, value as a HTML table row, the key is highlighted as bold.


limitSize

public static void limitSize(javax.swing.JComponent c)

bindEmacsKeysToTable

public static void bindEmacsKeysToTable(javax.swing.JTable jta)
Adds some Emacs like keybindings to a table for moving between rows.



Copyright © 2001-2005 XNap Team. All Rights Reserved.