?
Solved

How do I make this splash screen display a progress bar on top of the loaded image at a specific X,Y position?

Posted on 2006-10-27
1
Medium Priority
?
1,313 Views
Last Modified: 2008-01-09
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
Comment
Question by:richardsimnett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
valipotor earned 2000 total points
ID: 17824740
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month13 days, 20 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question