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,302 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
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now