• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1315
  • Last Modified:

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
0
richardsimnett
Asked:
richardsimnett
1 Solution
 
valipotorCommented:
Here is exactly what you need:

http://www.java-tips.org/java-se-tips/javax.swing/how-to-block-mouse-and-key-events-in-an-application.html

It uses the glass pane.

Read more about the    setGlassPane(); method.

Best regards,

valipotor
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now