博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
head first java 195,head first java解决办法
阅读量:6903 次
发布时间:2019-06-27

本文共 765 字,大约阅读时间需要 2 分钟。

Java codepackage simpleAnimation;

import javax.swing.*;

import java.awt.*;

public class SimpleAnimation

{

int x=70;

int y=70;

public static void main(String[] args)

{

SimpleAnimation gui=new SimpleAnimation();

gui.go();

}

public void go()

{

JFrame frame=new JFrame();

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

MyDrawPanel drawPanel=new MyDrawPanel();

frame.getContentPane().add(drawPanel);

frame.setSize(300,300);

frame.setVisible(true);

for(int i=0;i<130;i++)

{

x++;

y++;

drawPanel.repaint();

try

{

Thread.sleep(50);

}

catch(Exception ex)

{}

}

}

class MyDrawPanel extends JPanel

{

public void paintComponet(Graphics g)

{

g.setColor(Color.white);

g.fillRect(0, 0, this.getWidth(), this.getHeight());

g.setColor(Color.green);

g.fillOval(x,y,40,40);

}

}

}

转载地址:http://jtodl.baihongyu.com/

你可能感兴趣的文章
Leetcode-探索 | 移动零
查看>>
DBI 数据库模块剖析:Perl DBI 数据库通讯模块规范,工作原理和实例
查看>>
Tesseract+opencv+VS+win实现OCR
查看>>
android在activity中锁屏解锁后重走OnCreate的问题的解决办法
查看>>
[学习笔记]博弈论
查看>>
python os sys模块(二)
查看>>
一次linux启动故障记录
查看>>
linux 3.10内核 xfs的一次io异常导致的hung crash
查看>>
Castle ActiveRecord学习笔记(转)
查看>>
springboot+mybatis环境的坑和sql语句简化技巧
查看>>
Keil C编译器的变量存储分配
查看>>
非常不错的js 屏蔽类加验证类
查看>>
Innodb间隙锁,细节讲解(转)
查看>>
Apache安装
查看>>
C语言练习题库----数组
查看>>
nginx虚拟主机配置
查看>>
关于对char类型数据赋予负值的汇编表现
查看>>
润乾报表在proxool应用下的数据源配置
查看>>
Python基础23_os,sys,序列化,pickle,json
查看>>
python MVC、MTV 框架介绍 Django 模板系统常用语法
查看>>