Home » openjdk-7 » sun » swing » [javadoc | source]
sun.swing
public class: SwingUtilities2 [javadoc | source]
java.lang.Object
   sun.swing.SwingUtilities2
A collection of utility methods for Swing.

WARNING: While this class is public, it should not be treated as public API and its API may change in incompatable ways between dot dot releases and even patch releases. You should not rely on this class even existing.
Nested Class Summary:
public static class  SwingUtilities2.AATextInfo   
public enum class  SwingUtilities2.Section  Used by the {@code liesIn} method to return which section the point lies in. 
Field Summary
public static final  Object LAF_STATE_KEY    The AppContext key for our one LAFState instance. 
public static final  FontRenderContext DEFAULT_FRC     
public static final  Object AA_TEXT_PROPERTY_KEY    A JComponent client property is used to determine text aa settings. To avoid having this property persist between look and feels changes the value of the property is set to null in JComponent.setUI 
public static final  String IMPLIED_CR    Attribute key for the content elements. If it is set on an element, the element is considered to be a line break. 
public static final  Object COMPONENT_UI_PROPERTY_KEY    Key used in client properties used to indicate that the ComponentUI of the JComponent instance should be returned. 
public static final  StringUIClientPropertyKey BASICMENUITEMUI_MAX_TEXT_OFFSET    Client Property key for the text maximal offsets for BasicMenuItemUI 
Method from sun.swing.SwingUtilities2 Summary:
adjustFocus,   canAccessSystemClipboard,   canCurrentEventAccessSystemClipboard,   canEventAccessSystemClipboard,   clipString,   clipStringIfNecessary,   compositeRequestFocus,   convertColumnIndexToModel,   convertColumnIndexToView,   displayPropertiesToCSS,   drawChars,   drawString,   drawString,   drawStringUnderlineCharAt,   drawTextAntialiased,   getAdjustedClickCount,   getFontMetrics,   getFontMetrics,   getFontMetrics,   getFontRenderContext,   getGraphics2D,   getLeftSideBearing,   getLeftSideBearing,   getUIDefaultsInt,   getUIDefaultsInt,   getUIDefaultsInt,   getUIDefaultsInt,   isComplexLayout,   isLocalDisplay,   isPrinting,   liesInHorizontal,   liesInVertical,   loc2IndexFileList,   makeIcon,   pointOutsidePrefSize,   setLeadAnchorWithoutSelection,   setSkipClickCount,   shouldIgnore,   stringWidth,   submit,   submit,   tabbedPaneChangeFocusTo,   useSelectedTextColor
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from sun.swing.SwingUtilities2 Detail:
 public static  void adjustFocus(JComponent c) 
    Request focus on the given component if it doesn't already have it and isRequestFocusEnabled() returns true.
 public static boolean canAccessSystemClipboard() 
    checks the security permissions for accessing system clipboard for untrusted context (see isTrustedContext) checks the permissions for the current event being handled
 public static boolean canCurrentEventAccessSystemClipboard() 
    Returns true if EventQueue.getCurrentEvent() has the permissions to access the system clipboard
 public static boolean canEventAccessSystemClipboard(AWTEvent e) 
    Returns true if the given event has permissions to access the system clipboard
 public static String clipString(JComponent c,
    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.
 public static String clipStringIfNecessary(JComponent c,
    FontMetrics fm,
    String string,
    int availTextWidth) 
    Clips the passed in String to the space provided.
 public static Component compositeRequestFocus(Component component) 
 public static int convertColumnIndexToModel(TableColumnModel cm,
    int viewColumnIndex) 
    Maps the index of the column in the view at {@code viewColumnIndex} to the index of the column in the table model. Returns the index of the corresponding column in the model. If {@code viewColumnIndex} is less than zero, returns {@code viewColumnIndex}.
 public static int convertColumnIndexToView(TableColumnModel cm,
    int modelColumnIndex) 
    Maps the index of the column in the {@code cm} at {@code modelColumnIndex} to the index of the column in the view. Returns the index of the corresponding column in the view; returns {@code -1} if this column is not being displayed. If {@code modelColumnIndex} is less than zero, returns {@code modelColumnIndex}.
 public static String displayPropertiesToCSS(Font font,
    Color fg) 
 public static int drawChars(JComponent c,
    Graphics g,
    char[] data,
    int offset,
    int length,
    int x,
    int y) 
    The following draw functions have the same semantic as the Graphics methods with the same names. this is used for printing
 public static  void drawString(JComponent c,
    Graphics g,
    String text,
    int x,
    int y) 
    Draws the string at the specified location.
 public static float drawString(JComponent c,
    Graphics g,
    AttributedCharacterIterator iterator,
    int x,
    int y) 
 public static  void drawStringUnderlineCharAt(JComponent c,
    Graphics g,
    String text,
    int underlinedIndex,
    int x,
    int y) 
    Draws the string at the specified location underlining the specified character.
 public static AATextInfo drawTextAntialiased(JComponent c) 
    Returns whether or not text should be drawn antialiased.
 public static int getAdjustedClickCount(JTextComponent comp,
    MouseEvent e) 
    Return the MouseEvent's click count, possibly reduced by the value of the component's {@code SKIP_CLICK_COUNT} client property. Clears the {@code SKIP_CLICK_COUNT} property if the mouse event's click count is 1. In order for clearing of the property to work correctly, there must be a mousePressed implementation on the caller with this call as the first line.
 public static FontMetrics getFontMetrics(JComponent c,
    Graphics g) 
    Returns the FontMetrics for the current Font of the passed in Graphics. This method is used when a Graphics is available, typically when painting. If a Graphics is not available the JComponent method of the same name should be used.

    Callers should pass in a non-null JComponent, the exception to this is if a JComponent is not readily available at the time of painting.

    This does not necessarily return the FontMetrics from the Graphics.

 public static FontMetrics getFontMetrics(JComponent c,
    Font font) 
 public static FontMetrics getFontMetrics(JComponent c,
    Graphics g,
    Font font) 
    Returns the FontMetrics for the specified Font. This method is used when a Graphics is available, typically when painting. If a Graphics is not available the JComponent method of the same name should be used.

    Callers should pass in a non-null JComonent, the exception to this is if a JComponent is not readily available at the time of painting.

    This does not necessarily return the FontMetrics from the Graphics.

 public static FontRenderContext getFontRenderContext(Component c) 
 public static Graphics2D getGraphics2D(Graphics g) 
 public static int getLeftSideBearing(JComponent c,
    FontMetrics fm,
    String string) 
    Returns the left side bearing of the first character of string. The left side bearing is calculated from the passed in FontMetrics. If the passed in String is less than one character {@code 0} is returned.
 public static int getLeftSideBearing(JComponent c,
    FontMetrics fm,
    char firstChar) 
    Returns the left side bearing of the first character of string. The left side bearing is calculated from the passed in FontMetrics.
 public static int getUIDefaultsInt(Object key) 
    Returns an integer from the defaults table. If key does not map to a valid Integer, or can not be convered from a String to an integer, the value 0 is returned.
 public static int getUIDefaultsInt(Object key,
    Locale l) 
    Returns an integer from the defaults table that is appropriate for the given locale. If key does not map to a valid Integer, or can not be convered from a String to an integer, the value 0 is returned.
 public static int getUIDefaultsInt(Object key,
    int defaultValue) 
    Returns an integer from the defaults table. If key does not map to a valid Integer, or can not be convered from a String to an integer, default is returned.
 public static int getUIDefaultsInt(Object key,
    Locale l,
    int defaultValue) 
    Returns an integer from the defaults table that is appropriate for the given locale. If key does not map to a valid Integer, or can not be convered from a String to an integer, default is returned.
 public static final boolean isComplexLayout(char[] text,
    int start,
    int limit) 
    checks whether TextLayout is required to handle characters.
 public static boolean isLocalDisplay() 
 static boolean isPrinting(Graphics g) 
 public static Section liesInHorizontal(Rectangle rect,
    Point p,
    boolean ltr,
    boolean three) 
    This method divides a rectangle into two or three sections along the horizontal axis and determines which section the given point lies in; used by drag and drop when calculating drop locations.

    See the documentation for #liesIn for more information on how the section is calculated.

 public static Section liesInVertical(Rectangle rect,
    Point p,
    boolean three) 
    This method divides a rectangle into two or three sections along the vertical axis and determines which section the given point lies in; used by drag and drop when calculating drop locations.

    See the documentation for #liesIn for more information on how the section is calculated.

 public static int loc2IndexFileList(JList list,
    Point point) 
    A variation of locationToIndex() which only returns an index if the Point is within the actual bounds of a list item (not just in the cell) and if the JList has the "List.isFileList" client property set. Otherwise, this method returns -1. This is used to make WindowsL&F JFileChooser act like native dialogs.
 public static Object makeIcon(Class<?> baseClass,
    Class<?> rootClass,
    String imageFile) 
    Utility method that creates a UIDefaults.LazyValue that creates an ImageIcon UIResource for the specified image file name. The image is loaded using getResourceAsStream, starting with a call to that method on the base class parameter. If it cannot be found, searching will continue through the base class' inheritance hierarchy, up to and including rootClass.
 public static boolean pointOutsidePrefSize(JTable table,
    int row,
    int column,
    Point p) 
    Returns true if the given point is outside the preferredSize of the item at the given row of the table. (Column must be 0). Does not check the "Table.isFileList" property. That should be checked before calling this method. This is used to make WindowsL&F JFileChooser act like native dialogs.
 public static  void setLeadAnchorWithoutSelection(ListSelectionModel model,
    int lead,
    int anchor) 
    Set the lead and anchor without affecting selection.
 public static  void setSkipClickCount(Component comp,
    int count) 
    Sets the {@code SKIP_CLICK_COUNT} client property on the component if it is an instance of {@code JTextComponent} with a {@code DefaultCaret}. This property, used for text components acting as editors in a table or tree, tells {@code DefaultCaret} how many clicks to skip before starting selection.
 public static boolean shouldIgnore(MouseEvent me,
    JComponent c) 
    Ignore mouse events if the component is null, not enabled, the event is not associated with the left mouse button, or the event has been consumed.
 public static int stringWidth(JComponent c,
    FontMetrics fm,
    String string) 
    Returns the width of the passed in String. If the passed String is null, returns zero.
 public static Future<V> submit(Callable<V> task) 
    Submits a value-returning task for execution on the EDT and returns a Future representing the pending results of the task.
 public static Future<V> submit(Runnable task,
    V result) 
    Submits a Runnable task for execution on the EDT and returns a Future representing that task.
 public static boolean tabbedPaneChangeFocusTo(Component comp) 
    Change focus to the visible component in {@code JTabbedPane}. This is not a general-purpose method and is here only to permit sharing code.
 public static boolean useSelectedTextColor(Highlight h,
    JTextComponent c) 
    Determines whether the SelectedTextColor should be used for painting text foreground for the specified highlight. Returns true only if the highlight painter for the specified highlight is the swing painter (whether inner class of javax.swing.text.DefaultHighlighter or com.sun.java.swing.plaf.windows.WindowsTextUI) and its background color is null or equals to the selection color of the text component. This is a hack for fixing both bugs 4761990 and 5003294