<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title>Artem Ananiev&apos;s Blog</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/ixmal/" />
<modified>2008-06-11T09:24:13Z</modified>
<tagline></tagline>
<id>tag:weblogs.java.net,2008:/blog/ixmal/316</id>
<generator url="http://www.movabletype.org/" version="3.01D">Movable Type</generator>
<copyright>Copyright (c) 2008, ixmal</copyright>
<entry>
<title>Using JWebPane: common scenarios</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/ixmal/archive/2008/06/using_jwebpane_1.html" />
<modified>2008-06-11T09:24:13Z</modified>
<issued>2008-06-11T09:24:07Z</issued>
<id>tag:weblogs.java.net,2008:/blog/ixmal/316.9953</id>
<created>2008-06-11T09:24:07Z</created>
<summary type="text/plain">Moving on with JWebPane. Let&apos;s examine some basic things developers can do with this component.</summary>
<author>
<name>ixmal</name>

<email>Artem.Ananiev@Sun.COM</email>
</author>
<dc:subject>Community: JavaDesktop</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/ixmal/">
<![CDATA[In the last blog posting I introduced a new component called JWebPane that renders HTML content in Java applications. Today I'd like to discuss the details of the practical use of this component. Let me start with typical use cases.<br>
<br>

<h4>1. HTML Rendering</h4>
Since the necessity of employing this component in GUI applications appeared a long time ago, each solution, even simple rendering of web pages, is greatly appreciated. Moreover, in spite of the fact that the importance of interactivity is rising steeply, the correct rendering of up-to-date web content still remains a crucial requirement for an HTML component. It's worth mentioning that JWebPane copes with this task successfully along with the help of WebKit, one of the most advanced web engines.<br>
<br>

<h4>2. Load event notifications</h4>
Let's move on to more interesting items. The load control of web pages and its resources is another highly demanded function required by many users. For this purpose JWebPane provides the following events: page loading start, external resource loading start, loading progress, loading stop or error, page loading finish, and resources loading finish. The exact set of events is not finalized yet, and new event types will appear soon.<br>
<br>

<h4>3. Navigation</h4>
Sometimes using the HTML component is limited to one document, however, the HTML format itself implies tie-up and cross linking of documents. Navigation control, such as Back, Forward, Get URL and other commands, is naturally provided by JWebPane. The navigation function is closely related to transfers from one page to another. This is quite a controversial point: on the one hand, the application should maintain the history, but on the other hand, the component possesses information about which web sites were visited during the current session. That's why JWebPane provides the basic tools for history maintenance as well as the ability to retrieve history from the application.<br>
<br>

<h4>4. Chrome</h4>
I always wondered where did the "chrome" term come from :-) This term is used to specify the HTML component environment, which is usually a browser window. Chrome typically includes support of the following elements: status bar, window title and icon, tooltips, window size, the component itself, and others. JWebPane, as an HTML component, doesn't have built-in support of these controls, however, it provides an API to implement those in the application.<br>
<br>

<h4>5. What next?</h4>
Undoubtedly, the list of the JWebPane features is incomplete. I'm going to tell you more about the coolest ones, for example, how to create new windows or how to work with JavaScript. Additionally, we would like developers that are ready to use JWebPane share their ideas and visions. After all, they indeed define what kind of features should the convenient and handy HTML component have. Don't they?<br>
<br>
]]>

</content>
</entry>
<entry>
<title>Introducing JWebPane component</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/ixmal/archive/2008/05/introducing_jwe_1.html" />
<modified>2008-06-04T16:56:49Z</modified>
<issued>2008-05-29T10:26:45Z</issued>
<id>tag:weblogs.java.net,2008:/blog/ixmal/316.9887</id>
<created>2008-05-29T10:26:45Z</created>
<summary type="text/plain">One of the technical sessions at JavaOne 2008 was about two important parts of JavaFX: Scenario and HTML component aka JWebPane. Let&apos;s look at JWebPane component a bit closer.</summary>
<author>
<name>ixmal</name>

