这个只是一个类而已,不知直接可以看出来的
需要有main方法的才行啊

解决方案 »

  1.   


       import javax.swing.*;
       import javax.swing.border.*;
       import java.awt.*;
       import java.awt.event.*;public class JSplash extends JWindow
    implements KeyListener, MouseListener, ActionListener {
     
    /*
     *  JSplash constructs a splash screen (JWindow).
     * parent is the parent frame for the window
     * filename is the JPEG/GIF file to show as the splash
     * timeout is time in milliseconds to display the splash
     */
    public JSplash(JFrame parent, String filename, int timeout) { 
    super(parent); 

    // Note, this code does no error checking
    ImageIcon image = new ImageIcon(filename); 
    // The splash will be centered on the screen
    int w = image.getIconWidth() + 5; 
    int h = image.getIconHeight() + 5; 
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); 
    int x = (screen.width - w) / 2; 
    int y = (screen.height - h) / 2; 
    setBounds(x, y, w, h); 

    getContentPane().setLayout(new BorderLayout()); 
    JLabel picture = new JLabel(image); 
    getContentPane().add("Center", picture); 
    picture.setBorder(new BevelBorder(BevelBorder.RAISED)); 

    // Listen for key strokes 
    addKeyListener(this); 
    // Listen for mouse events from here and parent 
    addMouseListener(this); 
    parent.addMouseListener(this); 
    // Timeout after a while 
    Timer timer = new Timer(0, this); 
    timer.setRepeats(false); 
    timer.setInitialDelay(timeout); 
    timer.start(); 


    // This method is called in order to block the application until
    // the splash screen times out or is dismissed.
    // This is a bit of a kludge, actually, and the actual affect
    // varies based on platform.
    public void block() { 
    while(isVisible()) {} 


    // Dismiss the window on a key press, ignore rest.
    public void keyTyped(KeyEvent event) {} 
    public void keyReleased(KeyEvent event) {} 
    public void keyPressed(KeyEvent event) { 
    setVisible(false); 
    dispose(); 


    // Dismiss the window on a mouse click, ignore rest.
    public void mousePressed(MouseEvent event) {} 
    public void mouseReleased(MouseEvent event) {} 
    public void mouseEntered(MouseEvent event) {} 
    public void mouseExited(MouseEvent event) {} 
    public void mouseClicked(MouseEvent event) { 
    setVisible(false); 
    dispose(); 
    }

    // Dismiss the window on a timeout 
    public void actionPerformed(ActionEvent event) { 
    setVisible(false); 
    dispose(); 

    public static void main(String[] args) 
    {
    System.out.println("你 少 了 main 函数");
    }

      

  2.   

    楼上的兄弟,你没有main函数怎么能跑呢
      

  3.   

    啊,我知道了,这是一个类,不可以单独运行~谢谢大家~
       
        哪位大虾可以帮我写完整的main程序,将这个效果运行出来呢~~~再次谢谢了~