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 Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
SwingUtilities2.AATextInfo | |||||||||||
SwingUtilities2.Section | Used by the liesIn method to return which section
the point lies in. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
AA_TEXT_PROPERTY_KEY | A JComponent client property is used to determine text aa settings. | ||||||||||
BASICMENUITEMUI_MAX_TEXT_OFFSET | Client Property key for the text maximal offsets for BasicMenuItemUI | ||||||||||
COMPONENT_UI_PROPERTY_KEY | Key used in client properties used to indicate that the
ComponentUI of the JComponent instance should be returned. |
||||||||||
DEFAULT_FRC | |||||||||||
LAF_STATE_KEY | The AppContext key for our one LAFState
instance. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Request focus on the given component if it doesn't already have it
and
isRequestFocusEnabled() returns true. | |||||||||||
checks the security permissions for accessing system clipboard
for untrusted context (see isTrustedContext) checks the
permissions for the current event being handled
| |||||||||||
Returns true if EventQueue.getCurrentEvent() has the permissions to
access the system clipboard
| |||||||||||
Returns true if the given event has permissions to access the
system clipboard
| |||||||||||
Clips the passed in String to the space provided.
| |||||||||||
Clips the passed in String to the space provided.
| |||||||||||
The following draw functions have the same semantic as the
Graphics methods with the same names.
| |||||||||||
Draws the string at the specified location.
| |||||||||||
Draws the string at the specified location underlining the specified
character.
| |||||||||||
Returns whether or not text should be drawn antialiased.
| |||||||||||
Return the MouseEvent's click count, possibly reduced by the value of
the component's
SKIP_CLICK_COUNT client property. | |||||||||||
Returns the FontMetrics for the current Font of the passed
in Graphics.
| |||||||||||
Returns the FontMetrics for the specified Font.
| |||||||||||
Returns the left side bearing of the specified character.
| |||||||||||
Returns the left side bearing of the first character of string.
| |||||||||||
Returns the right side bearing of the last character of string.
| |||||||||||
Returns the right side bearing of the specified character.
| |||||||||||
Returns an integer from the defaults table that is appropriate
for the given locale.
| |||||||||||
Returns an integer from the defaults table that is appropriate
for the given locale.
| |||||||||||
Returns an integer from the defaults table.
| |||||||||||
Returns an integer from the defaults table.
| |||||||||||
checks whether TextLayout is required to handle characters.
| |||||||||||
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.
| |||||||||||
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.
| |||||||||||
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.
| |||||||||||
Utility method that creates a
UIDefaults.LazyValue that
creates an ImageIcon UIResource for the
specified image file name. | |||||||||||
Returns true if the given point is outside the preferredSize of the
item at the given row of the table.
| |||||||||||
Set the lead and anchor without affecting selection.
| |||||||||||
Sets the
SKIP_CLICK_COUNT client property on the component
if it is an instance of JTextComponent with a
DefaultCaret . | |||||||||||
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.
| |||||||||||
Returns the width of the passed in String.
| |||||||||||
Submits a value-returning task for execution on the EDT and
returns a Future representing the pending results of the task.
| |||||||||||
Submits a Runnable task for execution on the EDT and returns a
Future representing that task.
| |||||||||||
Change focus to the visible component in
JTabbedPane . | |||||||||||
Determines whether the SelectedTextColor should be used for painting text
foreground for the specified highlight.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
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
Client Property key for the text maximal offsets for BasicMenuItemUI
Key used in client properties used to indicate that the
ComponentUI
of the JComponent instance should be returned.
Request focus on the given component if it doesn't already have it
and isRequestFocusEnabled()
returns true.
checks the security permissions for accessing system clipboard for untrusted context (see isTrustedContext) checks the permissions for the current event being handled
Returns true if EventQueue.getCurrentEvent() has the permissions to access the system clipboard
Returns true if the given event has permissions to access the system clipboard
e | AWTEvent to check |
---|
Clips the passed in String to the space provided. NOTE: this assumes the string does not fit in the available space.
c | JComponent that will display the string, may be null |
---|---|
fm | FontMetrics used to measure the String width |
string | String to display |
availTextWidth | Amount of space that the string can be drawn in |
Clips the passed in String to the space provided.
c | JComponent that will display the string, may be null |
---|---|
fm | FontMetrics used to measure the String width |
string | String to display |
availTextWidth | Amount of space that the string can be drawn in |
The following draw functions have the same semantic as the Graphics methods with the same names. this is used for printing
Draws the string at the specified location.
c | JComponent that will display the string, may be null |
---|---|
g | Graphics to draw the text to |
text | String to display |
x | X coordinate to draw the text at |
y | Y coordinate to draw the text at |
Draws the string at the specified location underlining the specified character.
c | JComponent that will display the string, may be null |
---|---|
g | Graphics to draw the text to |
text | String to display |
underlinedIndex | Index of a character in the string to underline |
x | X coordinate to draw the text at |
y | Y coordinate to draw the text at |
Returns whether or not text should be drawn antialiased.
c | JComponent to test. |
---|
Return the MouseEvent's click count, possibly reduced by the value of
the component's SKIP_CLICK_COUNT
client property. Clears
the 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.
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.
c | JComponent requesting FontMetrics, may be null |
---|---|
g | Graphics Graphics |
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.
c | Graphics Graphics |
---|---|
font | Font to get FontMetrics for |
Returns the left side bearing of the specified character. The left side bearing is calculated from the passed in FontMetrics.
c | JComponent that will display the string |
---|---|
fm | FontMetrics used to measure the String width |
firstChar | Character to get the left side bearing for. |
Returns the left side bearing of the first character of string. The left side bearing is calculated from the passed in FontMetrics.
c | JComponent that will display the string |
---|---|
fm | FontMetrics used to measure the String width |
string | String to get the left side bearing for. |
Returns the right side bearing of the last character of string. The right side bearing is calculated from the passed in FontMetrics.
c | JComponent that will display the string |
---|---|
fm | FontMetrics used to measure the String width |
string | String to get the right side bearing for. |
Returns the right side bearing of the specified character. The right side bearing is calculated from the passed in FontMetrics.
c | JComponent that will display the string |
---|---|
fm | FontMetrics used to measure the String width |
lastChar | Character to get the right side bearing for. |
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.
key | an Object specifying the int. Returned value
is 0 if key is not available, |
---|---|
l | the Locale for which the int is desired |
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.
key | an Object specifying the int. Returned value
is 0 if key is not available, |
---|---|
l | the Locale for which the int is desired |
defaultValue | Returned value if key is not available,
or is not an Integer |
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.
key | an Object specifying the int. |
---|
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.
key | an Object specifying the int. Returned value
is 0 if key is not available, |
---|---|
defaultValue | Returned value if key is not available,
or is not an Integer |
checks whether TextLayout is required to handle characters.
text | characters to be tested |
---|---|
start | start |
limit | limit |
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.
rect | the rectangle |
---|---|
p | the point the check |
ltr | true for left to right orientation,
or false for right to left orientation |
three | true for three sections,
or false for two |
Section
where the point liesNullPointerException | if rect or p are
null
|
---|
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.
rect | the rectangle |
---|---|
p | the point the check |
three | true for three sections,
or false for two |
Section
where the point liesNullPointerException | if rect or p are
null
|
---|
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.
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
.
baseClass | the first class to use in searching for the resource |
---|---|
rootClass | an ancestor of baseClass to finish the
search at |
imageFile | the name of the file to be found |
ImageIcon
UIResource
for the image,
or null if it cannot be found
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.
Set the lead and anchor without affecting selection.
Sets the SKIP_CLICK_COUNT
client property on the component
if it is an instance of JTextComponent
with a
DefaultCaret
. This property, used for text components acting
as editors in a table or tree, tells DefaultCaret
how many
clicks to skip before starting selection.
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.
Returns the width of the passed in String.
If the passed String is null
, returns zero.
c | JComponent that will display the string, may be null |
---|---|
fm | FontMetrics used to measure the String width |
string | String to get the width of |
Submits a value-returning task for execution on the EDT and returns a Future representing the pending results of the task.
task | the task to submit |
---|
NullPointerException | if the task is null |
---|
Submits a Runnable task for execution on the EDT and returns a Future representing that task.
task | the task to submit |
---|---|
result | the result to return upon successful completion |
NullPointerException | if the task is null |
---|
Change focus to the visible component in JTabbedPane
.
This is not a general-purpose method and is here only to permit
sharing code.
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