当前位置: 技术问答>java相关
applet问题,帮忙看看。高分!
来源: 互联网 发布时间:2015-05-03
本文导语: import java.awt.*; import java.applet.*; import java.awt.event.*; class Mycanvas extends Canvas { int x,y; Mycanvas(int a,int b) { x=a;y=b; getSize(); } public Dimension getPreferedSize() { return new...
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
class Mycanvas extends Canvas
{
int x,y;
Mycanvas(int a,int b)
{
x=a;y=b;
getSize();
}
public Dimension getPreferedSize()
{
return new Dimension(200,100);
}
public void paint(Graphics g)
{
g.setColor(Color.red);
g.fillOval(50,50,4*x,4*y);
g.drawString("我是第 "+x,20,90);
}
}
public class Mycode1 extends Applet implements ActionListener
{
CardLayout mycard;
Button button1,button2,button3;
Mycanvas mycanvas[];
Panel p1,p2;
public void init()
{
setLayout(new BorderLayout());//Applet的布局
mycard=new CardLayout();
p1=new Panel();
p1.setLayout(mycard);
button1=new Button("first");
button2=new Button("next");
button3=new Button("last");
for(int i=1;i
import java.applet.*;
import java.awt.event.*;
class Mycanvas extends Canvas
{
int x,y;
Mycanvas(int a,int b)
{
x=a;y=b;
getSize();
}
public Dimension getPreferedSize()
{
return new Dimension(200,100);
}
public void paint(Graphics g)
{
g.setColor(Color.red);
g.fillOval(50,50,4*x,4*y);
g.drawString("我是第 "+x,20,90);
}
}
public class Mycode1 extends Applet implements ActionListener
{
CardLayout mycard;
Button button1,button2,button3;
Mycanvas mycanvas[];
Panel p1,p2;
public void init()
{
setLayout(new BorderLayout());//Applet的布局
mycard=new CardLayout();
p1=new Panel();
p1.setLayout(mycard);
button1=new Button("first");
button2=new Button("next");
button3=new Button("last");
for(int i=1;i