<email>Artem.Ananiev@Sun.COM</email>
</author>
<dc:subject>Community: JavaDesktop</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/ixmal/">
<![CDATA[Recently, at the JavaOne conference, Sun has introduced several new JavaFX related  technologies and products.  The Scene Graph and WebKit session was one of the technical sessions to present such advanced technologies:<br>
<br>

<a href="http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-6610.pdf">Inside The JavaFX™ Script Technology-Based Runtime APIs: Scene Graph & JWebPane Component</a><br>
<br>

This blog entry opens a series of articles about the technology described in the second part of the presentation - HTML component JWebPane. I'm set to explain what is it, when it could be employed in your application and when it couldn't be. :)<br>
<br>

For many years,  Java lacked a worthy component to render HTML content. HTML support in Swing was limited to the 3.2 version. Although the SwingLabs JDIC library provides a browsing component, it is hard to integrate into Swing applications because of its heavyweight implementation. The new component - JWebPane is not intended to substitute all known alternatives, however, it brings HTML support and easiness of use up to the high-level standard.<br>
<br>

Those who attended the JavaOne session already know that JWebPane is based on the widely recognized open sourced engine - WebKit. It is not a secret any more. :) The WebKit architecture consists of two considerable parts. The first one is cross-platform, it is responsible for parsing documents, generating DOM, supporting JavaScript. Another part, platform-dependent, so called "port", is intended for communicating with network, rendering graphic content on the screen and other devices, event handling, and other features. JWebPane is a Java port, in which all cross-platform calls are implemented in Java.<br>
<br>

Additionally, each port provides an API to develop browsing functionality using a particular library. For Java port, it is non surprisingly JavaFX. Moreover, JWebPane will became available in Swing applications. At the moment the API provides the following capabilities: adding the JWebPane component to the hierarchy of graphic components, documents loading control, handling the loading status events, navigation history support, and new windows control (both adding and removing).  This API is supposed to be extended, if needed.<br>
<br>

Finally, I'd like to demonstrate a small screen shot of the JWebPane application with new Nimbus Look and Feel available in JDK 6u10:<br>
<br>

<center><img src="http://weblogs.java.net/blog/ixmal/archive/introducing_jwebpane/google_adsearch.png"  /></center><br>
<br>

Next time I'll expose some technical details of the Java-port implementation and its interaction with WebKit.<br>
<br>

Other blogs related to JWebPane:
<ul>
<li><a href="http://blogs.sun.com/thejavatutorials/entry/html_component">HTML component</a> at http://blogs.sun.com
</ul><br>
<br>]]>

</content>
</entry>
<entry>
<title>java.awt.TrayIcon: isSupported vs isAvailable</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/ixmal/archive/2006/11/javaawttrayicon.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2006-11-17T08:01:30Z</issued>
<id>tag:weblogs.java.net,2006:/blog/ixmal/316.5967</id>
<created>2006-11-17T08:01:30Z</created>
<summary type="text/plain">Another one improvement of java.awt.TrayIcon class: the ability to detect if the system tray is available at the given moment.</summary>
<author>
<name>ixmal</name>

<email>Artem.Ananiev@Sun.COM</email>
</author>
<dc:subject>Community: JavaDesktop</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/ixmal/">
<![CDATA[<h3>Description of the problem</h3>
<br>
When the <code>java.awt.SystemTray</code> class was first introduced in JDK 6.0, there was only one method to check if the system tray and tray icons can be used: <code>isSupported()</code>. The value returned by this method is constant for the given desktop/environment, for example, on Windows platform it always return <code>true</code>.<br>
<br>
Another thing that can help the developers with the system tray is <code>AWTException</code> thrown by <code>SystemTray.add(TrayIcon icon)</code> method. According to the JavaDoc for this method, this exception is thrown "if the desktop system tray is missing". One of the common cases when the system tray is missing is when the notification area applet is removed from the GNOME desktop manually by user.<br>
<br>
Recently I have faced another problem, on Windows. There are several projects that make possible to install a Java application as a Windows NT/2K/XP service. Some of such Java applications may interact with the user using <code>SystemTray</code> and <code>TrayIcon</code>s. Here the problem lies: Windows services may start before any user is logged in, so no taskbar and system tray are present.<br>
<br>
<h3>Introducing <code>isAvailable</code> method</h3>
<br>
Obviously, the <code>isSupported()</code> method is not enough. Developers should be able to detect not only whether Java supports the system tray on the given platform, but also whether the system tray is currently present and tray icons can be added into it.<br>
<br>
The most probable name for the new method will be <code>isAvailable</code>. Additionally, it may be useful to have another method in the <code>SystemTray</code> class that works the following way: if the system tray is available, adds the given tray icon into it, if not - waits until the tray becomes available and then adds the icon. <code>AWTException</code> is not required for this case.<br>
<br>
<h3>Introducing a new property</h3>
<br>
There is another problem to be resolved to make the using of tray icons easier. Consider an application like an instant messenger that is run as an icon in the system tray, without any other visible window. If the system tray is removed or made unavailable this application may lose some of its functionality.<br>
<br>
Alternatively, using a property that changes its value when the system tray becomes available/unavailable, enables an application to listen for that property change and behave correspondingly. For example, an application can show some toplevel window.<br>
<br>
There is already a property called 'trayIcons' in the <code>SystemTray</code> class. The new property will be accessible as a parameter of the <code>java.beans.PropertyChangeListener</code> interface instance by using the same methods: <code>addPropertyChangeListener</code> and <code>removePropertyChangeListener</code>.<br>
<br>]]>

</content>
</entry>
<entry>
<title>Improved top-level icons support in Mustang</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/ixmal/archive/2006/06/improved_toplev.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2006-06-16T14:37:01Z</issued>
<id>tag:weblogs.java.net,2006:/blog/ixmal/316.5031</id>
<created>2006-06-16T14:37:01Z</created>
<summary type="text/plain">Prior to Mustang developers could specify a single icon image for every Java frame. This image was then displayed in the frame&apos;s titlebar, in the system taskbar and other places. However, some of that places require images of different size, and this made the specified image be scaled so it looked very ugly. Now in Mustang you can set several images to represent frames&apos; and dialogs&apos; icons wherever it is required.</summary>
<author>
<name>ixmal</name>

<email>Artem.Ananiev@Sun.COM</email>
</author>
<dc:subject>Community: JavaDesktop</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/ixmal/">
<![CDATA[<h3>What's the problem?</h3><br>
In Java&trade; 2 SE 5.0 and previous releases a single method in <code>java.awt.Frame</code> class enables developers to specify an icon for the frame: <code>setIconImage(Image image)</code>. This image had an arbitrary size and it was scaled to represent frame's icon in a different locations.<br>
<br>
Let's assume that application is running on Windows platform. Icon that was set to the frame is used in several places: on the frame's title bar, on the button on the system taskbar, in the window list when switching to another application by pressing Alt-Tab. The taskbar icon usually has a 16x16 pixels size, the title bar icon size varies depending on the user settings, window list uses a 32x32 sized icons. Thus, if we specify an image of 16x16 pixels size, it will look fine in a taskbar and ugly when switching to another application. The 32x32 pixels image has the similiar problems.<br>
<br>
<h3>More icons</h3><br>
In the Mustang release the following new method is introduced to the <code>java.awt.Window</code> class: <code>setIconImages(List&lt;? extends Image&gt; icons)</code>. Using this method you can supply as many images as you need to represent window's icon.<br>
<br>
How does it work? Every time either the system or window manager needs an icon for Java window, it examines the list of specified images and searches for the image of the most appropriate size. Exact definition for this 'most appropriate' size is platform-dependent.<br>
<br>
<h3>Dialogs icons</h3><br>
You may have already noticed that the new method is added to the <code>java.awt.Window</code> class, not to the <code>java.awt.Frame</code> class. In particular, this fact means that you can now set an icon for Java dialogs as well as for frames. This feature is extremely important for parentless dialogs introduced in earlier Mustang builds.<br>
<br>
If no icon is set for a dialog, it inherits the icon from its parent window. If a parent is <code>null</code> - that means the dialog is parentless - the platform-default icon is used. If a parent is not-<code>null</code> and no icon was explicitly set for the dialog, then the icon is inherited from the parent window.<br>
<br>
<h3>When will this API be available?</h3><br>
The answer is: it is already available, since Mustang b85 build was released at the end of May. However, some minor improvements are planned for the next Mustang builds.<br>]]>

