[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

Custom Made SplashScreen class unusual behaviour.

Asked by prain in Java Standard Edition, Java Programming Language, Programming Languages

Tags: java, screen, splash, custom

Hello,
I have a terrible problem....

I am really working on Java 1.5. So I cannot use the SplashScreen class given in java 1.6. Therefore I picked up a SplashScreen class written by some on the net and tailored it. I run the SpalshScreen INDEPENDENTLY. That works great.

Then I created a separate JFrame and at the close of the frame (at the click of the X button at the Top RHS corner), I I am triggering the WindowClosing event and sopposed to see the SpalshScreen pops up. But this is how it behaves ....

1. In Java 1.5 - Only a white background displays and after the time out it goes away.

2. In Java 1.6 nothing is displayed, but at the timeout the main window who invokes the Spash exits.

My question is....
WHY IS THAT THE INDEPENDENT SplashScreen works and when Attached it behaves weiredly.

Here is the code of SplashScreen. Just compile and run this. Then I have the small window I have created to trigger the SplashScreen. That also in here for you to test out.

import java.awt.*;
import javax.swing.*;

public class SplashScreen extends JWindow {
  private int duration;
  public SplashScreen(int d) {
    duration = d;
  }

  // A simple little method to show a title screen in the center
  // of the screen for the amount of time given in the constructor
  public void showSplash() {
    JPanel content = (JPanel)getContentPane();
    content.setBackground(Color.white);

    // Set the window's bounds, centering the window
    int width = 450;
    int height =115;
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screen.width-width)/2;
    int y = (screen.height-height)/2;
    setBounds(x,y,width,height);

    // Build the splash screen
    JLabel label1 = new JLabel("Shutting down.....", JLabel.CENTER);
   
    label1.setFont(new Font("Sans-Serif", Font.BOLD, 12));
    content.add(label1, BorderLayout.NORTH);
   
   
    JPanel messagePanel = new JPanel(new GridLayout(2, 1));
    messagePanel.setBackground(Color.yellow);
    messagePanel.setPreferredSize(new Dimension(100, 30));
    JLabel label2 = new JLabel ("Closing Connection at port xxxx...", JLabel.CENTER);
    label2.setFont(new Font("Sans-Serif", Font.BOLD, 12));
    messagePanel.add(label2, BorderLayout.SOUTH);
   
    JLabel label3 = new JLabel ("Closing Connection at port yyyy...", JLabel.CENTER);
    label3.setFont(new Font("Sans-Serif", Font.BOLD, 12));
    messagePanel.add(label3, BorderLayout.SOUTH);
   
    content.add(messagePanel, BorderLayout.CENTER);
   
    JLabel label4 = new JLabel ("xxxxxxxxxx Version 1.0", JLabel.CENTER);
   
    label4.setFont(new Font("Sans-Serif", Font.BOLD, 12));
    content.add(label4, BorderLayout.SOUTH);
   
    Color oraRed = new Color(156, 20, 20,  255);
    content.setBorder(BorderFactory.createLineBorder(oraRed, 10));

    // Display it
    setVisible(true);

    // Wait a little while, maybe while loading resources
    try { Thread.sleep(duration); } catch (Exception e) {}

    setVisible(false);
  }

  public void showSplashAndExit() {
    showSplash();
    System.exit(0);
  }

  public static void main(String[] args) {
    // Throw a nice little title page up on the screen first
    SplashScreen splash = new SplashScreen(5000);
    // Normally, we'd call splash.showSplash() and get on with the program.
    // But, since this is only a test...
    splash.showSplashAndExit();
  }
}


================================= HERE IS THE TRIGGER CLASS==========
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class PopSplash extends JFrame implements ActionListener
 {
       JButton splashButton;
       
  public PopSplash()
  {
    FlowLayout layout = new FlowLayout();
    this.setLayout(layout);
    this.setTitle("Window 1");
    this.setSize(335, 150);
    this.setLocation(200, 100);
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.addWindowListener(windowClosingListener);

    splashButton = new JButton("Splash");
    splashButton.setPreferredSize(new Dimension(95,30));
    splashButton.addActionListener(this);
 
    this.add(splashButton);
     
  }
 
  public void actionPerformed(ActionEvent aEvent)
  {
   if(aEvent.getSource() == splashButton)
   {
   
   }
  }


 WindowListener windowClosingListener = new WindowAdapter()
   {
      // anonymous WindowAdapter class
    public void windowClosing(WindowEvent w)
    {
     SplashScreen splash = new SplashScreen(5000);
     splash.showSplashAndExit();
     
     } // end windowClosing
   };// end anonymous class

  public static void main(String[] args) {
    PopSplash frame1 = new PopSplash();
    frame1.setVisible(true);
  }
}


Can some one throw some light to this?
[+][-]12/09/07 05:29 PM, ID: 20439019Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Java Standard Edition, Java Programming Language, Programming Languages
Tags: java, screen, splash, custom
Sign Up Now!
Solution Provided By: Computer101
Participating Experts: 2
Solution Grade: A
 
[+][-]09/30/07 10:44 PM, ID: 19988952Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/01/07 05:23 AM, ID: 19990160Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/01/07 02:31 PM, ID: 19994395Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/05/07 11:21 AM, ID: 20414102Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 / EE_QW_1_20070628