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
1,310 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 500 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SHA2 certs for IIS AND Java? 2 122
jmss example java 2 33
Print Rhino Java Array in Javascript 1 39
netbeans can not run self signed app 8 14
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

726 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