</content>
</entry>
<entry>
<title>java.awt.Desktop vs Runtime.exec()</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/ixmal/archive/2006/05/javaawtdesktop.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2006-05-11T00:19:27Z</issued>
<id>tag:weblogs.java.net,2006:/blog/ixmal/316.4689</id>
<created>2006-05-11T00:19:27Z</created>
<summary type="text/plain">There is a new class introduced in Mustang, java.awt.Desktop, which helps developers to better integrate their applications into native desktop. This blog briefly shows what new abilities are provided by this class.</summary>
<author>
<name>ixmal</name>

<email>Artem.Ananiev@Sun.COM</email>
</author>
<dc:subject>Community: JavaDesktop</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/ixmal/">
<![CDATA[<h3>Desktop API vs Runtime.exec()</h3><br>
I'm often asked why is that new class, <code>java.awt.Desktop</code>, is introduced. They state all the required actions can be performed with the call to one of <code>Runtime.exec()</code> methods:<br>
<pre>
    Desktop.getDesktop().open(new File(filename));
</pre>
is close to<br>
<pre>
    Runtime.getRuntime().exec("start " + filename);
</pre>
So I decided to write a couple of words about this issue to answer the most of such questions at once:)<br>
<br>
<h3>The difference is...</h3><br>
The problem with the "start" invocation is that it only works on  the Windows platform. It will fail on the Mac, Linux, and Solaris platforms.  With the Desktop API,  you can be guaranteed that it will start an application on all platforms.<br><br>
There are also lots of other handy features in the new API, such  as open, edit, print, and two special actions - browse and mail - that launch separate processes.<br><br>
See <a href="http://download.java.net/jdk6/docs/api/java/awt/Desktop.html"><code>java.awt.Desktop</code></a> JavaDoc for details.<br>]]>

</content>
</entry>
<entry>
<title>Using JPopupMenu in TrayIcon</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/ixmal/archive/2006/05/using_jpopupmen.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2006-05-04T13:23:24Z</issued>
<id>tag:weblogs.java.net,2006:/blog/ixmal/316.4649</id>
<created>2006-05-04T13:23:24Z</created>
<summary type="text/plain">Support of SystemTray and tray icons is introduced in Java SE 6.0 (aka Mustang). However, tray icons lack some useful features, and this blog covers one of them: ability to show Swing popup menu.</summary>
<author>
<name>ixmal</name>

<email>Artem.Ananiev@Sun.COM</email>
</author>
<dc:subject>Community: JavaDesktop</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/ixmal/">
<![CDATA[<h3>What's the problem?</h3><br>
Tray icons introduced in Mustang have several properties and methods corresponding to image for the icon, tooltip text, popup menu and ability to show some message to the user. Let's inspect the popup menu more closely.<br>
<br>
Popup menu used in tray icons must be an instance of <code>java.awt.PopupMenu</code>. This class represents a menu and allows to insert or delete simple menu items and separators. You cannot change its appearance or even provide an image for particular menu item.<br>
<br>
<h3>Use JPopupMenu instead</h3><br>
There is another class to create popup menus provided by Swing: <code>javax.swing.JPoupMenu</code>. As all Swing components this class can be customized in any way and makes use of the current Look&Feel. Here is a short illustrating example how it can be used:<br>
<br>
First, create a tray icon with a null popup since we're going to use our own one:<br><br>
<pre>
    TrayIcon trayIcon = new TrayIcon(someImage, "Tooltip", null);
</pre>
Then, create a custom JPopupMenu:<br><br>
<pre>
    JPopupMenu jpopup = new JPopupMenu();

    JMenuItem javaCupMI = new JMenuItem("Example", new ImageIcon("javacup.gif"));
    jpopup.add(javaCupMI);

    jpopup.addSeparator();

    JMenuItem exitMI = new JMenuItem("Exit");
    jpopup.add(exitMI);
</pre>
At last, show the popup menu when user clicks a right mouse button on the tray icon:<br><br>
<pre>
    trayIcon.addMouseListener(new MouseAdapter() {
        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                jpopup.setLocation(e.getX(), e.getY());
                jpopup.setInvoker(jpopup);
                jpopup.setVisible(true);
            }
        }
    });
