ragazzi ho un problema
ho una classe splashscreen
fin qui tutto okcodice:/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author Mirco */ // SplashScreen.java // 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 = 550; int height =250; 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 label = new JLabel(new ImageIcon("prova.jpg")); JLabel copyrt = new JLabel("connet Mirco", JLabel.CENTER); copyrt.setFont(new Font("Sans-Serif", Font.BOLD, 12)); content.add(label, BorderLayout.CENTER); content.add(copyrt, 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( ); dispose(); } }
poi ho un altra classe di nome Chose con il seguente main
non mi da nessuno errore ma quando lancio il programma non mi viene visualizzato lo splashscreen cioè per 10 secondi il tempo del timer non si vede nulla e poi compare il mio frame chose come nel main... ho controllato il percorso della mia immagine ed il nome ed è tutto ok.. poi se faccio partire la classe splashscreen da sola senza richiamarla da chooser cioè con un main interno ad essa funziona benissimo. cosa sbaglio raga?codice:public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { SplashScreen splash = new SplashScreen(10000); splash.showSplashAndExit( ); Chose f = new Chose(); Dimension screenSize = Toolkit.getDefaultToolkit ().getScreenSize (); Dimension frameSize = f.getSize (); f.setLocation ((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); f.show(); f.loginFalse();

Rispondi quotando