Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
日食+;Java-Splash窗口_Java_Splash Screen - Fatal编程技术网

日食+;Java-Splash窗口

日食+;Java-Splash窗口,java,splash-screen,Java,Splash Screen,我想用splashWindow开发一个基本的应用程序。 这应该保持5秒,当用户按任意键时,时间需要重置,并再次重新定义时间()5秒。 如果用户不按任何键,飞溅窗口将关闭 public class SplashWindow extends JWindow implements WindowListener, KeyListener { private Container c; SplashWindow() { frase1.setText("test");

我想用splashWindow开发一个基本的应用程序。 这应该保持5秒,当用户按任意键时,时间需要重置,并再次重新定义时间()5秒。 如果用户不按任何键,飞溅窗口将关闭

public class SplashWindow extends JWindow implements WindowListener, KeyListener
{
    private Container c;

    SplashWindow()
    {
        frase1.setText("test");
        Font font12 = new Font ("Courier New", Font.BOLD, 18);
        frase1.setFont(font12);
        frase1.setForeground(Color.WHITE);

        frase2.setText("test2");
        frase2.setFont(font12);
        frase2.setForeground(Color.WHITE);
    }


    public void open( int tempo )
    {

        c = getContentPane();
        c.setLayout(null);

        c.setBackground(Color.black);
        Insets in = Toolkit.getDefaultToolkit().getScreenInsets(this.getGraphicsConfiguration()); 
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        int width = d.width-(in.left + in.top);
        int height = d.height-(in.top + in.bottom);
        this.setSize(width,height);
        this.setLocation(in.left,in.top);

        BorderLayout layout = new BorderLayout();
        c.setLayout(layout);

        c.add(BorderLayout.CENTER, frase1);
        c.add(BorderLayout.PAGE_END, frase2);
        frase1.setHorizontalAlignment(SwingConstants.CENTER);
        frase2.setHorizontalAlignment(SwingConstants.CENTER);


        this.setVisible( true );
        this.addKeyListener(this);

        sleep( tempo );
    }





    /**
     * Aguarda um tempo em milisegundos 
     * @param tempo     int que representa o tempo, em milisegundos, que ser�aguardado.
     * @exception InterruptedException
     * @exception Exception
     * @return void
     */
    private void sleep( int tempo )
    {
        try {
            Thread.sleep( tempo );
        }
        catch( InterruptedException ie ) {
            ie.printStackTrace();
            JOptionPane.showMessageDialog( null, " Erro 00 - Falha no sleep do Splash ", " Erro ", JOptionPane.ERROR_MESSAGE );
        }
        catch( Exception e ) {
            e.printStackTrace();
            JOptionPane.showMessageDialog( null, " Erro 00 - Falha no sleep do Splash ", " Erro ", JOptionPane.ERROR_MESSAGE );
        }
    }

    /**
     * Fecha a janela de splash
     * @return void
     */
    public void close()
    {
        dispose();
    }

    /**
     * @param windowevent
     * @return void
     */
    public void windowOpened( WindowEvent windowevent )
    {
        Graphics2D graphics2d = (Graphics2D)getGlassPane().getGraphics();
        graphics2d.setColor( new Color( 51, 102, 153 ) );
        graphics2d.setFont( new Font( "SansSerif", 0, 16 ) );
    }
    /**
     * @param windowevent
     * @return void
     */
    public void windowActivated( WindowEvent windowevent )
    {
    }
    /**
     * @param windowevent
     * @return coid
     */
    public void windowClosed( WindowEvent windowevent )
    {
    }
    /**
     * @param windowevent
     * @return void
     */
    public void windowClosing( WindowEvent windowevent )
    {
    }
    /**
     * @param windowevent
     * @return void
     */
    public void windowDeactivated( WindowEvent windowevent )
    {
    }
    /**
     * @param windowevent
     * @return void
     */
    public void windowDeiconified( WindowEvent windowevent )
    {
    }
    /**
     * @param windowevent
     * @return void
     */
    public void windowIconified( WindowEvent windowevent )
    {
    }



}
使用功能。这是一本书