</pre>
<br>
And enjoy the result:<br>
<center><img src="http://weblogs.java.net/blog/ixmal/jpopupmenu/ss.jpg" /></center>
<br>
<h3>Magic?</h3><br>
You may probably ask me: "What is that magic line 'jpopup.setInvoker(jpopup);' for?" The answer is not as simple as quiestion is, though.<br>
<br>
JavaDoc for <code>JPopupMenu.setInvoker()</code> method says that invoker is the component in which the popup menu menu is to be displayed. This property can be set to <code>null</code>, but it leads to popup menu to operate incorrectly.<br>
<br>
Setting popup's invoker to itself has some side-effect too. Usually, if you dispose all the windows in your application, Java exits automatically. If you show JPopupMenu with self invoker, it won't, so the only way to terminate the whole application is to call to <code>System.exit()</code>.<br>
<br>
Both of these issues are well known to Swing team and will be corrected before the Mustang final release. See <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6421284">6421284</a> and <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6400183">6400183</a> for details.<br>
<br>]]>

</content>
</entry>
<entry>
<title>Headless toolkit basics</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/ixmal/archive/2006/04/headless_toolki_1.html" />
<modified>2008-06-16T10:48:49Z</modified>
<issued>2006-04-04T18:15:06Z</issued>
<id>tag:weblogs.java.net,2006:/blog/ixmal/316.4440</id>
<created>2006-04-04T18:15:06Z</created>
<summary type="text/plain">A short overview of a special AWT toolkit called &apos;headless toolkit&apos; which can be used in a system with display and/or mouse and keyboard missing.</summary>
<author>
<name>ixmal</name>

