public final class Utilities extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Utilities.UnorderableException
Deprecated.
Used only by the deprecated partialSort
|
Modifier and Type | Field and Description |
---|---|
static int |
OS_AIX
Operating system is IBM AIX.
|
static int |
OS_DEC
Deprecated.
please use OS_TRU64 instead
|
static int |
OS_FREEBSD
Operating system is FreeBSD
|
static int |
OS_HP
Operating system is HP-UX.
|
static int |
OS_IRIX
Operating system is SGI IRIX.
|
static int |
OS_LINUX
Operating system is Linux.
|
static int |
OS_MAC
Operating system is Mac.
|
static int |
OS_OPENBSD
Operating system is OpenBSD.
|
static int |
OS_OS2
Operating system is OS/2.
|
static int |
OS_OTHER
Operating system is unknown.
|
static int |
OS_SOLARIS
Operating system is Solaris.
|
static int |
OS_SUNOS
Operating system is Sun OS.
|
static int |
OS_TRU64
Operating system is Compaq TRU64 Unix
|
static int |
OS_UNIX_MASK
Deprecated.
Use
Utilities.isUnix() instead. |
static int |
OS_UNIX_OTHER
Operating system is one of the Unix variants but we don't know which
one it is.
|
static int |
OS_VMS
Operating system is Compaq OpenVMS
|
static int |
OS_WIN_OTHER
Operating system is one of the Windows variants but we don't know which
one it is
|
static int |
OS_WIN2000
Operating system is Windows 2000.
|
static int |
OS_WIN95
Operating system is Windows 95.
|
static int |
OS_WIN98
Operating system is Windows 98.
|
static int |
OS_WINDOWS_MASK
Deprecated.
Use
Utilities.isWindows() instead. |
static int |
OS_WINNT
Operating system is Windows NT.
|
static int |
OS_WINVISTA
Operating system is Windows Vista.
|
static int |
TYPICAL_WINDOWS_TASKBAR_HEIGHT
A height of the windows's taskbar
|
Modifier and Type | Method and Description |
---|---|
static List<? extends Action> |
actionsForPath(String path)
Load a menu sequence from a lookup path.
|
static Lookup |
actionsGlobalContext()
Global context for actions.
|
static JPopupMenu |
actionsToPopup(Action[] actions,
Component component)
Builds a popup menu for provided component.
|
static JPopupMenu |
actionsToPopup(Action[] actions,
Lookup context)
Builds a popup menu from actions for provided context specified by
Lookup . |
static ReferenceQueue<Object> |
activeReferenceQueue()
Useful queue for all parts of system that use
java.lang.ref.Reference s
together with some ReferenceQueue and need to do some clean up
when the reference is enqueued. |
static int |
arrayHashCode(Object[] arr)
Deprecated.
Use
Arrays.hashCode(Object[]) instead. |
static void |
attachInitJob(Component comp4Init,
AsyncGUIJob initJob)
Attaches asynchronous init job to given component.
|
static boolean |
compareObjects(Object o1,
Object o2)
Safe equality check.
|
static boolean |
compareObjectsImpl(Object o1,
Object o2,
int checkArraysDepth)
Safe equality check with array recursion.
|
static Cursor |
createCustomCursor(Component component,
Image icon,
String name) |
static Cursor |
createProgressCursor(Component component)
Returns a cursor with an arrow and an hourglass (or stop watch) badge,
to be used when a component is busy but the UI is still responding to the user.
|
static void |
disabledActionBeep()
On some platform this method makes a short audible beep, use it when user
tries to invoke an action that's disabled.
|
static String |
escapeParameters(String[] params)
Complementary method to parseParameters
|
static Rectangle |
findCenterBounds(Dimension componentSize)
Helps client code place components on the center of the screen.
|
static BeanInfo |
getBeanInfo(Class<?> clazz)
Central method for obtaining
BeanInfo for potential JavaBean classes. |
static BeanInfo |
getBeanInfo(Class<?> clazz,
Class<?> stopClass)
Central method for obtaining
BeanInfo for potential JavaBean classes, with a stop class. |
static String |
getClassName(Class<?> clazz)
Assemble a human-presentable class name for a specified class.
|
static Component |
getFocusTraversableComponent(Component c)
Find a focus-traverable component.
|
static Class<?> |
getObjectType(Class<?> c)
Get the object type for given primitive type.
|
static int |
getOperatingSystem()
Get the operating system on which NetBeans is running.
|
static Class<?> |
getPrimitiveType(Class<?> c)
Get the primitive type for given object type.
|
static Dimension |
getScreenSize()
Deprecated.
this method is almost useless in multiple monitor configuration
|
static String |
getShortClassName(Class<?> clazz)
Assemble a human-presentable class name for a specified class (omitting the package).
|
static Rectangle |
getUsableScreenBounds()
Returns the usable area of the screen where applications can place its
windows.
|
static Rectangle |
getUsableScreenBounds(GraphicsConfiguration gconf)
Returns the usable area of the screen where applications can place its
windows.
|
static Image |
icon2Image(Icon icon)
Deprecated.
|
static boolean |
isJavaIdentifier(String id)
Test whether a given string is a valid Java identifier.
|
static boolean |
isLargeFrameIcons()
Deprecated.
Obsolete, useless method, no replacement.
|
static boolean |
isMac()
Test whether NetBeans is running on Mac OS X.
|
static boolean |
isUnix()
Test whether NetBeans is running on some variant of Unix.
|
static boolean |
isWindows()
Test whether NetBeans is running on some variant of Windows.
|
static String |
keyToString(KeyStroke stroke)
Converts a Swing key stroke descriptor to a familiar Emacs-like name.
|
static String |
keyToString(KeyStroke stroke,
boolean portable)
Converts a Swing key stroke descriptor to a familiar Emacs-like name,
but in a portable way, ie.
|
static Image |
loadImage(String resourceID)
Deprecated.
|
static Image |
loadImage(String resource,
boolean localized)
Deprecated.
|
static Image |
mergeImages(Image image1,
Image image2,
int x,
int y)
Deprecated.
|
static String[] |
parseParameters(String s)
Parses parameters from a given string in shell-like manner.
|
static List |
partialSort(List l,
Comparator c,
boolean stable)
Deprecated.
Deprecated in favor of the potentially much faster (and possibly more correct)
Utilities.topologicalSort(java.util.Collection<? extends T>, java.util.Map<? super T, ? extends java.util.Collection<? extends T>>) . |
static String |
pureClassName(String fullName)
Turn full name of an inner class into its pure form.
|
static String |
replaceString(String original,
String replaceFrom,
String replaceTo)
Deprecated.
Use
String.replace(CharSequence,CharSequence) instead |
static int |
showJFileChooser(JFileChooser chooser,
Component parent,
String approveButtonText)
Deprecated.
Not needed in JDK 1.4.
|
static KeyStroke |
stringToKey(String s)
Construct a new key description from a given universal string
description.
|
static KeyStroke[] |
stringToKeys(String s)
Convert a space-separated list of user-friendly key binding names to a list of Swing key strokes.
|
static File |
toFile(URI u)
Converts a URI to a file while being safe for UNC paths.
|
static File |
toFile(URL u)
Deprecated.
Use
URL.toURI() and Utilities.toFile(URI) instead under JDK 1.4.
(There was no proper equivalent under JDK 1.3.) |
static Object[] |
toObjectArray(Object array)
Convert an array of primitive types to an array of objects.
|
static <T> List<T> |
topologicalSort(Collection<? extends T> c,
Map<? super T,? extends Collection<? extends T>> edges)
Topologically sort some objects.
|
static Object |
toPrimitiveArray(Object[] array)
Convert an array of objects to an array of primitive types.
|
static URI |
toURI(File f)
Converts a file to a URI while being safe for UNC paths.
|
static URL |
toURL(File f)
Deprecated.
Use
Utilities.toURI(java.io.File) and URI.toURL() instead under JDK 1.4.
(File.toURL() is buggy in JDK 1.3 and the bugs are not fixed in JDK 1.4.) |
static String |
translate(String className)
Provides support for parts of the system that deal with classnames
(use
Class.forName , NbObjectInputStream , etc.) or filenames
in layers. |
static String |
wrapString(String original,
int width,
boolean wrapWords,
boolean removeNewLines)
Deprecated.
Use
(String, int, BreakIterator, boolean) as it is friendlier to I18N. |
static String |
wrapString(String original,
int width,
BreakIterator breakIterator,
boolean removeNewLines)
Wrap multi-line strings.
|
static String[] |
wrapStringToArray(String original,
int width,
boolean wrapWords,
boolean removeNewLines)
Deprecated.
use
Utilities.wrapStringToArray(String, int, BreakIterator, boolean) since it is better for I18N |
static String[] |
wrapStringToArray(String original,
int width,
BreakIterator breakIterator,
boolean removeNewLines)
Wrap multi-line strings (and get the individual lines).
|
public static final int OS_WINNT
public static final int OS_WIN95
public static final int OS_WIN98
public static final int OS_SOLARIS
public static final int OS_LINUX
public static final int OS_HP
public static final int OS_AIX
public static final int OS_IRIX
public static final int OS_SUNOS
public static final int OS_TRU64
@Deprecated public static final int OS_DEC
public static final int OS_OS2
public static final int OS_MAC
public static final int OS_WIN2000
public static final int OS_VMS
public static final int OS_WIN_OTHER
public static final int OS_OTHER
public static final int OS_FREEBSD
public static final int OS_WINVISTA
public static final int OS_UNIX_OTHER
public static final int OS_OPENBSD
@Deprecated public static final int OS_WINDOWS_MASK
Utilities.isWindows()
instead.@Deprecated public static final int OS_UNIX_MASK
Utilities.isUnix()
instead.public static final int TYPICAL_WINDOWS_TASKBAR_HEIGHT
public static ReferenceQueue<Object> activeReferenceQueue()
java.lang.ref.Reference
s
together with some ReferenceQueue
and need to do some clean up
when the reference is enqueued. Usually, in order to be notified about that, one
needs to either create a dedicated thread that blocks on the queue and is
Object.notify
-ed, which is the right approach but consumes
valuable system resources (threads) or one can periodically check the content
of the queue by RequestProcessor.Task.schedule
which is
completely wrong, because it wakes up the system every (say) 15 seconds.
In order to provide useful support for this problem, this queue has been
provided.
If you have a reference that needs cleanup, make it implement Runnable and register it with the queue:
class MyReference extends WeakReferenceWhen theimplements Runnable { private final OtherInfo dataToCleanUp; public MyReference(Thing ref, OtherInfo data) { super(ref, Utilities.activeReferenceQueue()); dataToCleanUp = data; } public void run() { dataToCleanUp.releaseOrWhateverYouNeed(); } }
ref
object is garbage collected, your run method
will be invoked by calling
((Runnable) reference).run()
and you can perform whatever cleanup is necessary. Be sure not to block
in such cleanup for a long time as this prevents other waiting references
from cleaning themselves up.
Do not call any ReferenceQueue
methods. They
will throw exceptions. You may only enqueue a reference.
Be sure to call this method anew for each reference. Do not attempt to cache the return value.
public static int getOperatingSystem()
OS_*
constants (such as Utilities.OS_WINNT
)public static boolean isWindows()
true
if Windows, false
if some other manner of operating systempublic static boolean isMac()
true
if Mac, false
if some other manner of operating systempublic static boolean isUnix()
true
some sort of Unix, false
if some other manner of operating systempublic static boolean isJavaIdentifier(String id)
id
- string which should be checkedtrue
if a valid identifierSourceVersion#isIdentifier
,
SourceVersion#isKeyword
public static BeanInfo getBeanInfo(Class<?> clazz) throws IntrospectionException
BeanInfo
for potential JavaBean classes.clazz
- class of the bean to provide the BeanInfo
forIntrospectionException
- for the usual reasonsIntrospector.getBeanInfo(Class)
public static BeanInfo getBeanInfo(Class<?> clazz, Class<?> stopClass) throws IntrospectionException
BeanInfo
for potential JavaBean classes, with a stop class.clazz
- class of the bean to provide the BeanInfo
forstopClass
- the stop classIntrospectionException
- for the usual reasonsIntrospector.getBeanInfo(Class, Class)
@Deprecated public static String[] wrapStringToArray(String original, int width, boolean wrapWords, boolean removeNewLines)
Utilities.wrapStringToArray(String, int, BreakIterator, boolean)
since it is better for I18Noriginal
- the original string to wrapwidth
- the maximum width of lineswrapWords
- if true
, the lines are wrapped on word boundaries (if possible);
if false
, character boundaries are usedremoveNewLines
- if true
, any newlines in the original string are ignoredpublic static String[] wrapStringToArray(String original, int width, BreakIterator breakIterator, boolean removeNewLines)
original
- the original string to wrapwidth
- the maximum width of linesbreakIterator
- breaks original to chars, words, sentences, depending on what instance you provide.removeNewLines
- if true
, any newlines in the original string are ignoredpublic static String wrapString(String original, int width, BreakIterator breakIterator, boolean removeNewLines)
original
- the original string to wrapwidth
- the maximum width of linesbreakIterator
- algorithm for breaking linesremoveNewLines
- if true
, any newlines in the original string are ignored@Deprecated public static String wrapString(String original, int width, boolean wrapWords, boolean removeNewLines)
(String, int, BreakIterator, boolean)
as it is friendlier to I18N.original
- the original string to wrapwidth
- the maximum width of lineswrapWords
- if true
, the lines are wrapped on word boundaries (if possible);
if false
, character boundaries are usedremoveNewLines
- if true
, any newlines in the original string are ignored@Deprecated public static String replaceString(String original, String replaceFrom, String replaceTo)
String.replace(CharSequence,CharSequence)
insteadoriginal
- the original stringreplaceFrom
- the substring to be findreplaceTo
- the substring to replace it withpublic static String pureClassName(String fullName)
fullName
- e.g. some.pkg.SomeClass$Inner
Inner
@Deprecated public static boolean isLargeFrameIcons()
true
if it does not@Deprecated public static int arrayHashCode(Object[] arr)
Arrays.hashCode(Object[])
instead.arr
- array of objects, can contain null
sObject.hashCode()
public static boolean compareObjects(Object o1, Object o2)
null
Object.equals(java.lang.Object)
null
-safe, so if one of the parameters is true and the second not,
it returns false
.
Use java.util.Objects.deepEquals
in JDK 7.
o1
- the first object to compareo2
- the second object to comparetrue
if the objects are equalpublic static boolean compareObjectsImpl(Object o1, Object o2, int checkArraysDepth)
Use java.util.Objects.deepEquals
in JDK 7.
o1
- the first object to compareo2
- the second object to comparecheckArraysDepth
- the depth to which arrays should be compared for equality (negative for infinite depth, zero for no comparison of elements, one for shallow, etc.)true
if the objects are equalUtilities.compareObjects(Object, Object)
public static String getClassName(Class<?> clazz)
java.lang.String[]
.clazz
- the class to namepublic static String getShortClassName(Class<?> clazz)
String[]
.clazz
- the class to namepublic static Object toPrimitiveArray(Object[] array)
Integer[]
would be changed to an int[]
.array
- the wrapper arrayIllegalArgumentException
- if the array element type is not a primitive wrapperpublic static Object[] toObjectArray(Object array)
int[]
would be turned into an Integer[]
.array
- the primitive arrayIllegalArgumentException
- if the array element type is not primitivepublic static Class<?> getObjectType(Class<?> c)
c
- primitive type (e.g. int
)Integer
)public static Class<?> getPrimitiveType(Class<?> c)
c
- object type (e.g. Integer
)int
)public static Component getFocusTraversableComponent(Component c)
c
- the component to look innull
Component.isFocusTraversable()
public static String[] parseParameters(String s)
org.openide.execution.NbProcessDescriptor
(Execution API)
you should be able to:
c:\Program Files\jdk\bin\javac
.
-Dname=value
.
"c:\program files\jdk\bin\java" -Dmessage="Hello /\\/\\ there!" -Xmx128m
This example would create the following executable name and arguments:
c:\program files\jdk\bin\java
-Dmessage=Hello /\/\ there!
-Xmx128m
s
- a string to parsepublic static String escapeParameters(String[] params)
public static String keyToString(KeyStroke stroke)
stroke
- key descriptionCS-F1
for control-shift-function key one)Utilities.stringToKey(java.lang.String)
public static String keyToString(KeyStroke stroke, boolean portable)
Meta-C
on Mac => D-C
stroke
- key descriptionCS-F1
for control-shift-function key one)Utilities.stringToKey(java.lang.String)
public static KeyStroke stringToKey(String s)
KeyStroke
object used in Swing.
This format has following form:
[C][A][S][M]-identifier
Where:
C
stands for the Control key
A
stands for the Alt key
S
stands for the Shift key
M
stands for the Meta key
D
stands for the default menu accelerator - the Control
key on most platforms, the Command (meta) key on MacintoshO
stands for the alternate accelerator - the Alt key on
most platforms, the Ctrl key on Macintosh (Macintosh uses Alt as a
secondary shift key for composing international characters - if you bind
Alt-8 to an action, a mac user with a French keyboard will not be able
to type the [
character, which is a significant handicapD-Q
will always map to Control-Q.
Every modifier before the hyphen must be pressed.
identifier can be any text constant from KeyEvent
but
without the leading VK_
characters. So KeyEvent.VK_ENTER
is described as
ENTER
.
s
- the string with the description of the keynull
if the string does not represent any valid keypublic static KeyStroke[] stringToKeys(String s)
s
- the string with keysnull
if the string description is not validUtilities.stringToKey(java.lang.String)
public static Rectangle getUsableScreenBounds()
public static Rectangle getUsableScreenBounds(GraphicsConfiguration gconf)
gconf
- the GraphicsConfiguration of the monitorpublic static Rectangle findCenterBounds(Dimension componentSize)
componentSize
- the size of the component@Deprecated public static Dimension getScreenSize()
Utilities.getUsableScreenBounds()
,
Utilities.findCenterBounds(Dimension)
@Deprecated public static int showJFileChooser(JFileChooser chooser, Component parent, String approveButtonText)
parent
- approveButtonText
- FileChooserBuilder
@Deprecated public static List partialSort(List l, Comparator c, boolean stable) throws Utilities.UnorderableException
Utilities.topologicalSort(java.util.Collection<? extends T>, java.util.Map<? super T, ? extends java.util.Collection<? extends T>>)
.l
- the list to sort (will not be modified)c
- a comparator to impose the partial order; "equal" means that the elements
are not ordered with respect to one another, i.e. may be only a partial orderstable
- whether to attempt a stable sort, meaning that the position of elements
will be disturbed as little as possible; might be slightly slowerUtilities.UnorderableException
- if the specified partial order is inconsistent on this listpublic static <T> List<T> topologicalSort(Collection<? extends T> c, Map<? super T,? extends Collection<? extends T>> edges) throws TopologicalSortException
There may not be any nulls among the objects, nor duplicates (as per hash/equals), nor duplicates among the edge lists. The edge map need not contain an entry for every object, only if it has some outgoing edges (empty but not null map values are permitted). The edge map shall not contain neither keys nor value entries for objects not in the collection to be sorted, if that happens they will be ignored (since version 7.9).
The incoming parameters will not be modified; they must not be changed during the call and possible calls to TopologicalSortException methods. The returned list will support modifications.
There is a weak stability guarantee: if there are no edges which contradict the incoming order, the resulting list will be in the same order as the incoming elements. However if some elements need to be rearranged, it is not guaranteed that others will not also be rearranged, even if they did not strictly speaking need to be.
c
- a collection of objects to be topologically sortededges
- constraints among those objects, of type Map<Object,Collection>
;
if an object is a key in this map, the resulting order will
have that object before any objects listed in the valueTopologicalSortException
- if the sort cannot succeed due to cycles in the graph, the
exception contains additional information to describe and possibly recover from the errorpublic static String translate(String className)
Class.forName
, NbObjectInputStream
, etc.) or filenames
in layers.
Often class names (especially package names) changes during lifecycle
of a module. When some piece of the system stores the name of a class
in certain point of a time and wants to find the correct Class
later it needs to count with the possibility of rename.
For such purposes this method has been created. It allows modules to register their classes that changed names and other parts of system that deal with class names to find the correct names.
To register a mapping from old class names to new ones create a file
META-INF/netbeans/translate.names
in your module and fill it
with your mapping:
# # Mapping of legacy classes to new ones # org.oldpackage.MyClass=org.newpackage.MyClass # rename of package for one class org.mypackage.OldClass=org.mypackage.NewClass # rename of class in a package # rename of class and package org.oldpackage.OldClass=org.newpackage.NewClass # rename of whole package org.someoldpackage=org.my.new.package.structure # class was removed without replacement org.mypackage.OldClass=Btw. one can use spaces instead of
=
sign.
For a real world example
check the
xml module.
For purposes of org.openide.util.io.NbObjectInputStream there is a following special convention: If the className is not listed as one that is to be renamed, the returned string == className, if the className is registered to be renamed than the className != returned value, even in a case when className.equals (retValue)
Similar behaviour applies to filenames provided by layers (system filesystem). Filenames can be also translated to adapt to location changes e.g. in action registrations. Note that no spaces or special characters are allowed in both translated filenames or translation results. Filenames must conform to regexp^[/a-zA-Z0-9$_.+-]+$
. Keys and values are treated
as paths from fs root.
Example of file path translation (action registration file has moved):
# registration ID has changed Actions/Refactoring/RefactoringWhereUsed.instance=Actions/Refactoring/org-netbeans-modules-refactoring-api-ui-WhereUsedAction.instance
className
- fully qualified name of a class, or file path to translate@Deprecated public static Image mergeImages(Image image1, Image image2, int x, int y)
ImageUtilities.mergeImages(java.awt.Image, java.awt.Image, int, int)
.image1
- underlying imageimage2
- second imagex
- x position of top-left cornery
- y position of top-left corner@Deprecated public static Image loadImage(String resourceID)
ImageUtilities.loadImage(java.lang.String)
.resourceID
- resource path of the icon (no initial slash)@Deprecated public static Image icon2Image(Icon icon)
ImageUtilities.icon2Image(javax.swing.Icon)
.Image
.icon
- Icon
to be converted.public static JPopupMenu actionsToPopup(Action[] actions, Lookup context)
Lookup
.
Takes list of actions and for actions whic are instances of
ContextAwareAction
creates and uses the context aware instance.
Then gets the action presenter or simple menu item for the action to the
popup menu for each action (or separator for each 'lonely' null array member).actions
- array of actions to build menu for. Can contain null
elements, they will be replaced by separatorscontext
- the context for which the popup is buildContextAwareAction
public static JPopupMenu actionsToPopup(Action[] actions, Component component)
Lookup.Provider
instance).
If none of the components is Lookup.Provider
instance, then
it is created context which is fed with composite ActionMap which delegates
to all components up to hierarchy started from the specified one.
Then actionsToPopup(Action[], Lookup)
} is called with
the found Lookup
instance, which actually creates a popup menu.actions
- array of actions to build menu for. Can contain null
elements, they will be replaced by separatorscomponent
- a component in which to search for a contextLookup.Provider
,
Utilities.actionsToPopup(Action[], Lookup)
public static List<? extends Action> actionsForPath(String path)
Action
instances are returned as is;
any JSeparator
instances are translated to nulls.
Warnings are logged for any other instances.path
- a path as given to Lookups.forPath(java.lang.String)
, generally a layer folder namepublic static Lookup actionsGlobalContext()
ContextAwareAction
.ContextGlobalProvider
,
ContextAwareAction
,
NetBeans FAQ@Deprecated public static Image loadImage(String resource, boolean localized)
ImageUtilities.loadImage(java.lang.String, boolean)
.Utilities.loadImage(String)
but may do a localized search.
For example, requesting org/netbeans/modules/foo/resources/foo.gif
might actually find org/netbeans/modules/foo/resources/foo_ja.gif
or org/netbeans/modules/foo/resources/foo_mybranding.gif.
Caching of loaded images can be used internally to improve performance.
public static Cursor createProgressCursor(Component component)
Cursor.WAIT_CURSOR
, but has an arrow to indicate
a still-responsive UI.
Typically you will set the cursor only temporarily:
// code is running in other then event dispatch thread currentComponent.setCursor(Utilities.createProgressCursor(currentComponent)); try { // perform some work in other than event dispatch thread // (do not block UI) } finally { currentComponent.setCursor(null); }
This implementation provides one cursor for all Mac systems, one for all Unix systems (regardless of window manager), and one for all other systems including Windows. Note: The cursor does not have to look native in some cases on some platforms!
component
- the non-null component that will use the progress cursorpublic static Cursor createCustomCursor(Component component, Image icon, String name)
public static void attachInitJob(Component comp4Init, AsyncGUIJob initJob)
AsyncGUIJob.construct()
will be called after first
paint, when paint event arrives. Later, AsyncGUIJob.finished()
will be called according to the rules of the AsyncGUIJob
interface.
Useful for components that have slower initialization phase, component
can benefit from more responsive behaviour during init.comp4Init
- Regular component in its pre-inited state, state in which
component will be shown between first paint and init completion.initJob
- Initialization job to be called asynchronously. Job can
optionally implement Cancellable
interface for proper cancel logic. Cancel method will be called
when component stops to be showing during job's progress.
See Component.isShowing()
public static URI toURI(File f)
f
.toPath
().toUri
()
which results into URI
that works with URI.normalize()
and URI.resolve(URI)
.f
- a filefile
-protocol URI which may use the host fieldPath.toUri
public static File toFile(URI u) throws IllegalArgumentException
Paths.get
(u).toFile
()
which accepts UNC URIs with a host field.u
- a file
-protocol URI which may use the host fieldIllegalArgumentException
java.nio.file.Paths.get(java.net.URI)
@Deprecated public static URL toURL(File f) throws MalformedURLException
Utilities.toURI(java.io.File)
and URI.toURL()
instead under JDK 1.4.
(File.toURL()
is buggy in JDK 1.3 and the bugs are not fixed in JDK 1.4.)file:
URL.f
- a file (absolute only)file
protocolMalformedURLException
- for no good reasonUtilities.toFile(java.net.URI)
,
Issue #29711@Deprecated public static File toFile(URL u)
URL.toURI()
and Utilities.toFile(URI)
instead under JDK 1.4.
(There was no proper equivalent under JDK 1.3.)file:
URL to a matching file.
You may not use a URL generated from a file on a different platform, as file name conventions may make the result meaningless or even unparsable.
u
- a URL with the file
protocolnull
if the URL
does not seem to point to a file at allUtilities.toURL(java.io.File)
,
Issue #29711public static void disabledActionBeep()