<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>www.jugpadova.it: Tag desktop</title>
    <link>http://www.jugpadova.it/articles/tag/desktop</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Java User Group [Padova]</description>
    <item>
      <title>Mustang SplashScreen</title>
      <description>&lt;p&gt;&lt;a href="https://mustang.dev.java.net/"&gt;Mustang&lt;/a&gt; will be the next release of the Java Standard Edition (Java SE 6). At present Mustang is in beta, it will be delivered in &lt;a href="http://weblogs.java.net/blog/ray_gans/archive/2006/01/where_we_are_wi.html"&gt;Autumn 2006&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;One of the new &lt;a href="http://java.sun.com/developer/technicalArticles/J2SE/Desktop/mustang/index.html"&gt;desktop features&lt;/a&gt;
of Mustang is the capability of showing a splash screen even before the starting of the Java Virtual Machine.&lt;/p&gt;

&lt;p&gt;You can configure the splash screen by command line:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;java -splash:mysplash.gif MyApplication&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&amp;#8230;or, if your application is packaged in a JAR file, using the &lt;em&gt;SplashScreen-Image&lt;/em&gt; option in the manifest file:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;Manifest-Version: 1.0
Main-Class: MyApplication
SplashScreen-Image: mysplash.gif&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;For testing this new cool feature of Mustang, I wrote a small example, with some supporting classes. For trying it you can download the Splasher.jar file from &lt;a href="http://www.snipurl.com/bencode"&gt;here&lt;/a&gt;. Execute it using:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;java -jar Splasher.jar&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&amp;#8230;of course you have to download and install &lt;a href="https://mustang.dev.java.net/"&gt;Mustang&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;After the launch of the JVM the application can control and even drawing on the splash screen, retriving the SplashScreen object:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;SplashScreen splash = SplashScreen.getSplashScreen();
Graphics2D g = (Graphics2D)splash.getGraphics();
Rectangle r = splash.getBounds();
FontMetrics fm = g.getFontMetrics();
// drawing a message at the bottom of the splash screen
g.drawString(&amp;quot;Welcome!&amp;quot;,
            1, (int)r.getHeight()-1-fm.getDescent());
splash.update();&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You can dismiss the splash screen using the close() method:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;splash.close();&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This call is usually not needed as the splash screen will be &lt;strong&gt;automatically&lt;/strong&gt; closed when the first window of the application will be made visible.&lt;/p&gt;

&lt;p&gt;Some useful links:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://download.java.net/jdk6/docs/api/java/awt/SplashScreen.html"&gt;SplashScreen javadoc&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java.sun.com/developer/JDCTechTips/2005/tt1115.html"&gt;A JDC TechTip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java.sun.com/developer/technicalArticles/J2SE/Desktop/mustang/splashscreen/"&gt;An SDN article&lt;/a&gt; (little outdated, but still good)&lt;/li&gt;
&lt;/ul&gt;</description>
      <pubDate>Sat, 01 Apr 2006 09:45:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:8f4a2b91-9de9-448e-8dcc-c068905c686c</guid>
      <author>Lucio Benfante</author>
      <link>http://www.jugpadova.it/articles/2006/04/01/mustang-splashscreen</link>
      <category>Tips &amp; Tricks</category>
      <category>Mustang</category>
      <category>desktop</category>
      <category>splash screen</category>
    </item>
  </channel>
</rss>
