zoukankan      html  css  js  c++  java
  • 16.14

     1 import java.awt.*;
     2 import java.awt.event.ActionEvent;
     3 import java.awt.event.ActionListener;
     4 
     5 import javax.swing.*;
     6 
     7 public class Test_16_14 extends JFrame{
     8     
     9     public Test_16_14(){
    10         add(new ImageP());
    11     }
    12     public static void main(String[] args) {
    13         // TODO Auto-generated method stub
    14         Test_16_14 frame = new Test_16_14();
    15             frame.setSize(800, 600);
    16             frame.setTitle("Test_16_14");
    17             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    18             frame.setLocationRelativeTo(null); // Center the frame
    19             frame.setVisible(true);  
    20     }
    21     
    22     class ImageP extends JPanel{        
    23         private ImageIcon imageI = new ImageIcon("image/ca.gif");
    24         private Image image = imageI.getImage();
    25         private int x;
    26         
    27         public ImageP(){
    28             Timer timer = new Timer(1000,new TimerListener());
    29             timer.start();
    30         }
    31         protected void paintComponent(Graphics g){
    32             super.paintComponent(g);
    33             
    34             if(image != null)
    35                 g.drawImage(image, 0, getHeight()-97-x, 193,97,this);
    36             x += 10;
    37         }
    38         
    39         class TimerListener implements ActionListener{
    40             public void actionPerformed(ActionEvent e) {
    41                 // TODO Auto-generated method stub
    42                 repaint();
    43             }  
    44         }
    45     }
    46 }
    Test_16_14.java

    效果图:

  • 相关阅读:
    lumen简单使用exel组件
    VIM 批量注释的两种方法 (转)
    linux时间校准 设置时间为上海时区
    lumen发送邮件配置
    centos 下安装redis 通过shell脚本
    shell 脚本接收参数
    linux设置系统变量
    linux通配符
    UCCI协议[转]
    一种编程范式:对拍编程
  • 原文地址:https://www.cnblogs.com/wanjiang/p/5652143.html
Copyright © 2011-2022 走看看