一个Java Application运行后,在系统中是作为一个什么来运行的
1个回答
2016-07-28 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
关注
展开全部
用awt做的小球变色、分解与合成的Application程序。
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Calendar;
public class Test1 extends Frame {
private Button bt=new Button("显示");
int x1=0,y1=0,x2=0,y2=0;
long startTime,stopTime;
Rect r=new Rect();
public Test1(){
add(r);
add(bt,BorderLayout.SOUTH);
bt.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
Thread t=new Thread(Test1.this.r);
Calendar c=Calendar.getInstance();
startTime=c.getTimeInMillis();
t.start();
}
});
}
public static void main(String[] args) {
Test1 frame=new Test1();
frame.setSize(300, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}});
}
class Rect extends Panel implements Runnable{
public void paint(Graphics g){
super.paint(g);
g.setColor(Color.RED);
g.fillOval(100,100,20,20);
int green=255-x1*5;
g.setColor(new Color(0,green,0));
g.fillOval(100+x1,100+y1,20,20);
int blue=255+x2*5;
g.setColor(new Color(0,0,blue));
g.fillOval(100+x2,100+y2,20,20);
}
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Calendar;
public class Test1 extends Frame {
private Button bt=new Button("显示");
int x1=0,y1=0,x2=0,y2=0;
long startTime,stopTime;
Rect r=new Rect();
public Test1(){
add(r);
add(bt,BorderLayout.SOUTH);
bt.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
Thread t=new Thread(Test1.this.r);
Calendar c=Calendar.getInstance();
startTime=c.getTimeInMillis();
t.start();
}
});
}
public static void main(String[] args) {
Test1 frame=new Test1();
frame.setSize(300, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}});
}
class Rect extends Panel implements Runnable{
public void paint(Graphics g){
super.paint(g);
g.setColor(Color.RED);
g.fillOval(100,100,20,20);
int green=255-x1*5;
g.setColor(new Color(0,green,0));
g.fillOval(100+x1,100+y1,20,20);
int blue=255+x2*5;
g.setColor(new Color(0,0,blue));
g.fillOval(100+x2,100+y2,20,20);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询