Open In App

Java AWT | Desktop Class

The Desktop class is a part of Java AWT package. This class is used to launch associated applications registered on the native desktop to handle a URI or a file.

Important Points About Desktop Class :



Different Methods in Desktop Class

Method Explanation
browse(URI u) Launches the default browser to display a specific URI.
edit(File f) Launches the associated editor application and opens a file.
getDesktop() Returns the Desktop instance of the current browser context.
isDesktopSupported() returns whether this class is supported on the current platform.
isSupported(Desktop.Action action) returns whether an action is supported on the current platform.
mail() Launches the mail composing window of the user default mail client.
mail(URI mailtoURI) Launches the mail composing window of the user default mail client, filling the message fields specified by a mailto: URI.
open(File f) Launches the associated application to open the file
print(File f) Prints a file with the native desktop printing facility, using the associated application’s print command.

Below programs illustrate the Desktop class in Java AWT:



Reference: https://docs.oracle.com/javase/7/docs/api/java/awt/Desktop.html


Article Tags :