zoukankan      html  css  js  c++  java
  • 16.16

     1 import java.awt.Graphics;
     2 import java.awt.event.ActionEvent;
     3 import java.awt.event.ActionListener;
     4 
     5 import javax.swing.*;
     6 
     7 
     8 
     9 public class Test_16_16 extends JFrame{
    10     
    11     public Test_16_16(){
    12         add(new JP());
    13     }
    14     public static void main(String[] args) {
    15         // TODO Auto-generated method stub
    16         Test_16_16 frame = new Test_16_16();        
    17         frame.setSize(300,220);
    18         frame.setTitle("Test_16_16");
    19         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    20         frame.setLocationRelativeTo(null); // Center the frame
    21         frame.setVisible(true); 
    22     }
    23     
    24     static class JP extends JPanel{
    25         private boolean visi = true;
    26         
    27         public JP(){
    28             Timer timer = new Timer(1000,new TimerListener());
    29             timer.start();
    30         }
    31         protected void paintComponent(Graphics g){
    32             super.paintComponent(g);
    33             if(visi == true)
    34                 g.drawImage(new ImageIcon("image/flag4.gif").getImage(), 0, 0, this);
    35         }
    36         class TimerListener implements ActionListener{
    37 
    38             @Override
    39             public void actionPerformed(ActionEvent arg0) {
    40                 // TODO Auto-generated method stub
    41                 if(visi == true) visi = false;
    42                 else visi = true;
    43                 repaint();
    44             }
    45             
    46         }
    47     }
    48 }
    Test_16_16.java
  • 相关阅读:
    前端HTMLCSS
    jedis 连接池的使用
    win8+安装net3.5步骤与常见错误.
    并行线程的生命周期
    OneNote截图快捷键冲突解决方案
    C#中lsitView如何搜索某个子项
    redis哨兵与集群
    git笔记
    微软官方Hololens开发课程介绍
    Markdown使用入门简介
  • 原文地址:https://www.cnblogs.com/wanjiang/p/5657462.html
Copyright © 2011-2022 走看看