<email>Artem.Ananiev@Sun.COM</email>
</author>
<dc:subject>Community: JavaDesktop</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/ixmal/">
<![CDATA[<h3>Toolkit</h3>
<code>java.awt.Toolkit</code> is an abstract superclass of all actual implementations of the Abstract Window Toolkit (AWT). Subclasses of <code>java.awt.Toolkit</code> are used to bind various components to particular native resources.<br>
<br>
You may have noticed that many of the methods in <code>java.awt.Toolkit</code>, <code>java.awt.GraphicsEnvironment</code> and other classes require the availability of display, keyboard and mouse. You may easily find such methods as they throw <code>java.awt.HeadlessException</code> in headless mode.<br>
<br>
What is that headless mode?<br>
<h3>Headless mode</h3>
Headless mode is a system configuration in which graphic adapter, keyboard or mouse are lacking. For example, mainframes or dedicated servers do not support a display, keyboard or mouse. On the other hand, such environments possess a substantial computing power, which can be used for the non-visual features realization.<br>
<br>
All the AWT components with the exception of <code>Canvas</code> and <code>Panel</code> can not be operated in Headless mode. These include: applets, buttons, checkboxes, choices, dialogs, file dialogs, frames, labels, lists, menus, menubars, popup menus, page and print dialogs, scrollbars, scrollpanes, text components, windows, and their descendants. Such heavyweight components require a native "peer" at the operating system level, which cannot be guaranteed on "headless" machines.<br>
<br>
Here is a brief list of what is available in Headless mode:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;* lightweight components: canvas, panels, Swing components (with the exception of JApplet, JDialog, JFrame and JWindow)<br>
&nbsp;&nbsp;&nbsp;&nbsp;* fonts and font metrics<br>
&nbsp;&nbsp;&nbsp;&nbsp;* colors<br>
&nbsp;&nbsp;&nbsp;&nbsp;* images<br>
&nbsp;&nbsp;&nbsp;&nbsp;* printing using <code>java.awt.PrintJob</code>, <code>java.awt.print.*</code> and <code>javax.print.*</code><br>
&nbsp;&nbsp;&nbsp;&nbsp;* audio beep<br>
<h3>Headless mode setup</h3>
To set up the Headless mode you should set the appropriate system property using <code>System.setProperty()</code> method. Property name is "java.awt.headless" and possible values are "true" or "false". Note, that this property shoult be set before the toolkit is initialized with <code>Toolkit.getDefaultToolkit()</code> method.<br>
<br>
To check up the availability of the Headless mode you should use <code>GraphicsEnvironment.isHeadless()</code> method. This method checks the "java.awt.headless" property: if it equals to "true", it is assumed that <code>java.awt.HeadlessException</code> will be thrown from all the methods that are dependent on a display, keyboard, or mouse. This method <strong>*does not check*</strong> hardware configuration of the system, so it is possible to run the application in the Headless mode on a usual desktop.<br>
<!--
<br>
<h3>Operating in the Headless mode</h3>
<strong>Canvas</strong><br>
<br>
Following code represents a blank rectangular area onto which we can paint. To create a new canvas component use <code>java.awt.Canvas</code> class:<br>
<pre>
    Canvas c = new Canvas()
    {
        public void paint(Graphics g)
        {
            Rectangle r = getBounds();
            g.drawLine(0, 0, r.width - 1, r.height - 1);
            g.drawLine(0, r.height - 1, r.width - 1, 0);
        }
    }
</pre>
<br>
<strong>Fonts</strong><br>
<br>
This code illustrates how to set font using Font class for drawing a text string. The Graphics object is used to render this string:<br>
<pre>
    public void paint(Graphics g)
    {
        g.setFont(new Font("Arial", Font.ITALIC, 12));
        g.drawString("Test", 32, 8);
    }
</pre>
<br>
<strong>Colors</strong><br>
<br>
This code shows how to set color with the specified red, green, and blue values for drawing a filled rectangle. The Graphics object is used to render this line:<br>
<pre>
    public void paint(Graphics g)
    {
        g.setColor(new Color(255, 127, 0));
        g.fillRect(0, 0, 32, 24);
    } 
</pre>
<br>
<strong>Images</strong><br>
<br>
In following example the read method of the javax.imageio.ImageIO class decodes the grapefruit.jpg file and returns a result as a Buffered Image:<br>
<pre>
    Image i = null;
    try
    {
        File f = new File("grapefruit.jpg");
        i = ImageIO.read(f);
    }
    catch (Exception z)
    {
        z.printStackTrace(System.err);
    }
</pre>
<br>
<strong>Printing</strong><br>
<br>
This code illustrates how print a prepared canvas enabling to define the printer as a default surface for the paint method:<br>
<pre>
    PrinterJob pj = PrinterJob.getPrinterJob();
    pj.setPrintable(new Printable()
    {
        public int print(Graphics g, PageFormat pf, int pageIndex)
        {
            if (pageIndex > 0)
            {
                return Printable.NO_SUCH_PAGE;
            }
            ((Graphics2D)g).translate(pf.getImageableX(), pf.getImageableY());
            // paint canvas
            c.paint(g);
            return Printable.PAGE_EXISTS;
        }
    });
</pre>
-->
<h3>Example</h3>
All the capabilities described above are represented in the integrated HeadlessBasics example. There are some comments in the source code to better understang Headless mode basics.<br>
<br>
Compile the <a href="http://weblogs.java.net/blog/ixmal/headlessbasics/HeadlessBasics.java">source code</a> using javac compiler. Download <a href="http://weblogs.java.net/blog/ixmal/headlessbasics/grapefruit.jpg">grapefruit.jpg</a> image and put it to the directory where the HeadlessBasics class is located and then run the example with `java HeadlessBasics`. You can run it without any display, keyboard or mouse in the system, for example, using a remote console.
<br>]]>

</content>
</entry>

</feed>