Article View: borland.public.jbuilder.java.language
Article #17593Re: help with displaying splash screen at start of program...
From: Tad Frysinger
Date: Sat, 24 Oct 1998 00:00
Date: Sat, 24 Oct 1998 00:00
101 lines
3283 bytes
3283 bytes
Here is what I've done:
Usage:
----
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);
}
//Main method
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(
new com.sun.java.swing.plaf.windows.WindowsLookAndFeel());
//UIManager.setLookAndFeel(
new com.sun.java.swing.plaf.motif.MotifLookAndFeel());
}
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\\referen
ce\\cliffhanger\\graphics\\logo.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.109b9358cbbf3ef9989947@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<01bdfec6$139a4920$dfe2bcc0@ITS.city.bloomington.in.us>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,4720e0d8c1bf48cb X-Google-Attributes: gidf74b3,public From: tfrysinger@uswest.net (Tad Frysinger) Subject: Re: help with displaying splash screen at start of program... Date: 1998/10/24 Message-ID: <MPG.109b9358cbbf3ef9989947@forums.borland.com> X-Deja-AN: 404609955 References: <01bdfec6$139a4920$dfe2bcc0@ITS.city.bloomington.in.us> Organization: FreeZone Enterprises Newsgroups: borland.public.jbuilder.java.language