Package org.pepsoft.util
Class DesktopUtils
java.lang.Object
org.pepsoft.util.DesktopUtils
Utility methods for integrating into desktop environments. These methods do
very little error checking and assume they are running on a modern OS with a
supported desktop environment. If not, all manner of exceptions may be
thrown.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intTheinput eventmask that corresponds to this platform's default modifier key(s) for command keyboard shortcuts. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidbeep()Sound a beep, bell or other kind of audible alert, if supported by the desktop system.static voidcopyToClipboard(String text) Copy a string of text to the default system clipboard.static FileGet the default documents folder of the current user.static FileGet the default images folder of the current user.static voidstatic booleanOpen a file in the associated application, or a directory in the default file manager.static booleanOpen a URL in the default browser.static voidsetProgress(Window window, int percentage) Indicates the progress of an operation in the form of a progress bar on the task bar for supported systems; does nothing on unsupported systems.static voidsetProgressDone(Window window) Indicates that progress should no longer be displayed on the task bar for supported systems; does nothing on unsupported systems.static voidsetProgressError(Window window) Indicates that an operation for which progress was being displayed on the task bar for supported systems has failed, for example by turning the progress bar red; does nothing on unsupported systems.
-
Field Details
-
PLATFORM_COMMAND_MASK
public static final int PLATFORM_COMMAND_MASKTheinput eventmask that corresponds to this platform's default modifier key(s) for command keyboard shortcuts.
-
-
Method Details
-
open
Open a file in the associated application, or a directory in the default file manager.- Parameters:
file- The file or directory to open.- Returns:
trueif the file or directory was successfully opened.
-
getDocumentsFolder
Get the default documents folder of the current user.- Returns:
- The default documents folder of the current user, or the user's home directory if a documents folder could not be determined.
-
getPicturesFolder
Get the default images folder of the current user.- Returns:
- The default images folder of the current user, or the user's documents folder if an images folder could not be determined.
-
open
Open a URL in the default browser.- Parameters:
url- The URL to open.- Returns:
trueif the URL was successfully opened.
-
copyToClipboard
Copy a string of text to the default system clipboard.- Parameters:
text- The text to copy to the clipboard.
-
setProgress
Indicates the progress of an operation in the form of a progress bar on the task bar for supported systems; does nothing on unsupported systems.Once the operation has finished
setProgressDone(Window)must always be invoked to clear the progress display from the task bar.- Parameters:
window- The window of which to use the task bar icon to display the progress.percentage- The progress to display out of 100.
-
setProgressDone
Indicates that progress should no longer be displayed on the task bar for supported systems; does nothing on unsupported systems.- Parameters:
window- The window of which the task bar icon was being used to display progress.
-
setProgressError
Indicates that an operation for which progress was being displayed on the task bar for supported systems has failed, for example by turning the progress bar red; does nothing on unsupported systems.Once the operation has finished
setProgressDone(Window)must always be invoked to clear the progress error state from the task bar.- Parameters:
window- The window of which the task bar icon was being used to display progress.
-
beep
public static void beep()Sound a beep, bell or other kind of audible alert, if supported by the desktop system. -
main
- Throws:
MalformedURLException
-