Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JFrame not showing components

jdevmt999Jan 25 2015 — edited Jan 29 2015

I'm adding a splash screen as an undecorated JFrame to an existing application.  This existing application was originally developed with Java 6.  Recently I upgraded my Eclipse IDE to Java 8.  When I rebuilt my existing application in Java before making any changes the original JFrame for the main window displayed and functioned fine.  Then I added a new JFrame as a splash screen.  I added several JLabel components to this new JFrame (one to display an image and two to display release and programmer information).  I display this JFrame before the original JFrame, sleep for 10 sec and then display the original JFrame.  When the JFrame I'm using for the splash screen is displayed, none of the components are visible.  When the sleep expires I set the visibility of the splash screen to false, call dispose on the splash screen object and then construct the JFrame main frame, the original JFrame from the existing Java 6 app.  The main JFrame display fine, all the components are visible.

I am including the code for the new splash screen JFrame below.

Can someone tell what is going on?

Thanks

Source Code:

import java.awt.*;

import javax.swing.*;

 

public class MeasurementSplashScreen extends JFrame

 

public MeasurementSplashScreen( )

 

//setUndecorated(true);

Toolkit toolkit = Toolkit.getDefaultToolkit( );

Dimension screenSize = toolkit.getScreenSize( );

setSize(screenSize.width / 2, screenSize.height / 2);

 

setTitle("Grain Size Measurement");

 

JPanel splashMainPanel = new JPanel(new BorderLayout());

ImageIcon splashImage = new ImageIcon("C:\\Geology\\Research\\ComputationalGeology\\DigitalGrainSizeMeasurement\\SplashImages\\GSMSplashScreenImage.jpg");

JLabel splashImageLabel = new JLabel(splashImage);

splashMainPanel.add(splashImageLabel, BorderLayout.CENTER);

JPanel splashInfoPanel = new JPanel(new GridLayout(2, 1));

JLabel splashReleaseLabel = new JLabel("Release V3");

splashReleaseLabel.setHorizontalAlignment(SwingConstants.CENTER);

JLabel splashProgrammersLabel = new JLabel("Developed By: Michael Tarullo and Steve Avon");

splashProgrammersLabel.setHorizontalAlignment(SwingConstants.CENTER);

splashInfoPanel.add(splashReleaseLabel);

splashInfoPanel.add(splashProgrammersLabel);

splashMainPanel.add(splashInfoPanel, BorderLayout.SOUTH);

 

getContentPane().add(splashMainPanel, BorderLayout.CENTER);

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 26 2015
Added on Jan 25 2015
5 comments
2,355 views