java.awt
Class Desktop
This class enables Java application to access system commands to perform
desktop oriented operations, like writing and sending emails, or surfing
webpages with the system browser or editing/printing files with a default
editor. Methods are provided to handle these common operations, plus an
open
command selects a default registered application for the
specified file type. For example, opening an odf file results in launching
OpenOffice. If an operation is not supported, or the application fails to
launch, an exception is generated.
Implementation note: As this class is used to manage Desktop
integration, we provide some extension to configure the behaviour of this
class depending on the type of dektop that is detected.
First of all, we support 5 system properties that can be used to define
the application to launch in any given case. These properties are:
gnu.java.awt.peer.Desktop.html.command
gnu.java.awt.peer.Desktop.mail.command
gnu.java.awt.peer.Desktop.edit.command
gnu.java.awt.peer.Desktop.print.command
gnu.java.awt.peer.Desktop.open.command
These can be specified from the command line and have priority on every
other setting.
The second method supported is defining a Java preference.
The main preference node is a user node relative to the
class gnu.java.awt.peer.ClasspathDesktopPeer
. This node
contains a child for each supported operation. The key for each type is
always command
:
gnu.java.awt.peer.Desktop.html.command
gnu.java.awt.peer.Desktop.mail.command
gnu.java.awt.peer.Desktop.edit.command
gnu.java.awt.peer.Desktop.print.command
gnu.java.awt.peer.Desktop.open.command
The access to these keys is done with the Preference API or, if outside
of the java scope, is done in a backend dependent way. For example,
with the GConf backend, you can access these properties
with (may not be accurate on your system):
gconftool-2 -g /apps/classpath/gnu/java/awt/peer/Desktop/html/command
class | Desktop.Action - Represents an action type supported by a platform.
|
void | browse(URI uri) - Launches the Desktop default browser to open the given
uri .
|
void | edit(File file) - Launch the edit command to edit this file.
|
static Desktop | getDesktop() - Returns an instance of the Desktop Class.
|
static boolean | isDesktopSupported() - Check if this implementation supports Desktop.
|
boolean | isSupported(Desktop.Action action) - Check if the given Action is supported by this implementation.
|
void | mail() - Launches the Desktop default mailer.
|
void | mail(URI mailtoURI) - Launches the Desktop default mailer, with the given mailtoURI
as agrument.
|
void | open(File file) - Launches the Desktop default application to open the given File.
|
void | print(File file) - Launch the print program to print this file.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
browse
public void browse(URI uri)
throws IOException
Launches the Desktop default browser to open the given uri
.
If a security manager exists and denies
AWTPermission("showWindowWithoutWarningBanner"),a SecurityException will
be generated.
edit
public void edit(File file)
throws IOException
Launch the edit command to edit this file.
File should already exist before the editing starts.
If a security manager exists and
SecurityManager.checkRead(java.lang.String) method denies read access to
the file, or SecurityManager.checkPrintJobAccess() method denies the
permission to print the file, a SecurityException will be generated.
getDesktop
public static Desktop getDesktop()
throws UnsupportedOperationException,
HeadlessException
Returns an instance of the Desktop Class.
If this implementation does not support Desktop, an
UnsupportedOperationException will be thrown.
Also, an HeadlessException will be generated if
GraphicsEnvironment.isHeadless() returns true.
isDesktopSupported
public static boolean isDesktopSupported()
Check if this implementation supports Desktop.
If true, use getDesktop to get an instance of this class.
This implementation will return false when GraphicsEnvironment.isHeadless
returns true.
- true if this class is supported on the current platform;
false otherwise
mail
public void mail()
throws IOException
Launches the Desktop default mailer.
If a security manager exists and denies
AWTPermission("showWindowWithoutWarningBanner"), a SecurityException will
be generated.
mail
public void mail(URI mailtoURI)
throws IOException
Launches the Desktop default mailer, with the given mailtoURI
as agrument. The mailtoURI
must conform to the
The mailto URL scheme (RFC 2368)
If a security manager exists and denies
AWTPermission("showWindowWithoutWarningBanner"), a SecurityException will
be generated.
open
public void open(File file)
throws IOException
Launches the Desktop default application to open the given File.
If file
is a directory, a file manager is launched.
Desktop.java -- enable desktop integration between java programs and system
programs.
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.