Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / October 2004

Tip: Looking for answers? Try searching our database.

Acrobat-like splashscreen in Java on LINUX ?

Thread view: 
FET - 04 Oct 2004 07:50 GMT
Hi everyone,
I would like to build an irregular shaped splash screen on Linux using
JDK 1.4.2
I understand that the only way to currently do this by taking a
screenshot of the underlying desktop and painting my splash image over
it.
Is there any other way to do it on Linux ? I have looked at the SKinLF
but it doesn't have native code for X11.
If not, then how do I go about taking a screenshot of the underlying
desktop programatically ?
Thanks in advance.

Best regards.
Antti S. Brax - 04 Oct 2004 08:19 GMT
bilaribilari@yahoo.com wrote in comp.lang.java.gui:
> I would like to build an irregular shaped splash screen on Linux using
> JDK 1.4.2
> I understand that the only way to currently do this by taking a
> screenshot of the underlying desktop and painting my splash image over
> it.

    Does this bring any added value to your program or is it just
    a gimmick? Consider the effort that you are going to spend in
    this feature and how much value it will bring. How much extra
    code (and maintenance cost) will this add to your codebase?

    Does the startup of your program take so long that a splash
    screen is required? Are you making a splash screen just because
    "they are cool and everyone has them?"

    Can you make your program start faster so that you won't need
    a splash screen at all (perhaps you can use lazy initialization)?

    Simply put: don't do it. It's not worth the hassle.

Signature

Antti S. Brax                  Rullalautailu pitää lapset poissa ladulta
http://www.iki.fi/asb/         http://www.cs.helsinki.fi/u/abrax/hlb/
       "Disconnect this cable to shorten, re-connect to lengthen."
         -- Instructions on Logitech's USB mouse extension cord.

Jacob - 04 Oct 2004 08:21 GMT
> If not, then how do I go about taking a screenshot of the underlying
> desktop programatically ?

BufferedImage screenCapture = (new Robot()).createScreenCapture (new
Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
Tor Iver Wilhelmsen - 04 Oct 2004 08:19 GMT
> BufferedImage screenCapture = (new Robot()).createScreenCapture (new
> Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));

It would probably be better to capture just the rectangle that the
irregularly shaped splash screen spans.
Elp - 04 Oct 2004 14:48 GMT
> Hi everyone,
> I would like to build an irregular shaped splash screen on Linux using
> JDK 1.4.2
> I understand that the only way to currently do this by taking a
> screenshot of the underlying desktop and painting my splash image over
> it.

That doesn't seem to be a great idea to me unless your splash screen is only
displayed for half a second or so (but in this case, why would you need a
splash screen?). If the splash is displayed several seconds, there are good
chance that the user will do something else while your app is starting,
which means that the underlying desktop will change while your splash will
still display the old desktop state. That's enough for the user to think
that your program is buggy.
FET - 05 Oct 2004 04:42 GMT
Hi all,
I figured it out myself. Here is the code if anyone may need it in the
future.

package mypackage;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JWindow;

public class TransparentSplash extends JPanel
{
   BufferedImage img = null;
   JLabel lblImage = null ;
   JWindow wind = new JWindow ( (Frame)null );
   
   public TransparentSplash ( String strSplashImageFile, int iWidth,
int iHeight ) throws Exception
   {
       setLayout ( new GridLayout ( 1,1 ) );
       setOpaque ( false );
       Robot rob = new Robot ( );
       
       Dimension screenSize = Toolkit.getDefaultToolkit (
).getScreenSize ( ) ;
       Dimension frameSize = new Dimension ( iWidth , iHeight ) ;
       if ( frameSize.height > screenSize.height )
       {
           frameSize.height = screenSize.height;
       }
       if ( frameSize.width > screenSize.width )
       {
           frameSize.width = screenSize.width;
       }
       int iX = ( screenSize.width - frameSize.width ) / 2 ;
       int iY = ( screenSize.height - frameSize.height ) / 2 ;
       
       img = rob.createScreenCapture ( new Rectangle ( iX , iY ,
iWidth , iHeight ) );
       
       lblImage = new JLabel ( new ImageIcon ( strSplashImageFile )
);
       lblImage.setOpaque ( false ) ;
       add ( lblImage );
       
       wind.setContentPane ( this );
       wind.setBounds(iX,iY,iWidth,iHeight);
       
       wind.addMouseListener( new MouseAdapter () {
           public void mouseClicked ( MouseEvent me )
           {
               wind.dispose();
               System.exit ( 0 );
           }
       });
       
       wind.setVisible(true);
   }
   
   public void paintComponent ( Graphics g )
   {
       g.drawImage ( img , 0 , 0 , getWidth ( ) , getHeight ( ) ,
this ) ;
       super.paintComponent ( g ) ;
   }

   /**
    *
    * @param args
    */
   public static void main(String[] args) throws Exception
   {
       TransparentSplash transparentSplash = new
TransparentSplash("/tmp/key.png", 600, 400);//this is a transparent
GIF which is the background of the spash screen
   }
}


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.