richardsimnett
asked on
How do I make this splash screen display a progress bar on top of the loaded image at a specific X,Y position?
Hello,
I have a component class that I have take from several threads I found on this site. I need to overlay a JProgressBar on the image that is loaded, and a JLabel so that I can provide text saying what the startup process is doing. I have tried to accomplish this using ZIndexing but it doesnt work. Also how do I statically set the X,Y positions of the ProgressBar and the Jlabel? Can someone tell me how to get the desired effect out of this code?
Worth 500 points.
/*
* JSplash.java
*
* Created on October 28, 2006, 12:18 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
import javax.swing.*;
import java.awt.*;
/**
*
* @author Rick
*/
public class JSplash extends JWindow
{
/** Creates a new instance of JSplash */
JProgressBar progress;
public JSplash(String filename, Frame f)
{
super(f);
JLabel l = new JLabel(new ImageIcon(filename));
progress = new JProgressBar();
l.setComponentZOrder(progr ess,0);
getContentPane().add(l, BorderLayout.CENTER);
//getContentPane().add(pro gress);
pack();
Dimension screenSize =
Toolkit.getDefaultToolkit( ).getScree nSize();
Dimension labelSize = l.getPreferredSize();
setLocation(screenSize.wid th/2 - (labelSize.width/2),
screenSize.height/2 - (labelSize.height/2));
setVisible(true);
screenSize = null;
labelSize = null;
}
void closeSplash()
{
setVisible(false);
dispose();
}
}
Thanks,
Rick
I have a component class that I have take from several threads I found on this site. I need to overlay a JProgressBar on the image that is loaded, and a JLabel so that I can provide text saying what the startup process is doing. I have tried to accomplish this using ZIndexing but it doesnt work. Also how do I statically set the X,Y positions of the ProgressBar and the Jlabel? Can someone tell me how to get the desired effect out of this code?
Worth 500 points.
/*
* JSplash.java
*
* Created on October 28, 2006, 12:18 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
import javax.swing.*;
import java.awt.*;
/**
*
* @author Rick
*/
public class JSplash extends JWindow
{
/** Creates a new instance of JSplash */
JProgressBar progress;
public JSplash(String filename, Frame f)
{
super(f);
JLabel l = new JLabel(new ImageIcon(filename));
progress = new JProgressBar();
l.setComponentZOrder(progr
getContentPane().add(l, BorderLayout.CENTER);
//getContentPane().add(pro
pack();
Dimension screenSize =
Toolkit.getDefaultToolkit(
Dimension labelSize = l.getPreferredSize();
setLocation(screenSize.wid
screenSize.height/2 - (labelSize.height/2));
setVisible(true);
screenSize = null;
labelSize = null;
}
void closeSplash()
{
setVisible(false);
dispose();
}
}
Thanks,
Rick
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.