Link to home
Start Free TrialLog in
Avatar of richardsimnett
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(progress,0);
        getContentPane().add(l, BorderLayout.CENTER);
        //getContentPane().add(progress);
        pack();
        Dimension screenSize =
          Toolkit.getDefaultToolkit().getScreenSize();
        Dimension labelSize = l.getPreferredSize();
        setLocation(screenSize.width/2 - (labelSize.width/2),
                    screenSize.height/2 - (labelSize.height/2));
        setVisible(true);
        screenSize = null;
        labelSize = null;
  }
 
  void closeSplash()
  {
      setVisible(false);
      dispose();
  }
}


Thanks,
Rick
ASKER CERTIFIED SOLUTION
Avatar of valipotor
valipotor

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial