Splash screen needs to keep on top

Hello Everyone,
I have been working on application where i need to show splash screen before launching the actual application.
I did create JDailog as splash screen and want to show this splash screen at top of all application but I don't want to set setAlwaysOnTop(true). becasue my requirement is that to keep splash screen on top at the time of launching. if user click any other application and splash screen doesn't remain on top, that is fine with me.
i want when i do launch my application and start working on other application like MS word, splash screen must visible at the top of the active application.
so what really i need to do to keep this on top of active application.
I don't want to use setAlwaysOnTop(true). because it has certain limitations and that doesn’t really work in my case.
really looking for your great response.
Thanks,

You could do setAlwaysOnTop( true ) to ensure that the splash screen is shown on top,
and have a listener to reset it once it is made visible. Something like
splash.addHierarchyListener( new HierarchyListener() {
     public void hierarchyChanged(HierarchyEvent e) {
          if ( HierarchyEvent.SHOWING_CHANGED == ( e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED ) ) {
               splash.setAlwaysOnTop( false );
};

Similar Messages

  • Splash screen - need help loading

    I am having trouble calling a simple splash screen class from my main application class; My main application class called PUI, with all of my code that is working, I created a very simple splash class called PS. I want the PS to show before the main PUI application loads. Here is the simple code for the PS class.
    public class PandoraSplash {
         public static void main(String[] arg) {
              JWindow window = new JWindow();
              window.getContentPane().add(
                        new JLabel("Loading PANDORA...", SwingConstants.CENTER));
              window.setBounds(200, 200, 200, 100);
              window.setVisible(true);
              try {
                   Thread.sleep(5000);
              } catch (InterruptedException e) {
                   e.printStackTrace();
              window.setVisible(false);
              window.dispose();
    } As you can see the Thread is set for 5000, then I want the main PUI to open. How do I call this class from PUI? also, How do I make this class come first in the load of the entire package?
    Thank you, all help will be much appreciated!

    Note: This thread was originally posted in the [New To Java|http://forums.sun.com/forum.jspa?forumID=54] forum, but moved to this forum for closer topic alignment.

  • Launching Splash Screen on the click of a button

    Situation: I have an application running, and when the user clicks a button on the main menu, a new dialog opens.
    Problem: This dialog takes awhile to load as it is retreiving information from the database etc ... hence I would like to launch a splash screen in one thread and the other dialog in a second thread.
    Following is the Splash Screen class:
    public class SplashScreen extends JWindow {
        public SplashScreen(int d) {
            duration = d;
            this.launchSplash();
        public void launchSplash() {
            JPanel content = (JPanel) getContentPane();
            content.setBackground(Color.white);
            // Set the window's bounds, centering the window
            int width = 350;
            int height = 255;
            Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
            int x = (screen.width - width) / 2;
            int y = (screen.height - height) / 2;
            setBounds(x, y, width, height);
            // Build the splash screen
            JLabel label = new JLabel();
            label.setIcon(new ImageIcon(getClass().getResource("loading.gif")) );         
            label.setHorizontalAlignment(JLabel.CENTER);    
            content.add(label, BorderLayout.CENTER);          
            // Display it
            this.setVisible(true);
            // Wait a little while, maybe while loading resources
            try {
                Thread.sleep(duration);
            } catch (Exception e) {
            this.setVisible(false);
    //        System.exit(0);
    //    public static void main(String[] args) {
    //        // Throw a nice little title page up on the screen first
    //        SplashScreen splash = new SplashScreen(10000);
    //        // Normally, we'd call splash.launchSplash() and get on
    //        // with the program. But, since this is only a test...
    //        System.exit(0);
    //    }When I run this as a standalone, it works fine (i.e. uncomment the 'main' function). But when I try to call it from another function, it doesn't launch.
    Eg: I am calling it when a button has been clicked. Code is as follows:
        public void actionPerformed(ActionEvent e) {
         SplashScreen sd = new SplashScreen(10000);
         // Calling the dialog (that takes a long time to load) here
    }Would like to know whether
    [1] is it possible to launch a splash screen on the click of a button? As usually a splash screen is done at the beginning of an application before anything is loaded. In my case an application is already running, during which a splash screen needs to be launched.
    [2] Would using the new splashscreen class of Java 6.0 support this?
    [3] If not what is the best way to approach this problem
    Appreciate any input.
    Thanks,
    Edited by: mnr on Feb 20, 2008 9:47 AM

    Thanks Michael_Dunn, I see what you mean.
    I know this is not exactly as you suggested, but when I tried the following I got a partial solution. Just wanted to know whether I am on the right track.
    I wrote a small class for the thread
    public class cSplashScreenThread extends Thread {
        public volatile boolean finished = false;
        public cSplashScreenThread(){       
    // override run() method in interface
        public void run() {
           SplashScreen sd = new SplashScreen(10000);
        }This calls the SplashScreen(code encl in earlier post).
    In the main application I added the following
    public void actionPerformed(ActionEvent e) {
    // SPLASH SCREEN
    //                    SwingUtilities.invokeLater(new Runnable() {
    //                        public void run() {
                                cSplashScreenThread sd = new cSplashScreenThread();
                                sd.start();
                                sd.finished = true;
    // DIALOG
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                          DialogToCall tempDialolog = new DialogToCall(.......);
                                tempDialolog .setVisible(true);
    :When I run this in the application, the SplashScreen does indeed appear(earlier I wasn't able to see the splashScreen), and I notice (when I put a breakpoint at the pt where it calls the dialog), that it is going and creating the dialog etc, but the dialog never appears ...... after the splash screen closes, nothing else happens!
    Could you please guide me on what best to do?
    Thanks,
    Edited by: mnr on Feb 21, 2008 11:19 AM

  • I keep getting an audi add as a background or splash screen when I bring up my home page (simpatico msn) how do I get rid of it?

    when ever I start firefox my home page opens and I have the standard home page but lately I have been getting an Audi ad as a splash screen behind my home page window, my home page is Simpatico Canada

    The settings for the warning messages have been removed from the user interface (Bug 513166).
    You need to change the related security.warn_* prefs directly on the <b>about:config</b> page.<br />
    Filter: security.warn
    To open the <i>about:config</i> page, type <b>about:config</b> in the location (address) bar and press the "<i>Enter</i>" key, just like you type the url of a website to open a website.<br />
    If you see a warning then you can confirm that you want to access that page.<br />
    *Use the Filter bar at to top of the about:config page to locate a preference more easily.
    *Preferences that have been modified show as bold(user set).
    *Preferences can be reset to the default or changed via the right-click context menu.

  • HT201177 I cannot view some videos and participate in some websites since Adobe upgraded all to Flash 11.7. I have an older Mac G5 PowerPC (no Intel chip) running OS 10.5.8. I keep getting splash screens saying I have to update to Flash 11.7 but 11.7 is m

    I cannot view some videos and participate in some websites since Adobe upgraded all to Flash 11.7. I have an older Mac G5 PowerPC (no Intel chip) running OS 10.5.8. I keep getting splash screens saying I have to update to Flash 11.7 but 11.7 is made for those Macs with an Intel chip. I am running the newest Flash for my system. It seems all concerned should have made Flash retro-compatible for those of us with older Macs. Is there a work around to this Flash requirement short of buying a new Mac with the Intel chip?

    I'll bet you'll have better luck if you post your question in the Power Mac discussions here: https://discussions.apple.com/community/desktop_computers/power_mac
    Either that, or one of the forums at Adobe.
    Good luck.
    Russ

  • 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();
    }

  • App builder keeps hanging after splash screen images added

    After I upload all my splash screens for SD and HD, I cannot proceed to the next screen.
    There are green checks next to HD and SD, and all looks good.
    I have not uploaded any fonts as there is no HTML in the app.
    I have deleted and re-downloaded the app builder and still get the same behavior.

    The problem was that one of the images had a resolution of 72.09 instead of an even 72. after I changed it it worked. Thanks.

  • Need to change the bios splash screen..

     im using lenovo B460e notebook .
    i want to change the bios splash screen..
    so pls anyone help me out.
    my biosbrand is LENOVO and its version is:4FCNA1WW

    You may check if you get the option in installed BIOS itself otherwise kindly do not try.
    Best Regards,
    Tanuj
    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!

  • Lenovo Ideapad s10e Keeps Restarting after Splash Screen

    Hey, my Lenovo s10e perpetually restarts after the Lenovo splash screen. The blinking cursor comes up for 5 seconds and then the computer restarts again. F1 for system bios or F8 for safe mode do not work. Taking out battery/AC and holding power button for 40 secs also yields no results.
    Computer had been working fine, when inexplicably the virtual memory shot up and the paging file had to be increased. Tried to shut down the computer but it wasn't responding, so I did so manually. I have not been able to get the computer to boot up properly since.
    I spoke with Lenovo on the phone and they said it was a motherboard issue, and the computer had to be sent in. Was wondering if anyone had some other possible solutions before I'm forced to ship it out.
    All the best,
    Andom

    Hey thanks for the reply.
    Unfortunately, One Key Recovery does not do anything: splash screen and blinking cursor come up before restarting again. I also wouldn't want to do anything that makes me lose my data.
    Lenovo support said they would be able to fix it without reformatting HD, so I guess I'll have to go that option...unfortunately, max estimate is $575.

  • How doI correct a problem from safe boot? I am trying to gain a clean start minus Chrome which keeps freezing on the keychain splash screen

    My pages automatically come up when rebooting (something I intent to fix); I am unable to go anywhere before Chrome comes up and the splash screen for the keychain (hate that) comes up and freezes the pages not allowing me to go anywhere to fix the problem. UGH!!! Help?

    You hold down the shift key at startup
    http://support.apple.com/kb/ht1455
    Once you are in safe mode you want to remove login items. Go to the Apple Menu, select system preferences, user and groups, login items( not login options) , unlock and click the - button on everything in there.
    You can delete chrome from finder. Select applications and drag it to the trash or a right click then move to trash
    You can do a clean install of the OS or simply repair it.
    As far as the keychain you can reset the keychain in keychain access application, go to preferences, reset keychain.

  • W540 stuck on ThinkPad splash screen

    I've got W540 (32GB RAM, 500GB HDD) running Windows 7.1 64bit that is constantly getting stalled at the ThinkPad splash screen during powerup.
    It will often stall at the "ThinkPad" splash screen.  
    Other times it will stall at the "ThinkPad" splash screen with the "To interrupt normal startup, pess Enter" message displayed.
    I've seen other entries that reference this issue with:
    - using a SSD, I'm a standard HDD.
    - a broken USB port.  Mine all look OK (is there a way to actually test them?)
    I've updated to the latest Bios and reset the Bios defaults with no change.
    I've run the hardware diagnostic tests and found no errors.
    When I say "stall" on the splash screens I sometimes find if I leave it alone long enough (maybe 5+ minutes) it will continue to the normal Windows boot up.
    This is the 2nd W540 out of a pool of laptops to display symptoms similar to this.
    Anyone got information on what may cause a stall at the ThinkPad splash screen?
    Thanks.

    Not knowing your exact set up, but KNOWING that this is a blind black box with no activity light like a normal workstation, you need to do workarounds.
    Normally, on my older workstation, I could see the HD light blink and the rate would give me an inkling of the process.
    The WORKAROUND: we now need to calibrate your computer clock to your watch, or use a cell phone time keeper which would already be synced if the W540 is connected to the WiFi (no switch so the W540 has to be connected, unless there is no access point).  As an aside, I have found that when there are large MS updates, like last Tuesday, or other such WiFi connected updated, the compute also hangs with the user having NO KNOWLEDGE that the WiFi is talking / or calling home to some cloud device.
    Back to the workaround: Boot the system, and when there appears to be a crash or hang in the sequence, note the time of the 'event' and also note the time when it appears to restart.  Once properly booted, and I cannot tell you how often this has happened to my W540, check the even times in the [Event Viewer].  Too long to explain, Google the term "Win 7 Event Viewer", or check this:
    MS Help - Event Viewer
    Then find out where the computer chokes and restarts by checking the time in the events and the cause.  These are i/o routines which the Lenovo Gods have decide to shield us from such WORKSTATION task.
    FWIW, often I get <Program Not Responding>, when in fact it is performing a numbers intensive task.... yet I cannot tell what is happening as there is no i/o light. Usually unlocks when the task is finished, which may be what is happening on your system.  You need to find out the task that is  causing the wait.
    Odd, the Lenovo Gaming machines Y50 have these lights, albeit atrophied:  see lower 4 indicator lights....

  • Splash screen ABAP (Was 6.20) SAPGui 6.20

    I love splash screens. A small pop-up window with a picture should come for say 5  to 10 seconds and disappear by a timer task.
    Giving such timer splash screens at START or END makes the application attractive. I do it in VB PB & Java.
    How to do Slash screen in ABAP SAP GUI 6.20 WAS 6.20?
    Should be thrown up as a "floating" popup.
    Regards & Hopeful
    -jnc

    With good tips from Thomas Jung
    I made 2 function modules to suit my whims.
    SAP being a serious Businesss Software you cannot have too many JPGs floating around! One or two is fun.
    In Function group uou need two screens 0806 & 2009 which are essentially blank.
    I put 2 title Bars - 0806 "SAP - JOB in Progress"; 2009 - "SAP - JOB OVER!!"
    Code listing for function: ZJNC_START_SPLASH
    Description: Show Splash at Start
    FUNCTION zjnc_start_splash.
    ""Local interface:
    *"  IMPORTING
    *"     REFERENCE(IMAGEFILE) TYPE  C DEFAULT 'THANKS.JPG'
    *"     REFERENCE(WIDTH) TYPE  I DEFAULT 415
    *"     REFERENCE(HEIGHT) TYPE  I DEFAULT 274
    *"     REFERENCE(TIMEOUT) TYPE  I DEFAULT 3
    *"     REFERENCE(CALLBACK) TYPE  C
          Global data declarations
      MOVE imagefile TO g_name.
      MOVE width TO picwidth.
      MOVE height TO picheight.
      MOVE timeout TO pictimeout.
      MOVE callback TO piccallback.
      TRANSLATE piccallback TO UPPER CASE.
      PERFORM getpicurl.
      CALL SCREEN 0806.
    ENDFUNCTION.
    Code listing for function: ZJNC_END_SPLASH
    Description: Show Splash at End
    FUNCTION ZJNC_END_SPLASH.
    ""Local interface:
    *"  IMPORTING
    *"     REFERENCE(IMAGEFILE) TYPE  C DEFAULT 'THANKS.JPG'
    *"     REFERENCE(WIDTH) TYPE  I DEFAULT 415
    *"     REFERENCE(HEIGHT) TYPE  I DEFAULT 274
    *"     REFERENCE(TIMEOUT) TYPE  I DEFAULT 3
          Global data declarations
      MOVE imagefile TO g_name.
      MOVE width TO picwidth.
      MOVE height TO picheight.
      MOVE timeout TO pictimeout.
      PERFORM getpicurl.
      CALL SCREEN 2009.
    ENDFUNCTION.
    Code listing for: LZUTILTOP
    TOP level Include of Function Group ZUTIL
    Author Jayanta Narayan Choudhuri
            Flat 302
            395 Jodhpur Park
            Kolkata 700 068
          Email [email protected]
          URL:  http://www.geocities.com/ojnc
    FUNCTION-POOL zutil.                        "MESSAGE-ID ..
    TYPE-POOLS: abap.
    DATA: graphic_url(255),
          g_result   TYPE i,
          g_linesz   TYPE i,
          g_filesz   TYPE i,
          g_name(100).
    TYPES: t_graphic_line(256) TYPE x.
    DATA: graphic_line TYPE t_graphic_line,
          graphic_table TYPE TABLE OF t_graphic_line.
    DATA: picwidth        TYPE i,
          picheight       TYPE i,
          pictimeout      TYPE i,
          piccallback(60) TYPE c,
          first           TYPE boolean.
          CLASS ZCL_ES_SPLASH_SCREEN  DEFINITION
    CLASS zcl_es_splash_screen DEFINITION.
      PUBLIC SECTION.
        EVENTS on_close.
        METHODS constructor
          IMPORTING
            !i_num_secs  TYPE i DEFAULT 5
            !i_url       TYPE c
            !i_width     TYPE i
            !i_height    TYPE i.
      PROTECTED SECTION.
        METHODS handle_end_of_timer
          FOR EVENT finished OF cl_gui_timer.
      PRIVATE SECTION.
        DATA container TYPE REF TO cl_gui_dialogbox_container.
        DATA image     TYPE REF TO cl_gui_picture.
        DATA timer     TYPE REF TO cl_gui_timer.
    ENDCLASS.                    "ZCL_ES_SPLASH_SCREEN  DEFINITION
    CLASS ZCL_ES_SPLASH_SCREEN IMPLEMENTATION
    CLASS zcl_es_splash_screen IMPLEMENTATION.
      METHOD constructor.
        DATA: image_width     TYPE i,
              image_height    TYPE i.
        COMPUTE image_width  = i_width + 30.
        COMPUTE image_height = i_height + 50.
        CREATE OBJECT container
           EXPORTING
             width                       = 10
             height                      = 10
             top                         = 10
             left                        = 10
             name                        = 'DialogSplash'.
        CALL METHOD container->set_caption
          EXPORTING
            caption = g_name.
        CREATE OBJECT image
          EXPORTING
            parent = container.
        CALL METHOD image->load_picture_from_url
          EXPORTING
            url = i_url.
        image->set_display_mode( image->display_mode_normal_center ).
        cl_gui_cfw=>flush( ).
        container->set_metric( EXPORTING metric = image->metric_pixel ).
        DATA: myleft TYPE i,
              mytop  TYPE i.
        COMPUTE myleft = ( 800 - image_width ) / 2.
        COMPUTE mytop  = ( 600 - image_height ) / 2.
        IF myleft < 0.
          MOVE 0 TO myleft.
        ENDIF.
        IF mytop < 0.
          MOVE 0 TO mytop.
        ENDIF.
        container->set_position(
          EXPORTING
            height            = image_height
            left              = myleft
            top               = mytop
            width             = image_width ).
        cl_gui_cfw=>update_view( ).
        CREATE OBJECT timer.
        timer->interval = i_num_secs.
        SET HANDLER me->handle_end_of_timer FOR timer.
        timer->run( ).
        cl_gui_cfw=>flush( ).
      ENDMETHOD.                    "constructor
      METHOD handle_end_of_timer.
    I wanted NAMASTE to remain until JOB was complete.
       IF container IS NOT INITIAL.
         container->free( ).
         CLEAR container.
         FREE  container.
       ENDIF.
       IF timer IS NOT INITIAL.
         timer->free( ).
         CLEAR timer.
         FREE  timer.
       ENDIF.
       cl_gui_cfw=>flush( ).
        RAISE EVENT on_close.
      ENDMETHOD.                    "handle_end_of_timer
    ENDCLASS.                    "ZCL_ES_SPLASH_SCREEN  IMPLEMENTATION
          CLASS lcl_event_handler DEFINITION
    CLASS lcl_event_handler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS: on_close FOR EVENT on_close OF zcl_es_splash_screen.
    ENDCLASS. "lcl_event_handler DEFINITION
    CLASS lcl_event_handler IMPLEMENTATION
    CLASS lcl_event_handler IMPLEMENTATION.
      METHOD on_close.
        IF sy-dynnr = 2009.
          LEAVE PROGRAM.
        ELSE.
          MOVE abap_false TO first.
          PERFORM (piccallback) IN PROGRAM (sy-cprog).
        ENDIF.
      ENDMETHOD. "on_close
    ENDCLASS. "lcl_event_handler IMPLEMENTATION
    DATA: splash TYPE REF TO zcl_es_splash_screen.
    *&      Module  STATUS_0806  OUTPUT
    MODULE status_0806 OUTPUT.
      IF first IS INITIAL.
        first = abap_true.
        SET TITLEBAR 'TITLE0806'.
        CREATE OBJECT splash
            EXPORTING
              i_num_secs = pictimeout
              i_url      = graphic_url
              i_width    = picwidth
              i_height   = picheight.
        SET HANDLER lcl_event_handler=>on_close FOR splash.
      ENDIF.
    ENDMODULE.                " STATUS_0806  OUTPUT
    *&      Module  STATUS_2009  OUTPUT
    MODULE status_2009 OUTPUT.
      IF first IS INITIAL.
        first = abap_true.
        SET TITLEBAR 'TITLE2009'.
        CREATE OBJECT splash
            EXPORTING
              i_num_secs = pictimeout
              i_url      = graphic_url
              i_width    = picwidth
              i_height   = picheight.
        SET HANDLER lcl_event_handler=>on_close FOR splash.
      ENDIF.
    ENDMODULE.                " STATUS_2009  OUTPUT
    *&      Form  getpicurl
    FORM getpicurl.
      OPEN DATASET g_name FOR INPUT IN BINARY MODE.
      REFRESH graphic_table.
      CLEAR   g_filesz.
      DO.
        CLEAR graphic_line.
        READ DATASET g_name INTO graphic_line ACTUAL LENGTH g_linesz.
        ADD g_linesz TO g_filesz.
        APPEND graphic_line TO graphic_table.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
      ENDDO.
      CLOSE DATASET g_name.
      CLEAR graphic_url.
      CALL FUNCTION 'DP_CREATE_URL'
        EXPORTING
          type                 = 'IMAGE'
          subtype              = 'GIF'
        TABLES
          data                 = graphic_table
        CHANGING
          url                  = graphic_url
        EXCEPTIONS
          dp_invalid_parameter = 1
          dp_error_put_table   = 2
          dp_error_general     = 3
          OTHERS               = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        EXIT.
      ENDIF.
    ENDFORM.                    "getpicurl
    Extracted by Direct Download Enterprise version 1.2 - E.G.Mellodew. 1998-2004 UK.

  • 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

  • Splash Screen that fades in smoothly...

    Is there some code somewhere?
    Or how can I realize that with Swing?
    Hope you can help me... ;)
    Greetz
    Sambale

    Ok... Guess you didn't understand it right...
    I want my splash screen to fade smoothly from 0%
    (invisible) over 50 % (semi-invisible) to 100%
    (full).
    It means I need a method just like setTransparency(
    values from 0 to 100).
    D'you know what I mean?The top level Java components (Frame and Window) are always 100% opaque. In order to do what you want you have to use the java.awt.Robot class to grab a snapshot of the background where the splash screen will be displayed and then paint your semi-transparent image over the top of it using a thread and AlphaComposite to tweak the transparency over time. Not 100% accurate but good enough to fool most people. Here's an example showing the concepts.
    import java.awt.AWTException;
    import java.awt.AlphaComposite;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.awt.Point;
    import java.awt.Rectangle;
    import java.awt.Robot;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.IOException;
    import java.net.URL;
    import javax.imageio.ImageIO;
    import javax.swing.JPanel;
    import javax.swing.JWindow;
    import javax.swing.Timer;
    public class FadeImagePanel extends JPanel {
            private Image image;  
            private Image bgImage;
            private float alpha = 0.0f;
            private Dimension PREF_SIZE;
            FadeImagePanel(URL imageLocation) throws IOException {
                this.image = ImageIO.read(imageLocation);
                initialize();
            private void initialize() {
                captureBackground();
                startAnimation();
            private void startAnimation() {
                Thread t = new Thread(new Runnable() {
                    public void run() {
                        while (alpha < 1.0f) {
                            try {
                                Thread.sleep(20);
                                repaint();
                                alpha += 0.05f;
                                if (alpha > 1.0f) {
                                    alpha = 1.0f;
                            } catch (InterruptedException ie) {
                                ie.printStackTrace();
                t.start();
            public Point getPreferredSplashLocation() {
                Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
                int w = screenSize.width;
                int h = screenSize.height;
                int x = (w - image.getWidth(this))/2;
                int y = (h - image.getHeight(this))/2;
                return new Point(x,y);
            private void captureBackground() {
                Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
                int w = screenSize.width;
                int h = screenSize.height;
                int x = (w - this.getPreferredSize().width)/2;
                int y = (h - this.getPreferredSize().height)/2;
                Rectangle splashRectangle = new Rectangle(x,y,w,h);
                try {
                    Robot r = new Robot();
                    bgImage = r.createScreenCapture(splashRectangle);
                } catch (AWTException awte) {
                    awte.printStackTrace();
            protected void paintComponent(Graphics g) {
                Graphics2D g2d = (Graphics2D)g;
                g2d.drawImage(bgImage, 0, 0, this);
                AlphaComposite comp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
                g2d.setComposite(comp);
                g.drawImage(image, 0, 0, this);
            public Dimension getPreferredSize() {
                if (PREF_SIZE == null) {
                    PREF_SIZE = new Dimension(image.getWidth(this), image.getHeight(this));
                return PREF_SIZE;
            public static void main(String[] args) throws IOException {
                final JWindow window = new JWindow();
                URL imageURL = FadeImagePanel.class.getResource("splash.png");
                FadeImagePanel fip = new FadeImagePanel(imageURL);
                window.add(fip);
                window.pack();
                window.setLocation(fip.getPreferredSplashLocation());
                window.setVisible(true);
                new Timer(3000, new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        System.exit(0);
                }).start();
        }         

  • How can i calculate the percentages and update the progressBar in the splash screen form ?

    I created a splash screen form:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    using System.Threading;
    namespace GetHardwareInfo
    public partial class SplashScreen : Form
    public SplashScreen()
    InitializeComponent();
    private Mutex mutex = new Mutex();
    public void SyncedClose()
    mutex.WaitOne();
    this.Close();
    mutex.ReleaseMutex();
    public void UpdateProgressBar(int percentage)
    if (this.InvokeRequired)
    mutex.WaitOne();
    if (!IsDisposed)
    this.BeginInvoke(new Action<int>(UpdateProgresPRV), percentage);
    mutex.ReleaseMutex();
    else
    UpdateProgresPRV(percentage);
    private void UpdateProgresPRV(int per)
    if (progressBar1.IsDisposed) return;
    progressBar1.Value = per;
    private void SplashScreen_Load(object sender, EventArgs e)
    The SplashScreen form have in the designer image and on the image a progressBar1.
    Then in form1 i did in the top:
    List<string> WmiClassesKeys = new List<string>();
    IEnumerable<Control> controls;
    string comboBoxesNames;
    SplashScreen splash = new SplashScreen();
    And in the constructor:
    controls = LoopOverControls.GetAll(this, typeof(ComboBox));
    string[] lines = File.ReadAllLines(@"c:\wmiclasses\wmiclasses1.txt");
    foreach (string line in lines)
    foreach (ComboBox comboBox in controls.OfType<ComboBox>())
    if (line.StartsWith("ComboBox"))
    comboBoxesNames = line.Substring(14);
    else
    if (line.StartsWith("Classes"))
    if (comboBox.Name == comboBoxesNames)
    comboBox.Items.Add(line.Substring(14));
    foreach (ComboBox comboBox in controls.OfType<ComboBox>())
    comboBox.SelectedIndex = 0;
    The method GetAll is to loop over specific controls:
    public static IEnumerable<Control> GetAll(Control control, Type type)
    var controls = control.Controls.Cast<Control>();
    return controls.SelectMany(ctrl => GetAll(ctrl, type))
    .Concat(controls)
    .Where(c => c.GetType() == type);
    When i'm running the program it's taking some time to make the foreach loops in this time i need to show the SplashScreen and update the progressBar untill the foreach loops over.

    Don't use Application.Doevents. It's not required and can cause problems.
    I do not really grasp the approach you are taking here. So let me make a different suggestion:
    SplashScreen:
    using System;
    using System.Windows.Forms;
    using System.Threading;
    namespace WindowsFormsApplication1
    public partial class SplashScreen : Form
    private static SplashScreen DefaultInstance;
    public SplashScreen()
    InitializeComponent();
    public static void ShowDefaultInstance()
    Thread t = new Thread(TMain);
    t.Name = "SplashUI";
    t.Start();
    public static void CloseDefaultInstance()
    DefaultInstance.Invoke(new Action(DefaultInstance.Close));
    private static void TMain()
    DefaultInstance = new SplashScreen();
    DefaultInstance.Show();
    Application.Run(DefaultInstance);
    public static void UpdateProgress(int Progress)
    if (DefaultInstance.InvokeRequired)
    DefaultInstance.Invoke(new Action<int>(UpdateProgress), Progress);
    else
    DefaultInstance.progressBar1.Value = Progress;
    Form1:
    using System.Windows.Forms;
    namespace WindowsFormsApplication1
    public partial class Form1 : Form
    public Form1()
    InitializeComponent();
    SplashScreen.ShowDefaultInstance();
    for (int i = 1; i<=100; i++)
    System.Threading.Thread.Sleep(20); // simulates work
    SplashScreen.UpdateProgress(i);
    SplashScreen.CloseDefaultInstance();
    EDIT: Please note that the progressbar itself is being animated by the system, so it might look slower than it really is. To workaround this, there are solutions available (you'll find them) that first set the value one higher than necessary, then
    back to the actual value.
    Edit #2: You do need a different thread, otherwise the UI is locked while the loop is running in your Form1's constructor.
    Armin

Maybe you are looking for

  • How to restore missing apps after a itunes sync?

    Have iPhone 4   iOS 4.2.8 To install an app (Skype), my phone recommended I do it thru iTunes 10.5.2 (via usb tether) Checked the sync box, selected the Skype app after I downloaded it in iTunes. The sync process went thru a bunch of 'finding, removi

  • PDF Document Display Issue - iPad Mini iOS 8.1

    I use my iPad heavily doing in-home sales. I rely on a combination of Box, PDF Expert, and Notability to retrieve and create information/documents. After updating my iPad Mini to iOS 8, I started having a display issue when trying to pull up my price

  • Where is idvd in OS x Lion?

    Where is idvd in OS x Lion?

  • 70" Vizio smart tv

    I purchased a 70" vizio smart tv for 2000.00 about a year ago from best buy. While purchasing the television the sales rep asked me if I wanted to purchse the warranty plan that included accidental coverage (this happened when bb had black tie). I pa

  • SQL Command Object

    We are in the process of migrating reports from SSRS to Crystal 2011. In SSRS we are able to paste complex SQL into reports as the data source for the report (e.g. multiple CTE's, correlated subqueries, temp tables, etc). It appears that we can accom