🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #15473

Re: Splash Screen

#15473
From: Tad Frysinger
Date: Fri, 28 May 1999 00:00
123 lines
3805 bytes
In article <7ift6p$sm9@forums.borland.com>, dillan@geocities.com says...
> Hi
> 
> 
> Can anyone tell me how to write a splash screen.
> 
> 
> Kind regards
> 
> Dillan Fernando
> 
> 
> 

Try this...(with JBuilder 3, run the package migration on the 
splashscreen class)
----
public class Application1 
{
  boolean packFrame = false;
                    
  //Construct the application
  public Application1() 
  {
                    
    SplashScreen splash = new SplashScreen();
    splash.pack();
    splash.setVisible(true);
                    
    Frame1 frame = new Frame1();
    //Validate frames that have preset sizes
    //Pack frames that have useful preferred size info, 
    // e.g. from their layout
    if (packFrame)
       frame.pack();
    else
       frame.validate();
    //Center the window
    Dimension screenSize = 
      Toolkit.getDefaultToolkit().getScreenSize();     
    Dimension frameSize = frame.getSize();
    if (frameSize.height > screenSize.height)
      frameSize.height = screenSize.height;
    if (frameSize.width > screenSize.width)
      frameSize.width = screenSize.width;
    frame.setLocation((screenSize.width - frameSize.width) / 2,
                      (screenSize.height - frameSize.height) / 2);
    frame.setVisible(true);
    splash.setVisible(false);
  }
                     
  public static void main(String[] args) 
  {
     try  
     {
        UIManager.setLookAndFeel(
          new com.sun.java.swing.plaf.windows.WindowsLookAndFeel());
     }
     catch (Exception e) 
     {
     }
     new Application1();
  }
                    
}

----
                     
Here is the class:
                     
----
import borland.jbcl.layout.*;
import borland.jbcl.control.*;
import java.util.*;
import java.awt.*;
                     
public class SplashScreen extends Window 
{
  ImageControl imageControl1 = new ImageControl();
  BorderLayout borderLayout1 = new BorderLayout();
                     
  public SplashScreen() 
  {
     super( new Frame() );
     try 
     {
        jbInit();
     }
     catch (Exception e) 
     {
        e.printStackTrace();
     }
  }
                     
  /**
   * Method generated and maintained by JBuilder designer to initialize   
   * control properties.
   */
  private void jbInit() throws Exception
  {
     this.setSize(new Dimension(200, 250));
     this.setVisible(false);
     imageControl1.setAlignment(borland.jbcl.util.Alignment.CENTER | 
                                borland.jbcl.util.Alignment.MIDDLE);
     imageControl1.setImageName(
     "D:\\JBuilder\\samples\\borland\\reference\\cliffhanger\\graphics\\l
ogo.gif");
     this.setLayout(borderLayout1);
     this.add(imageControl1, BorderLayout.CENTER);
     Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();     
     Dimension frameSize = this.getSize();
     if (frameSize.height > screenSize.height)
        frameSize.height = screenSize.height;
     if (frameSize.width > screenSize.width)
        frameSize.width = screenSize.width;
     this.setLocation((screenSize.width - frameSize.width) / 2, 
                    (screenSize.height - frameSize.height) / 2);
                    
  }
}
                     
                     
Tad Frysinger (TeamB)
Technical Details
Message-ID: <MPG.11b893fde4c48589899ef@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7ift6p$sm9@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,bf0c229ba114cb34
X-Google-Attributes: gidf74b3,public
From: tfrysinger@earthlink.net (Tad Frysinger)
Subject: Re: Splash Screen
Date: 1999/05/28
Message-ID: <MPG.11b893fde4c48589899ef@forums.borland.com>
X-Deja-AN: 483210654
References: <7ift6p$sm9@forums.borland.com>
Organization: Freezone Enterprises
Newsgroups: borland.public.jbuilder.java.language