JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.util.swing
Class JCSwingUtilities

java.lang.Object
  |
  +--com.klg.jclass.util.swing.JCSwingUtilities

public class JCSwingUtilities
extends Object

Utilities class that provides tools to perferm common tasks.


Constructor Summary
JCSwingUtilities()
           
 
Method Summary
static Dimension getButtonPSFromGraphics(JButton button, Graphics gc)
          Gets the preferred size of a swing JButton from the font metrics specified by the Graphics object.
static Dimension getLabelPSFromGraphics(JLabel label, Graphics gc)
          Gets the preferred size of a swing JLabel from the font metrics specified by the Graphics object.
static Dimension getPreferredSizeFromGraphics(JComponent component, Graphics gc, boolean override)
          Calculates the preferred size of Swing components from the font metrics in the specified Graphics object, not from the default screen font metrics as Swing usually does.
static void setEnabled(Component container, boolean value)
          Recursively calls setEnabled() on all child components of a container.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JCSwingUtilities

public JCSwingUtilities()
Method Detail

setEnabled

public static void setEnabled(Component container,
                              boolean value)
Recursively calls setEnabled() on all child components of a container. If the Component passed in is not a Container, it is either enabled or disabled, and the method returns.

Parameters:
container - the Component to be recursively enabled or disabled
value - a boolean indicating if the container and its children (recursively) should be enabled or disabled; true means enabled, false disabled

getPreferredSizeFromGraphics

public static Dimension getPreferredSizeFromGraphics(JComponent component,
                                                     Graphics gc,
                                                     boolean override)
Calculates the preferred size of Swing components from the font metrics in the specified Graphics object, not from the default screen font metrics as Swing usually does.
Note: This method currently only supports JLabel and JButton.

Parameters:
component - The component to get the preferred size from (currently, this must be a JButton or a JLabel)
gc - The graphics object used to obtain font metrics
override - true if this overrides the use of getPreferredSize() from the UI class specified for the component all the time; false if preferred size is to be calculated by this method only when the component's UI class is the default one
Returns:

getLabelPSFromGraphics

public static Dimension getLabelPSFromGraphics(JLabel label,
                                               Graphics gc)
Gets the preferred size of a swing JLabel from the font metrics specified by the Graphics object.

Parameters:
label - The JLabel whose preferred size is required
gc - The graphics object used to obtain font metrics
Returns:
The preferred size of the JLabel based on the gc's font metrics

getButtonPSFromGraphics

public static Dimension getButtonPSFromGraphics(JButton button,
                                                Graphics gc)
Gets the preferred size of a swing JButton from the font metrics specified by the Graphics object.

Parameters:
button - The JButton whose preferred size is required
gc - The graphics object used to obtain font metrics
Returns:
The preferred size of the JButton based on the gc's font metrics

Copyright © 2004 Quest Software Inc..
All rights reserved.