<delect id="sj01t"></delect>
  1. <em id="sj01t"><label id="sj01t"></label></em>
  2. <div id="sj01t"></div>
    1. <em id="sj01t"></em>

            <div id="sj01t"></div>
            java語言

            java實現gif動畫效果代碼參考

            時間:2025-01-31 19:04:25 java語言 我要投稿
            • 相關推薦

            java實現gif動畫效果代碼參考

              復制代碼 代碼如下:

              /*

              * Donttai.java

              *

              * Created on __DATE__, __TIME__

              */

              package 動態圖;

              import java.awt.Graphics;

              import java.awt.Image;

              import java.awt.image.ImageObserver;

              import java.io.File;

              import java.io.IOException;

              import javax.imageio.ImageIO;

              /**

              *

              * @author __USER__

              */

              public class Donttai extends javax.swing.JFrame implements Runnable

              {

              /** Creates new form Donttai */

              public Donttai()

              {

              initComponents();

              }

              //String path = "E:WorkspacesMyEclipse_9.020120731bin動態圖110";

              //Java默認文件路徑是項目的根目錄,所以要手動加上bin及其以下的路徑

              String path="bin/動態圖/花好月圓/10";

              int idx = 1;

              public void paint(Graphics g)

              {

              ImageObserver imageObserver = new ImageObserver()

              {

              @Override

              public boolean imageUpdate(Image img, int infoflags, int x, int y,

              int width, int height)

              {

              // TODO Auto-generated method stub

              return false;

              }

              };

              try

              {

              //g.drawImage(ImageIO.read(new File(Donttai.class.getResource("1.png").toString())), 20, 20, imageObserver);

              String temp = "";

              if (idx <= 9)

              temp = path + "0" + idx + ".jpg";

              else if (idx >= 10)

              {

              temp = path + idx + ".jpg";

              }

              g.drawImage(ImageIO.read(new File(temp)), 100, 50, 400, 300,

              imageObserver);

              }

              catch (IOException e)

              {

              // TODO Auto-generated catch block

              e.printStackTrace();

              }

              }

              /** This method is called from within the constructor to

              * initialize the form.

              * WARNING: Do NOT modify this code. The content of this method is

              * always regenerated by the Form Editor.

              */

              //GEN-BEGIN:initComponents

              //

              private void initComponents()

              {

              jButton1 = new javax.swing.JButton();

              setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

              jButton1.setText("jButton1");

              javax.swing.GroupLayout layout = new javax.swing.GroupLayout(

              getContentPane());

              getContentPane().setLayout(layout);

              layout.setHorizontalGroup(layout.createParallelGroup(

              javax.swing.GroupLayout.Alignment.LEADING).addGroup(

              javax.swing.GroupLayout.Alignment.TRAILING,

              layout.createSequentialGroup()

              .addContainerGap(483, Short.MAX_VALUE)

              .addComponent(jButton1).addGap(35, 35, 35)));

              layout.setVerticalGroup(layout.createParallelGroup(

              javax.swing.GroupLayout.Alignment.LEADING).addGroup(

              layout.createSequentialGroup().addGap(37, 37, 37)

              .addComponent(jButton1)

              .addContainerGap(392, Short.MAX_VALUE)));

              pack();

              }//

              //GEN-END:initComponents

              /**

              * @param args the command line arguments

              */

              public static void main(String args[])

              {

              // java.awt.EventQueue.invokeLater(new Runnable()

              // {

              // public void run()

              // {

              // new Donttai().setVisible(true);

              //

              // }

              // });

              Donttai donttai = new Donttai();

              donttai.setVisible(true);

              donttai.run();

              }

              //GEN-BEGIN:variables

              // Variables declaration - do not modify

              private javax.swing.JButton jButton1;

              // End of variables declaration//GEN-END:variables

              @Override

              public void run()

              {

              // TODO Auto-generated method stub

              while (true)

              {

              repaint();

              if (idx < 16)

              idx++;

              else

              idx = 1;

              try

              {

              Thread.sleep(60);

              }

              catch (InterruptedException e)

              {

              // TODO Auto-generated catch block

              e.printStackTrace();

              }

              }

              }

              }

            【java實現gif動畫效果代碼參考】相關文章:

            Fireworks制作GIF動畫效果的技巧02-05

            Java 隊列實現原理及簡單實現代碼03-18

            java利用反射實現動態代理實現代碼05-18

            java構造函數實現代碼示例04-01

            冒泡排序的原理以及java代碼實現12-29

            JavaScript簡單實現放大鏡效果代碼02-21

            何利用PS做出萬花筒gif動畫效果04-11

            冒泡排序算法原理及JAVA實現代碼方法03-20

            推薦刪除JAVA集合中元素的實現代碼07-13

            <delect id="sj01t"></delect>
            1. <em id="sj01t"><label id="sj01t"></label></em>
            2. <div id="sj01t"></div>
              1. <em id="sj01t"></em>

                      <div id="sj01t"></div>
                      黄色视频在线观看