On Oct 15, 2005, at 3:01 PM, Bhaskar, KS wrote:

On my win xp machine, the splash screen goes to the background.  Under wine, it stays on top, so yes, it is a wine issue.
--------------------------
Sent from my BlackBerry Wireless Handheld


Is the window hidden, or is it hidden and destroyed? I know this is Java and not Delphi, but here is an example showing how I code a splash screen (obviously, in a real application, I'd do initialization work while the splash screen was displayed, and not just sleep for 2 seconds):


/** Splash.java
* Show splash screen
* @author Greg Woodhouse
*/

//package triton;
import java.awt.*;
import javax.swing.*;

public class SplashScreen extends JWindow {
  public SplashScreen() {
 
    JPanel content = (JPanel)getContentPane();
   
    //Center the window
    int width = 400;
    int height = 350;
    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
        content.setLayout(new BorderLayout());
    JLabel logo = new JLabel(new ImageIcon("Triton.png"));
        JPanel logoPane = new JPanel();
        logoPane.setLayout(new BorderLayout());
        logoPane.add(logo, BorderLayout.CENTER);
        //Use separate panels to simplify layout
        JPanel infoPane = new JPanel();
        JTextArea info = new JTextArea("Triton\n" + "version 0.1\n\n"
        + "This version is a prototype only.");
        info.setEditable(false);
        //Use the same background as the container
        info.setBackground(content.getBackground());
        infoPane.add(info);
    content.add(logoPane, BorderLayout.CENTER);
        content.add(infoPane, BorderLayout.SOUTH);
}

  public void showSplash() {
    setVisible(true);
  }
 
  public void hideSplash() {
    setVisible(false);
  }
}


and here is code from the main class that displays the splash screen

public static void main(String argv[]) {
         SplashScreen splash = new SplashScreen();
         splash.showSplash();
         //Do setup work here
     Triton frame = new Triton();
         //wait 2 seconds
         try {
                 Thread.sleep(2000);
         } catch (Exception ex) { }
         splash.hideSplash();
         splash = null; //no longer needed
         //use EXIT_ON_CLOSE to allow user to quit application by closing window
     frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
     frame.setSize(760,500);
     frame.setVisible(true);
   }

===
Gregory Woodhouse

"Nothing is as powerful than an idea 
whose time has come."
-- Victor Hugo



Reply via email to