📄 tha.java
字号:
import java.awt.*;
import java.awt.Graphics;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
/*public class arc extends JFrame implements Runnable
{
aa a5=new aa();
public arc()
{
setTitle("shan xing");
getContentPane().setLayout(new GridLayout(2,2,2,2));
JPanel a1=new JPanel();
JPanel a2=new JPanel();
JPanel a3=new JPanel();
JPanel a4=new JPanel();
a1.add(a5);
a2.add(a5);
a3.add(a5);
a4.add(a5);
getContentPane().add(new aa());
getContentPane().add(new aa());
getContentPane().add(new aa());
getContentPane().add(new aa());
}
public static void main (String[] args)
{
arc yy=new arc();
yy.setVisible(true);
yy.setSize(500,600);
yy.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}*/
class aa extends JPanel
{
public int x,y;
public void setaa(int x,int y)
{
this.x=x;
this.y=y;
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
int i,j,k;
i=getSize().width/2;
j=getSize().height/2;
k=(int)(Math.min(getSize().width,getSize().height)*0.4);
i=i-k;
j=j-k;
g.setColor(Color.red);
g.fillArc(i,j,2*k,2*k,0+x,30);
g.fillArc(i,j,2*k,2*k,90+x,30);
g.fillArc(i,j,2*k,2*k,180+x,30);
g.fillArc(i,j,2*k,2*k,270+x,30);
}
}
public class tha extends Panel implements Runnable
{
aa a5;
int time;
public tha(int time,aa a5)
{
this.a5=a5;
this.time=time;
Thread th=new Thread(this);
//JFrame jf=new JFrame("fan san si ");
// getContentPane().setLayout(new GridLayout(2,2));
// add(a5);
// getContentPane().add(a6);
// getContentPane().add(a7);
// getContentPane().add(a8);
// jf.setVisible(true);
// jf.setSize(500,600);
th.start();
}
public void run()
{
for(int i=0;;i++)
{
try
{
a5.setaa(i,i);
//a6.setaa(i,i);
//a7.setaa(i,i);
// a8.setaa(i,i);
a5.repaint();
// a6.repaint();
// a7.repaint();
// a8.repaint();
Thread.sleep(time);
}
catch(InterruptedException e)
{
}
}
}
public static void main (String[] args)
{
aa a6=new aa();
aa a7=new aa();
aa a8=new aa();
aa a1=new aa();
tha yy1=new tha(10,a1);
tha yy2=new tha(1,a6);
tha yy3=new tha(100,a7);
tha yy4=new tha(1000,a8);
JFrame yy=new JFrame("ni hao");
yy.getContentPane().setLayout(new GridLayout(2,2));
yy.setVisible(true);
yy.setSize(500,600);
yy.getContentPane().add(a1);
yy.getContentPane().add(a6);
yy.getContentPane().add(a7);
yy.getContentPane().add(a8);
yy.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -