📄 temp.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class temp extends JFrame
{
static int x=0;
Container c;
public temp()
{
c=this.getContentPane();
c.setLayout(new GridLayout(3,1));
c.add(new panel());
c.add(new panel());
c.add(new panel());
this.setSize(200,200);
this.setVisible(true);
}
public static void main(String s[])
{
temp kk=new temp();
}
class panel extends JPanel
{
panel()
{
thread t = new thread();
t.start();
}
public void paint(Graphics g)
{
g.clearRect(0,0,this.getWidth(),this.getHeight());
g.setColor(Color.red);
g.fillOval(x*2,0,20,20);
}
}
class thread extends Thread
{
public void run()
{
while(true)
{
try
{
Thread.sleep(200);
x=x+1;
repaint();
System.out.println(x);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -