Article View: borland.public.jbuilder.java.swing
Article #13076Re: how can I make a splash screen?
From: Tad Frysinger
Date: Sat, 03 Oct 1998 00:00
Date: Sat, 03 Oct 1998 00:00
112 lines
3800 bytes
3800 bytes
In article <3614F887.4F69766A@sema4.com>, ahumphreys@sema4.com says...
> I just checked CliffHanger out. It also has a title bar. Is there any way to
> get rid of that title bar?
>
> Tad Frysinger wrote:
>
> > In article <3613DA13.904FE7B5@sema4.com>, ahumphreys@sema4.com says...
> > > I'm trying to create a splash screen for my program. Currently, I have
> > > it set up as a Dialog, but I'd like to make the titlebar invisible. How
> > > can I do that?
> > >
> > > If I can't do that, are there other ways to make a splash screen?
> > >
> > > Thanks.
> > >
> > > Alex
> > >
> > >
> > Check out the CliffHanger demo that ships with JBuilder - it does what
> > you want.
> >
> > Tad Frysinger
> > [TeamB]
>
>
>
>
Sorry about that - I could have sworn it didn't. Anyway - try this:
Here is an example using a 'SplashScreen' object:
public Application1() {
SplashScreen splash = new SplashScreen();
splash.pack();
splash.setVisible(true);
// Assume the Frame is doing work, that takes time. Otherwise you
// could use Thread.sleep() for a delay
Frame1 frame = new Frame1();
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);
// Turn off the splash screen
splash.setVisible(false);
}
And here is the object. I hard-coded the image, which you obviously
wouldn't want to do...
package TestDB;
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.107fe1d3881cd3ed989922@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<3613DA13.904FE7B5@sema4.com> <MPG.107db98a6f768b9989917@forums.borland.com> <3614F887.4F69766A@sema4.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,d59278f18297e0 X-Google-Attributes: gid111d45,public From: tfrysinger@uswest.net (Tad Frysinger) Subject: Re: how can I make a splash screen? Date: 1998/10/03 Message-ID: <MPG.107fe1d3881cd3ed989922@forums.borland.com> X-Deja-AN: 397355893 References: <3613DA13.904FE7B5@sema4.com> <MPG.107db98a6f768b9989917@forums.borland.com> <3614F887.4F69766A@sema4.com> Organization: FreeZone Enterprises Newsgroups: borland.public.jbuilder.java.swing