0

私は Java 1.5 を使用しており、アプリケーションを開始する前にアニメーションを表示し、アプリケーションがロードされたときにアプリケーションを閉じたいと考えています。グーグルで何かを作成しましたが、アニメーションgifを使用しないとアニメーションgifがアニメーションしません。

何が問題で、それを行う方法を知っている体はありますか?

public class SplashFrameSwing extends JFrame{
JPanel contentPane;
JLabel imageLabel = new JLabel();

public SplashFrameSwing(String url) throws IOException {
    try {
        ImageIcon ii = new ImageIcon(url);
        setBackground(new Color(0, 0, 0, 0));
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        contentPane = (JPanel) getContentPane();
        contentPane.setLayout(new BorderLayout());
        setUndecorated(true);
        setSize(new Dimension(ii.getIconWidth(),ii.getIconHeight()));
        imageLabel.setIcon(ii);
        contentPane.add(imageLabel, java.awt.BorderLayout.CENTER);
        this.setLocationRelativeTo(null);
        this.setVisible(true);
    } catch (Exception exception) {
        exception.printStackTrace();
    }
}

public static void main(String... args){
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            try {
                // URL url = new URL("http://i34.photobucket.com/albums/d129/nirendaran/Speed/verify_anim.gif");
                String url = "C:\\Users\\TV\\Pictures\\Icon\\sniffer-prev.gif";
                SplashFrameSwing splash  = new SplashFrameSwing(url);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });
}
}
4

1 に答える 1

0

これは私にとってはうまくいきますが、バージョン 1.7.0_05 を使用しています。

EventQueue.invokeLater(new Runnable(){
  public void run(){
    JLabel label = new JLabel();

    label.setHorizontalAlignment(SwingConstants.CENTER);

    try{
      // URL imageURL = new URL("http://static.ak.fbcdn.net/rsrc.php/v2/yb/r/GsNJNwuI-UM.gif");
      URL imageURL = new URL("http://i34.photobucket.com/albums/d129/nirendaran/Speed/verify_anim.gif");

      label.setIcon(new ImageIcon(imageURL));
    }
    catch (MalformedURLException ex){
      ex.printStackTrace();
    }

    JFrame frame = new JFrame();
    frame.add(label, BorderLayout.CENTER);
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.setMinimumSize(new Dimension(160, 120));
    frame.setVisible(true);
  }
});
于 2012-07-14T23:25:02.453 に答える