Displaying a Splash Screen

Hi:
I have an application which takes sometime to load and decided to display a splash screen. The splash screen is a simple JFrame with a JPanel within. The splash screen is displaying but it�s not being painted at all. A grey box with the splash screen size is displayed.
Following is the code from where I�m calling both the splash screen and the application.
    private static void startApplication() {
        SplashScreen splashScreen = new SplashScreen();
        System.out.println("Loading...");
        splashScreen.setUndecorated(true);
        splashScreen.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        splashScreen.pack();
        splashScreen.setLocationRelativeTo(null);
        splashScreen.setVisible(true);
        try {
            Application application = new Application();
            splashScreen.setCompleted(0.2);
            System.out.println("Loading Database...");
            application.initDatabase();
            System.out.println("Loading of Database Complete...");
            splashScreen.setCompleted(0.5);
            application.initActions();
            splashScreen.setCompleted(0.6);
            application.initToolBar();
            splashScreen.setCompleted(0.7);
            application.initMenuBar();
            splashScreen.setCompleted(0.8);
            application.initComponents();
            splashScreen.setCompleted(0.9);
            application.setDefaultCloseOperation(Application.DISPOSE_ON_CLOSE);
            application.setTitle("Password Keeper");
            application.setUndecorated(false);
            application.pack();
            application.setLocationRelativeTo(null);
            splashScreen.setCompleted(1);
            application.setVisible(true);
        }catch(ClassNotFoundException e) {
            System.err.println("Failed to load the required classes.");
            JOptionPane.showMessageDialog(splashScreen, "Failed to load the required classes.", "Loading Application", JOptionPane.ERROR_MESSAGE);
        }catch(SQLException e){
            System.err.println("Failed to load the required classes.");
            JOptionPane.showMessageDialog(splashScreen, "An error occured while connecting with the database.", "Loading Application", JOptionPane.ERROR_MESSAGE);
        System.out.println("Application Started...");
        splashScreen.setVisible(false);
        splashScreen.dispose();
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                startApplication();
    }The problem started to show up when the application was included. This works fine when the splash screen is displayed by itself.
Albert Attard

A grey box with the splash screen size is displayed.would indicate you have your "application which takes sometime to load" in the
EDT, which will prevent painting until loading finishes
use a separate thread to load the data
http://java.sun.com/docs/books/tutorial/essential/threads/
http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html

Similar Messages

  • Help displaying a splash screen.

    Hi Guys.
    I need help displaying a splash screen as an advertisment or something before i have my main application run.
    Here is the code i wrote (it works as if it were a seperate application)
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package MajourProject;
    import java.awt.AWTException;
    import java.awt.Dimension;
    import java.awt.Robot;
    import java.awt.Toolkit;
    import javax.swing.ImageIcon;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JProgressBar;
    import javax.swing.JScrollPane;
    import javax.swing.JWindow;
    * @author Matt
    public class SplashScreen extends JWindow
        public SplashScreen()
    Start();
        public void Start(int UpTime)
            ImageIcon ii = new ImageIcon("src/1.jpg");
              JScrollPane jsp = new JScrollPane(new JLabel(ii));
                    JProgressBar Bar = new JProgressBar();
              getContentPane().add(jsp);
              setSize(853,303);
              centerScreen();
              setVisible(true);
                   try
                                Thread.sleep(20000);
                               dispose();
                   catch(Exception IE)
            private void centerScreen()
                    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
                    int x = (int) ((d.getWidth() - getWidth()) / 2);
              int y = (int) ((d.getHeight() - getHeight()) / 2);
              setLocation(x, (y-100));
           public static void main(String [] args)
                 new
    }

    And there's a problem with that code, is there?
    I don't really feel like running the code to find out what that problem might be, so let me just point out that splash screens are built into Java 6. Adding a splash screen to your program requires nothing more than using a command-line argument to point at the image file.

  • How to display different Splash Screen depending on the Locale?

    Hi,
    I have a splash screen which is working fine.
    I want to display different spalsh screen depending on the locale the user has.
    Is this possible.
    I can display different Title,Description and the text of the short-cut icon on desktop and startup Menu based on the locale by mentioning it in the JNLP and altering my browser settings. I am not able to use the icon and splash screen corresponding to the specified locale. How to do this?
    EX:
    <information>
    <title> In english</title>
    <description> In english</description>
    <shortcut online="true">
    <!-- create desktop shortcut -->
    <desktop/>
    <menu submenu="My Project in English language"/>
    </shortcut>
    *<icon kind="shortcut" href="images/icon_english.gif"/>
    <icon kind="splash" href="images/splash_english.jpg"/>*
    <!-- locale="nl-NL" specifies dutch -->
    </information>
    <information locale="nl-NL">
    <title> In Dutch</title>
    <description>In Dutch</description>
    <shortcut online="true">
    <!-- create desktop shortcut -->
    <desktop/>
    <menu submenu="My Project in Dutch language"/>
    </shortcut>
    *<icon kind="shortcut" href="images/icon_dutch.gif"/>
    <icon kind="splash" href="images/splash_dutch.jpg"/>*
    </information>
    *Now here i am not getting the splash_dutch screen for the locale "nl-NL"(Dutch) and i am getting splash_english screen.
    Can we acheive this?*

    Hi anjali...
    I have problem with splash screen..
    here is my jnlp file
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="http://localhost:8080/MyProject">
         <information>
              <title>MyProject1.0</title>
              <vendor>none</vendor>
              <description>Application Launcher For MyProject1.0</description>
              <description kind="short"></description>
              <offline-allowed />
              <icon kind="splash" href="images/Splash_MyProject.jpg" width="560" height="300"/>
         </information>
         <resources>
              <jar href="SwingApplication/mysql-connector-java-5.0.6-bin.jar" />
              <jar href="SwingApplication/MyProject1.0.jar" main="true"/>
              <jar href="SwingApplication/liquidlnf.jar" />
              <j2se version="1.6+" java-vm-args="-Xms32M -Xmx256M " />
         </resources>
         <security>
              <all-permissions/>
         </security>
         <application-desc main-class="com.mobius.ui.MainWindow">
              <argument>production%0%3#com.mysql.jdbc.Driver#MyProject4%jdbc:mysql://10.100.1.89:3306/MyProject4%MyProject%info123#MyProject2%jdbc:mysql://10.100.1.89:3306/MyProject2%MyProject%info123</argument>
         </application-desc>
    </jnlp>my post is in
    http://forum.java.sun.com/thread.jspa?threadID=5298381
    http://forum.java.sun.com/thread.jspa?threadID=5298466
    I am in big problem Help me...
    Edited by: arunnprakash on May 22, 2008 1:28 PM
    Edited by: arunnprakash on May 22, 2008 1:28 PM

  • Problem with displaying a splash screen twice

    I have a splash screen that displays while I am reading data from the recordstore, I use the same sceen when I am writing data back to the record store when the application exits.
    The problem I am having is that the screen never appears the second time, I have tried to set it to null and then instantiate it again but it still does not appear. Can someone please give me some adivse as to why this might be happening. I am pretty sure it is some kind of race condition with the threads but I just cant seem to solve it. I am placing snipits of code below.
    public class NetTools extends MIDlet implements CommandListener
    public void startApp()
    isPaused = false;
    display = Display.getDisplay(this);
    splash = new Splash();
    splash.start();
    settings = new Settings(this);
    settings.start();
    display.setCurrent(splash);
    splash.StartTimer();
    splash.setMsg("Loading Settings...");
    settings.Load();
    splash.setMsg("Loading Main App...");
    splash.Dismiss();
    showMainScreen();
    splash = null;
    public void destroyApp(boolean unconditional)
    display = Display.getDisplay(this);
    splash = new Splash();
    splash.start();
    display.setCurrent(splash);
    splash.setMsg("Saving Settings...");
    //splash.Join();
    //splash.StartTimer();
    settings.Save();
    //splash.Dismiss();
    settings = null;
    splash = null;
    public class Settings implements Runnable
    public void Load()
    try
    thread.yield();
    public void Save()
    try
    thread.yield();
    public class Splash extends Canvas implements Runnable
    public void StartTimer()
    start_time = System.currentTimeMillis();
    repaint();
    serviceRepaints();
    public void Dismiss()
    while ((start_time+WAIT_TIME)>System.currentTimeMillis())
    repaint();
    I cannot seem to figure out how to make the thread for the splash overtake the UI thread in the destroyApp(), does anybody have any ideas.
    Sunny

    A grey box with the splash screen size is displayed.would indicate you have your "application which takes sometime to load" in the
    EDT, which will prevent painting until loading finishes
    use a separate thread to load the data
    http://java.sun.com/docs/books/tutorial/essential/threads/
    http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
    http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html

  • Change info displayed on splash screen Help-- About

    When I open NI Multisim and click on Help-->About, the splash screen displays the following information in the upper left hand corner of the splash screen:
    test
    Benjamin Franklin Institute
    Serial#
    How/where do I change the word "test" so that it doesn't appear on all the classroom PCs?  Where is the source of the identifying information that appers on the splash screen?
    Thanks.

    Hello,
    In this case “test” is making reference to the Register Owner. This information is requested during the installation process. You will be able to modify this information by modifying a key in the Windows Registry.  Please refer to the link below for more information.
    http://digital.ni.com/public.nsf/allkb/0385A6FBAADE844286256DDB0066FCE8?OpenDocument
    Regards,
    MCOTO

  • No display or splash screen

    Compaq Presario sr5703wm, Windows Vista 32-bit,
    Repalced fuse in power supply. Removed password by jumper on motherboard. Booted fine 6-7 times. Next boot had no display on monitor- no splash screen, nothing. Checked for VGA connections -OK. Checked monitor on another computer-OK. When computer turned on all fans running CD/DVD light blinks momentarily, hard drive spins up. Attempted to do recovery using disc and CD/DVD drive does not run. Have tried reset Bios with no resolution.
    HELP PLEASE!  Thank you

    Hello, 
    I understand that your pc will not boot but you do hear the fans and also see lights on the cd/dvd drive blinking momentarily. I appreciate you already testing out the monitor to confirm it works with another pc. 
    When you attempted to run the recovery using the disc did the monitor show any images?
    You also mentioned resetting the bios. Did the bios menu physically show up on the monitor or could you not see it on the screen? Also take a look at your keyboard and see if there lights that flash in somewhat of a pattern. (ie. caps lock, num lock)
    I am thinking there might be an issue with the graphics card which I’m, showing is integrated to the motherboard. 
    I have inserted a link that will provide you with more steps you try. 
    I recommend you start with step 5 because the majority of the steps above you have already done. (See below)
    Step 5: Reseat loose internal components
    If the computer case was recently serviced or moved, a card, cable, memory module, or processor may have become loose. When this happens, the computer might make a beeping sound when turned on. Use the following steps to check for loose components:
    Let me know if this helps you. If you have any questions feel free to let us know. 
    Thanks 
    Clicking the White Kudos star on the left is a way to say Thanks!
    Clicking the 'Accept as Solution' button is a way to let others know which steps helped solve the problem!

  • Nothing displays on Splash Screen

    Adobe DW5. The splash screen shows up but is blank - white. I  reinstalled the Adobe Suite and still nothing. After opening, Splash  screen shows but it is white. I did some research and some people noted  flash wasn't installed because that is probably what plays it but I have  flash installed, shockwave.
    Any thoughts?

    Hi,
    Try updating BIOS to the latest version and check if it helps. Else, it seems there is some hardware issue involved. I strongly suggest you to contact our technical support for assistance.
    Click here to open a link where you can select the country and get the exact contact support number. I’m sure they will be a great help.
    Best Regards,
    Mithun.
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"! This will help the rest of the Community with similar issues identify the verified solution and benefit from it.
    Follow @LenovoForums on Twitter!

  • Hi guys need Help with Displaying Splash Screen?!!?

    Hi Guys.
    Sorry for the last incomplete post my mistake!
    I need help displaying a splash screen as an advertisment or something before i have my main application run.
    Here is the code i wrote (it works as if it were a seperate application)
    package MajourProject;
    import java.awt.AWTException;
    import java.awt.Dimension;
    import java.awt.Robot;
    import java.awt.Toolkit;
    import javax.swing.ImageIcon;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JProgressBar;
    import javax.swing.JScrollPane;
    import javax.swing.JWindow;
    * @author Matt
    public class SplashScreen extends JWindow
        public SplashScreen()
            int UpTime = 20000;
            Start(UpTime);
        public void Start(int UpTime)
            ImageIcon ii = new ImageIcon("src/1.jpg");
              JScrollPane jsp = new JScrollPane(new JLabel(ii));
                    JProgressBar Bar = new JProgressBar();
              getContentPane().add(jsp);
              setSize(853,303);
              centerScreen();
              setVisible(true);
                   try
                                Thread.sleep(20000);
                               dispose();
                   catch(Exception IE)
            private void centerScreen()
                    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
                    int x = (int) ((d.getWidth() - getWidth()) / 2);
              int y = (int) ((d.getHeight() - getHeight()) / 2);
              setLocation(x, (y-100));
           public static void main(String [] args)
                 new SplashScreen();
    }but i now have a problem as i already have a main application done as i wrote this seperately. I now need to combine the two together. So what i did was in my Main Application wrote:
    Splash_Screen SS = new Splash_Screen();it then runs my Splash Screen class which i re-wrote to look as such:
    package MajourProject;
    import java.awt.AWTException;
    import java.awt.Dimension;
    import java.awt.Robot;
    import java.awt.Toolkit;
    import javax.swing.ImageIcon;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JProgressBar;
    import javax.swing.JScrollPane;
    import javax.swing.JWindow;
    * @author Matt
    public class SplashScreen extends JWindow
        public SplashScreen()
            int time = 15000;
            Start(time);
        public void Start(int UpTime)
            ImageIcon ii = new ImageIcon("src/1.jpg");
              JScrollPane jsp = new JScrollPane(new JLabel(ii));
                    JProgressBar Bar = new JProgressBar();
              getContentPane().add(jsp);
              setSize(853,303);
              centerScreen();
              setVisible(true);
                   try
                                Thread.sleep(20000);
                                dispose();
                   catch(Exception IE)
            private void centerScreen()
                    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
                    int x = (int) ((d.getWidth() - getWidth()) / 2);
              int y = (int) ((d.getHeight() - getHeight()) / 2);
              setLocation(x, (y-100));
    }it obviously runs the default constructor which then runs the other methods in the class but it doesn't seem to show can anybody help me to find out whats wrong? It seems to be there just before the main application launches but only for a split second. And when i am waiting while the thread is sleeping the area i have defined the Content pane for he cursor goes to the loading icon! I don't know if this makes any sence to you but if you can help me it would be most apreciated.
    Thanks.

    SpearOne wrote:
    Hi Encephalopathic
    why would it work if i put it in it's own application surely it wouldn't be caused by this thread.sleep?? everything after it is in fact put to sleep. In its "own" application, nothing happens after it is displayed.
    if it is the problem then could you please give me some code to add quickly to test??
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JProgressBar;
    import javax.swing.JScrollPane;
    import javax.swing.JWindow;
    import javax.swing.Timer;
    public class SplashScreen extends JWindow
      private static final String IMAGE_PATH = "src/1.jpg";
      private static final int UP_TIME = 15000;
      public SplashScreen()
        Start();
      public void Start()
        ImageIcon ii = new ImageIcon(IMAGE_PATH);
        JScrollPane jsp = new JScrollPane(new JLabel(ii));
        //JProgressBar Bar = new JProgressBar();
        getContentPane().add(jsp);
        setSize(853, 303);
        centerScreen();
      private void centerScreen()
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (int) ((d.getWidth() - getWidth()) / 2);
        int y = (int) ((d.getHeight() - getHeight()) / 2);
        setLocation(x, (y - 100));
      public static void main(String[] args)
        final JFrame frame = new JFrame("Main Frame");
        frame.setPreferredSize(new Dimension(300, 200));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
        final SplashScreen splash = new SplashScreen();
        splash.setVisible(true);
        Timer swingTimer = new Timer(UP_TIME, new ActionListener()
          public void actionPerformed(ActionEvent e)
            splash.dispose();
            frame.setVisible(true);
        swingTimer.setRepeats(false);
        swingTimer.start();
    }

  • Web start won't display splash screen

    Hi, I am using the following .jnlp file.. The problem I am having is that web start will not display the splash screen specified below. It displays the icon fine, but not the splash screen. I cannot find an answer, can anyone help?
    <?xml version="1.0" encoding="utf-8"?>
    <jnlp spec="1.0+"
    codebase="https://mywebserver/program"
    href="https://mywebserver/progem/start.jnlp">
    <information>
    <title>My Title</title>
    <vendor>My company</vendor>
    <description></description>
    <offline-disallowed/>
    <icon href="ban1.jpg" kind="splash" />
    <icon href="icon.jpg"/>
    </information>
    <resources>
    <j2se version="1.1+"/>
    <jar href="start.jar"/>
    </resources>
    <applet-desc
    main-class="myclass"
    documentbase="start..html"
    name="Program Name"
    width="180"
    height="100">
    </applet-desc>
    </jnlp>

    I can see no reason why this wouldn't work. Can you try looking at the splash.xml file in the "splash" directory in the cache ?
    the file should contain an entry for your program, pointing to your splash file.
    /Andy

  • Problem in displaying splash screen..

    Hi..
    First of all my apology to repost the question as i was asked to post it here for the answer.I've developed a desktop application which has a splash screen.I'm using netbeans 6.0.Now, i am able to view the splash screen if i 'build' and 'run' the application in the IDE.But when i run the jar file i am not able to see the splash screen.
    This is how i've put the splash screen for my application.In project->properties->run->in VM options : splash.gif. Please help to display the splash screen when i run just the jar file.
    Thank you

    I don't understand what the way you're doing. It's a Netbeans option??
    Currently I'm developing a Swing app and I have a splash window. The way I've done it is creating a sublcass of JWindow, adding a panel, a JLabel and setting an icon.
    Like this:
    public class InitSplash extends JWindow {
         public InitSplash(Frame owner) throws HeadlessException {
              super(owner);
              initGUI();
              Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
              Dimension labelSize = jLabel.getPreferredSize();
              setLocation(screenSize.width / 2 - (labelSize.width / 2),
                        screenSize.height / 2 - (labelSize.height / 2));
         private void initGUI() {
              try {
                        this.setPreferredSize(new java.awt.Dimension(110, 150));
                        this.setLocationByPlatform(true);
                        jPanel1 = new JPanel();
                        getContentPane().add(jPanel1, BorderLayout.CENTER);
                        jPanel1.setBackground(new java.awt.Color(255,255,255));
                        jPanel1.setBorder(new LineBorder(new java.awt.Color(0,0,0), 2, false));
                             jLabel = new JLabel();
                             jPanel1.add(jLabel);
                             jLabel
                                       .setIcon(new ImageIcon(
                                                 getClass()
                                                           .getClassLoader()
                                                           .getResource(
                                                                     "com/ttt/common/gui/graphics/logo-transparente.gif")));
                             msgLabel = new JLabel();
                             jPanel1.add(msgLabel);
                             msgLabel.setText("Loading...");
                             msgLabel.setFont(new java.awt.Font("Tahoma",1,12));
                             msgLabel.setPreferredSize(new java.awt.Dimension(102, 25));
                             msgLabel.setHorizontalAlignment(SwingConstants.CENTER);
                   pack();
              } catch (Exception e) {
                   e.printStackTrace();
         }Is this what you are trying?

  • Displaying error after splash screen

    I am writing the client side of a client/server app that relies heavily on the connection between client and server.
    I have made a splash screen and while it attempts to connect it displays the splash screen.
    what i need though is that when it fails to connect it should display an alert box in the center of the screen say it has failed to connect.
    I don't understand how to do this i tried using
    JOptionPane.showInternalMessageDialog(null, message);
    and
    final JOptionPane optionPane = new JOptionPane(message, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
    then telling it to go to sleep but nothing.
    how should i do this?
    Scott.

    ratcateme wrote:
    I am writing the client side of a client/server app that relies heavily on the connection between client and server.
    I have made a splash screen and while it attempts to connect it displays the splash screen.
    what i need though is that when it fails to connect it should display an alert box in the center of the screen say it has failed to connect.
    I don't understand how to do this i tried using
    JOptionPane.showInternalMessageDialog(null, message);
    and
    final JOptionPane optionPane = new JOptionPane(message, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
    then telling it to go to sleep but nothing.That was a mistake.
    JOptionPane.showMessage
    quit

  • Display splash screen while downloading applet jar file

    I've tried to search the forums, but most results I get are how to display a splash screen while the classes are loading. Unfortunately, the classes do not begin loading until after the jar file has been downloaded. How does one go about showing as splash screen as the jar file containing the classes is downloaded?
    Thanks for the help!

    "Java 5 provides a capability in this area"- Unfortunately, due to circumstances out of our control we are stuck on java 1.4.x.
    "How you do that is your problem."- I'm so glad I can count on the helpful java community. Thanks.
    Since it appears that "warnerja" is discusted by my question (mabye had a bad day) and is leaving me out in the cold, does anyone have any ideas on how I can implement her/his suggestion. I can break my jar file into multiple seperate jars and as each one loads I can update a progress bar. Unfortunately, I do not know where to begin with this code wise nor do I know if this is the best solution to this problem. I would think this to be a common problem.
    Thanks for your help!

  • Useful Code of the Day:  Splash Screen & Busy Application

    So you are making an Swing application. So what are two common things to do in it?
    1) Display a splash screen.
    2) Block user input when busy.
    Enter AppFrame! It's a JFrame subclass which has a glass pane overlay option to block input (setBusy()). While "busy", it displays the system wait cursor.
    It also supports display of a splash screen. There's a default splash screen if you don't provide a component to be the splash screen, and an initializer runner which takes a Runnable object. The Runnable object can then modify the splash screen component, for example to update a progress bar or text. See the main method for example usage.
    It also has a method to center a component on another component (useful for dialogs) or center the component on the screen.
    NOTE on setBusy: I do recall issues with the setBusy option to block input. I recall it having a problem on some Unix systems, but I can't remember the details offhand (sorry).
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    * <CODE>AppFrame</CODE> is a <CODE>javax.swing.JFrame</CODE> subclass that
    * provides some convenient methods for applications.  This class implements
    * all the same constructors as <CODE>JFrame</CODE>, plus a few others. 
    * Methods exist to show the frame centered on the screen, display a splash
    * screen, run an initializer thread and set the frame as "busy" to block 
    * user input. 
    public class AppFrame extends JFrame implements KeyListener, MouseListener {
          * The splash screen window. 
         private JWindow splash = null;
          * The busy state of the frame. 
         private boolean busy = false;
          * The glass pane used when busy. 
         private Component glassPane = null;
          * The original glass pane, which is reset when not busy. 
         private Component defaultGlassPane = null;
          * Creates a new <CODE>AppFrame</CODE>. 
         public AppFrame() {
              super();
              init();
          * Creates a new <CODE>AppFrame</CODE> with the specified
          * <CODE>GraphicsConfiguration</CODE>. 
          * @param  gc  the GraphicsConfiguration of a screen device
         public AppFrame(GraphicsConfiguration gc) {
              super(gc);
              init();
          * Creates a new <CODE>AppFrame</CODE> with the specified title. 
          * @param  title  the title
         public AppFrame(String title) {
              super(title);
              init();
          * Creates a new <CODE>AppFrame</CODE> with the specified title and
          * <CODE>GraphicsConfiguration</CODE>. 
          * @param  title  the title
          * @param  gc     the GraphicsConfiguration of a screen device
         public AppFrame(String title, GraphicsConfiguration gc) {
              super(title, gc);
              init();
          * Creates a new <CODE>AppFrame</CODE> with the specified title and
          * icon image. 
          * @param  title  the title
          * @param  icon   the image icon
         public AppFrame(String title, Image icon) {
              super(title);
              setIconImage(icon);
              init();
          * Creates a new <CODE>AppFrame</CODE> with the specified title and
          * icon image. 
          * @param  title  the title
          * @param  icon  the image icon
         public AppFrame(String title, ImageIcon icon) {
              this(title, icon.getImage());
          * Initializes internal frame settings. 
         protected void init() {
              // set default close operation (which will likely be changed later)
              setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
              // set up the glass pane
              glassPane = new JPanel();
              ((JPanel)glassPane).setOpaque(false);
              glassPane.addKeyListener(this);
              glassPane.addMouseListener(this);
          * Displays a new <CODE>JWindow</CODE> as a splash screen using the
          * specified component as the content.  The default size of the
          * component will be used to size the splash screen.  See the
          * <CODE>showSplash(Component, int, int)</CODE> method description for
          * more details. 
          * @param  c  the splash screen contents
          * @return  the window object
          * @see  #showSplash(Component, int, int)
          * @see  #hideSplash()
         public JWindow showSplash(Component c) {
              return showSplash(c, -1, -1);
          * Displays a new <CODE>JWindow</CODE> as a splash screen using the
          * specified component as the content.  The component should have all
          * the content it needs to display, like borders, images, text, etc. 
          * The splash screen is centered on monitor.  If width and height are
          * <CODE><= 0</CODE>, the default size of the component will be used
          * to size the splash screen. 
          * <P>
          * The window object is returned to allow the application to manipulate
          * it, (such as move it or resize it, etc.).  However, <B>do not</B>
          * dispose the window directly.  Instead, use <CODE>hideSplash()</CODE>
          * to allow internal cleanup. 
          * <P>
          * If the component is <CODE>null</CODE>, a default component with the
          * frame title and icon will be created. 
          * <P>
          * The splash screen window will be passed the same
          * <CODE>GraphicsConfiguration</CODE> as this frame uses. 
          * @param  c  the splash screen contents
          * @param  w  the splash screen width
          * @param  h  the splash screen height
          * @return  the window object
          * @see  #showSplash(Component)
          * @see  #hideSplash()
         public JWindow showSplash(Component c, int w, int h) {
              // if a splash window was already created...
              if(splash != null) {
                   // if it's showing, leave it; else null it
                   if(splash.isShowing()) {
                        return splash;
                   } else {
                        splash = null;
              // if the component is null, then create a generic splash screen
              // based on the frame title and icon
              if(c == null) {
                   JPanel p = new JPanel();
                   p.setBorder(BorderFactory.createCompoundBorder(
                        BorderFactory.createRaisedBevelBorder(),
                        BorderFactory.createEmptyBorder(10, 10, 10, 10)
                   JLabel l = new JLabel("Loading application...");
                   if(getTitle() != null) {
                        l.setText("Loading " + getTitle() + "...");
                   if(getIconImage() != null) {
                        l.setIcon(new ImageIcon(getIconImage()));
                   p.add(l);
                   c = p;
              splash = new JWindow(this, getGraphicsConfiguration());
              splash.getContentPane().add(c);
              splash.pack();
              // set the splash screen size
              if(w > 0 && h > 0) {
                   splash.setSize(w, h);
              } else {
                   splash.setSize(c.getPreferredSize().width, c.getPreferredSize().height);
              centerComponent(splash);
              splash.show();
              return splash;
          * Disposes the splash window. 
          * @see  #showSplash(Component, int, int)
          * @see  #showSplash(Component)
         public void hideSplash() {
              if(splash != null) {
                   splash.dispose();
                   splash = null;
          * Runs an initializer <CODE>Runnable</CODE> object in a new thread. 
          * The initializer object should handle application initialization
          * steps.  A typical use would be:
          * <OL>
          *   <LI>Create the frame.
          *   <LI>Create the splash screen component.
          *   <LI>Call <CODE>showSplash()</CODE> to display splash screen.
          *   <LI>Run the initializer, in which: 
          *   <UL>
          *     <LI>Build the UI contents of the frame.
          *     <LI>Perform other initialization (load settings, data, etc.).
          *     <LI>Pack and show the frame.
          *     <LI>Call <CODE>hideSplash()</CODE>.
          *   </UL>
          * </OL>
          * <P>
          * <B>NOTE:</B>  Since this will be done in a new thread that is
          * external to the event thread, any updates to the splash screen that
          * might be done should be triggered through with
          * <CODE>SwingUtilities.invokeAndWait(Runnable)</CODE>. 
          * @param  r  the <CODE>Runnable</CODE> initializer
         public void runInitializer(Runnable r) {
              Thread t = new Thread(r);
              t.start();
          * Shows the frame centered on the screen. 
         public void showCentered() {
              centerComponent(this);
              this.show();
          * Checks the busy state.
          * @return  <CODE>true</CODE> if the frame is disabled;
          *          <CODE>false</CODE> if the frame is enabled
          * @see  #setBusy(boolean)
         public boolean isBusy() {
              return this.busy;
          * Sets the busy state.  When busy, the glasspane is shown which will
          * consume all mouse and keyboard events, and a wait cursor is
          * set for the frame. 
          * @param  busy  if <CODE>true</CODE>, disables frame;
          *               if <CODE>false</CODE>, enables frame
          * @see  #getBusy()
         public void setBusy(boolean busy) {
              // only set if changing
              if(this.busy != busy) {
                   this.busy = busy;
                   // If busy, keep current glass pane to put back when not
                   // busy.  This is done in case the application is using
                   // it's own glass pane for something special. 
                   if(busy) {
                        defaultGlassPane = getGlassPane();
                        setGlassPane(glassPane);
                   } else {
                        setGlassPane(defaultGlassPane);
                        defaultGlassPane = null;
                   glassPane.setVisible(busy);
                   glassPane.setCursor(busy ?
                        Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR) :
                        Cursor.getDefaultCursor()
                   setCursor(glassPane.getCursor());
          * Handle key typed events.  Consumes the event for the glasspane
          * when the frame is busy. 
          * @param  ke  the key event
         public void keyTyped(KeyEvent ke) {
              ke.consume();
          * Handle key released events.  Consumes the event for the glasspane
          * when the frame is busy. 
          * @param  ke  the key event
         public void keyReleased(KeyEvent ke) {
              ke.consume();
          * Handle key pressed events.  Consumes the event for the glasspane
          * when the frame is busy. 
          * @param  ke  the key event
         public void keyPressed(KeyEvent ke) {
              ke.consume();
          * Handle mouse clicked events.  Consumes the event for the glasspane
          * when the frame is busy. 
          * @param  me  the mouse event
         public void mouseClicked(MouseEvent me) {
              me.consume();
          * Handle mouse entered events.  Consumes the event for the glasspane
          * when the frame is busy. 
          * @param  me  the mouse event
         public void mouseEntered(MouseEvent me) {
              me.consume();
          * Handle mouse exited events.  Consumes the event for the glasspane
          * when the frame is busy. 
          * @param  me  the mouse event
         public void mouseExited(MouseEvent me) {
              me.consume();
          * Handle mouse pressed events.  Consumes the event for the glasspane
          * when the frame is busy. 
          * @param  me  the mouse event
         public void mousePressed(MouseEvent me) {
              me.consume();
          * Handle mouse released events.  Consumes the event for the glasspane
          * when the frame is busy. 
          * @param  me  the mouse event
         public void mouseReleased(MouseEvent me) {
              me.consume();
          * Centers the component <CODE>c</CODE> on the screen. 
          * @param  c  the component to center
          * @see  #centerComponent(Component, Component)
         public static void centerComponent(Component c) {
              centerComponent(c, null);
          * Centers the component <CODE>c</CODE> on component <CODE>p</CODE>. 
          * If <CODE>p</CODE> is null, the component <CODE>c</CODE> will be
          * centered on the screen. 
          * @param  c  the component to center
          * @param  p  the parent component to center on or null for screen
          * @see  #centerComponent(Component)
         public static void centerComponent(Component c, Component p) {
              if(c != null) {
                   Dimension d = (p != null ? p.getSize() :
                        Toolkit.getDefaultToolkit().getScreenSize()
                   c.setLocation(
                        Math.max(0, (d.getSize().width/2)  - (c.getSize().width/2)),
                        Math.max(0, (d.getSize().height/2) - (c.getSize().height/2))
          * Main method.  Used for testing.
          * @param  args  the arguments
         public static void main(String[] args) {
              final AppFrame f = new AppFrame("Test Application",
                   new ImageIcon("center.gif"));
              f.showSplash(null);
              f.runInitializer(new Runnable() {
                   public void run() {
                        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        f.getContentPane().add(new JButton("this is a frame"));
                        f.pack();
                        f.setSize(300, 400);
                        try {
                             Thread.currentThread().sleep(3000);
                        } catch(Exception e) {}
                        f.showCentered();
                        f.setBusy(true);
                        try {
                             Thread.currentThread().sleep(100);
                        } catch(Exception e) {}
                        f.hideSplash();
                        try {
                             Thread.currentThread().sleep(3000);
                        } catch(Exception e) {}
                        f.setBusy(false);
    "Useful Code of the Day" is supplied by the person who posted this message. This code is not guaranteed by any warranty whatsoever. The code is free to use and modify as you see fit. The code was tested and worked for the author. If anyone else has some useful code, feel free to post it under this heading.

    Hi
    Thanks fo this piece of code. This one really help me
    Deepa

  • Custom splash screen only shows up when command line is used...

    Hi,
    Everything in my Java web start application works perfectly but, the custom splash screen only shows up when command line is used ("C:\Program Files (x86)\Java\jre7\bin>javaws -verbose http://www.xxx.eu/AcSentVivresCrus/AcSentJnlp/AcSent.jnlp"), if I use the shortcut on the desktop or in the start menu, the Java 7 splash screen shows up (tested under Windows Vista and Seven). Does someone have any clues?
    Thanks...
    My jnlp file :
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="6.0+" href="AcSent.jnlp">
      <information>
        <title>AcSent : Commande de repas</title>
        <description>AcSent - Commande de repas</description>
        <vendor>AcSent</vendor>
        <homepage href="http://www.xxx.eu" />
        <icon href="acSentIconBiseau.png" />
        <icon href="splashAcSentRC.png" kind="splash" />
        <shortcut online="true">
          <desktop />
          <menu submenu="AcSent" />
        </shortcut>
      </information>
      <security>
        <all-permissions />
      </security>
      <resources>
        <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se" max-heap-size="128m" />
        <jar href="AcSentJnlpProgressIndicator.jar" download="progress" />
        <jar href="AcSentJnlp.jar" main="true" version="1.0" />
        <property name="jnlp.packEnabled" value="true" />
        <property name="jnlp.versionEnabled" value="true" />
      </resources>
      <application-desc name="AcSent" main-class="eu.acsent.jnlp.AcSentApplication"
           progress-class="eu.acsent.jnlp.progressindicator.CustomProgress"> 
      </application-desc>
    </jnlp>

    Hi again,
    I made some researches :
    - The link in the generated shorcuts ("C:\Windows\SysWOW64\javaws.exe -localfile -J-Djnlp.application.href=http://www.xxx.eu/AcSentVivresCrus/AcSentJnlp/AcSent.jnlp "C:\Users\Arnaud\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\46\69c1e9ee-1f252d1a") is not the same as the one I use in the command line ("C:\Program Files (x86)\Java\jre7\bin>javaws -verbose http://www.xxx.eu/AcSentVivresCrus/AcSentJnlp/AcSent.jnlp"). Is there a way in the the JNLP file to tell how to generate shortcuts (not the icon, etc., but command line options)?
    - This sample (https://blogs.oracle.com/thejavatutorials/entry/changing_the_java_web_start) displays the splash screen when I click on the the generated shortcuts (I use Windows 7). I have copied the ButtonDemo jar file and the JNLP file on my IIS web server (Windows 2008 Server), this time the splash screen does not show up when I click the generated shortcuts but always shows up when I use the command line. Can someone tell me if it is a trouble with IIS ?
    Thanks again...

  • Howto. stacked canvas as splash screen

    hello all users of forms world!
    problem:
    how to display a splash screen with a text inside when a process is launched in a canvas full of iteration etc...
    solution:
    assume we have a content canvas C playing the role of a data processor, items browser or other ..
    and a stacked canvas S playing the role of "splash screen" linked to a B_spash block.
    generic code :
    function show_waitscreen (msg Varchar2)
    begin
    :B.message := msg;
    show_view('splash_canvas'); --show canvas S
    synchronize;
    -- here is my contribution :: we must "cut off " the
    --relation between C ans S at the visual level
    host('waitcmd');
    -- waitcmd is a unix shell doing anything :: a date, etc
    end;
    e.g.
    short_process;
    show_waitscreen;
    long_process; -- a lot of go_block, go_record or loop
    hide_waitscreen; -- to implement ! it is very simple
    I'll hope that code helps some programmers using forms (4.5 ,6)
    Daniel

    Hi All,
    I found the solution and successfully implemented the desired functionality
    DECLARE
         v_Tab VARCHAR2(1000);
    BEGIN
         v_Tab := GET_CANVAS_PROPERTY('CAN_TABS', TOPMOST_TAB_PAGE);
         IF v_Tab = 'a1' THEN
         GO_BLOCK('BLK1');
              EXECUTE_QUERY;
         ELSIF v_Tab = 'a2' THEN
              GO_BLOCK('BLK2');
              EXECUTE_QUERY;
         ELSIF v_Tab = 'a3' THEN
    *          Set_View_Property('CAN_STK_FIS_NET',HEIGHT,280);*
    *          Set_View_Property('CAN_STK_FIS_NET',WIDTH,630);*
    *          Set_View_Property('CAN_STK_FIS_NET',DISPLAY_POSITION,6,135);*
    *          SHOW_VIEW('CAN_STK_FIS_NET');     *     
              GO_BLOCK('BLK_FIS1_GRID');
              EXECUTE_QUERY;
    END IF;
    END ;
    I have seperately created stacked canvas 'CAN_STK_FIS_NET' and placed multiple blocks as per requirement and able to achieve the functionality.
    Please let me know if any one need any detail explanation.
    regards
    cj

Maybe you are looking for

  • Looking For A Good Tutorial That Shows How To Redirect A Form Page.

    Hi, Attached is a mock up of the Home Recipes Page on the site I'm building. When a user clicks on one of the categories (Desserts, Drinks, etc), I want them to be able to go to the Main Page for that category, on which will appear the recipes that h

  • Aperture 3.1 - Mobileme - Flickr - Facebook

    Hi, I just upgraded to Aperture 3.1 and pleased to find all my galleries for Flickr and Facebook listed, and not just the one's created in Aperture. But for mobileme, there is still a mismatch: just the ones created in mobileme are listed in Aperture

  • Sending attachments/binary data from flex to Restful APIs

    Hi, We have a requirement of sending the files (or binary data) from flex GUI to Restful services(backend APIs). We are using flex HTTPService component to invoke the rest apis. The Rest APIs are designed to accept the multipart/mixed data which can

  • SPDIF output broken with alsa (Xonar D2 card)

    Hi, since the last time I used the SACD player, foobar2000 under wine, I get no sound from my digital port. The config had been working for a few years by then, and usually foobar gets in the way of other applications using alsa, but when the applica

  • Why do my footnotes keep disappearing on my new Macbook Air?

    My footnotes keep disappearing on Microsoft Word, on my Macbook Air. I have only had the computer (and Word) for a week or so. Do you know why this is? The footnotes do reappear when I close the document and reopen it, but it means I am unable to wor