ehsbe CommonsTM
Version 1.1.0rc3

com.ehsbe.commons.gui.util
Class SwingUtilities2

java.lang.Object
  extended by com.ehsbe.commons.gui.util.SwingUtilities2

public class SwingUtilities2
extends Object

Wrapper around sun.swing.SwingUtilities2

Version:
$Revision: 450 $
Author:
Jens Elkner

Constructor Summary
SwingUtilities2()
           
 
Method Summary
static String clipString(FontMetrics fm, String string, int availTextWidth)
          Clips the passed in String to the space provided.
static String clipStringIfNecessary(FontMetrics fm, String string, int availTextWidth)
          Clips the passed in String to the space provided.
static FontRenderContext getFontRenderContext(Component c)
          Get the FontRenderContext associated with the given JComponent
static void invokeLater(Runnable r)
          Runs the given runnable immediately, if invoked from the event dispatch thread (EDT), otherwise the runnable gets pushed into the EDT queue.
static int stringWidth(FontMetrics fm, String string)
          Get the width of the passed in String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwingUtilities2

public SwingUtilities2()
Method Detail

getFontRenderContext

public static FontRenderContext getFontRenderContext(Component c)
Get the FontRenderContext associated with the given JComponent

Parameters:
c - for which component the FRC should be fetched
Returns:
always a none-null value
See Also:
JComponent.getFontMetrics(java.awt.Font)

stringWidth

public static int stringWidth(FontMetrics fm,
                              String string)
Get the width of the passed in String.

Parameters:
fm - FontMetrics used to measure the String width
string - String to get the width of
Returns:
the width of a string

clipString

public static String clipString(FontMetrics fm,
                                String string,
                                int availTextWidth)
Clips the passed in String to the space provided. NOTE: this assumes the string does not fit in the available space.

Parameters:
fm - FontMetrics used to measure the String width
string - String to display
availTextWidth - Amount of space that the string can be drawn in
Returns:
Clipped string that can fit in the provided space.

clipStringIfNecessary

public static String clipStringIfNecessary(FontMetrics fm,
                                           String string,
                                           int availTextWidth)
Clips the passed in String to the space provided.

Parameters:
fm - FontMetrics used to measure the String width
string - String to display
availTextWidth - Amount of space that the string can be drawn in
Returns:
Clipped string that can fit in the provided space.

invokeLater

public static void invokeLater(Runnable r)
Runs the given runnable immediately, if invoked from the event dispatch thread (EDT), otherwise the runnable gets pushed into the EDT queue.

Parameters:
r - runnable to run/dispatch

ehsbe CommonsTM
Version 1.1.0rc3

Copyright ©2005-2009 EHSBE, Walther-Rathenau-Str. 58, 39104 Magdeburg, Sachsen-Anhalt, Germany. All Rights Reserved.