code: import java.awt.*; import java.applet.*; class HelloWorldApplet extends Applet{//an applet pu
关键是我的这个小applet编译的正确吗?我是在ubuntu中编译的,只是在javac时,将public去掉了。...
关键是我的这个小applet 编译的正确吗?我是 在ubuntu 中编译 的,只是在javac时,将public 去掉了。
展开
1个回答
展开全部
import java.applet.Applet;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class Test extends Applet {
public static void main(String args[])
{
Test test=new Test();
test.init();
test.start();
Frame f=new Frame();
f.add(test);//只加了这一行
f.setSize(150,150);
f.setVisible(true);
f.addWindowListener(new WindowControl(test));
}
public void paint(Graphics g)
{
g.drawString("成功了",30,30);
}
public void destroy()
{
System.exit(0);
}
}
class WindowControl extends WindowAdapter
{
Applet c;
public WindowControl(Applet c)
{
this.c=c;
}
public void WindowControl(WindowEvent e)
{
c.destroy();
}
}
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class Test extends Applet {
public static void main(String args[])
{
Test test=new Test();
test.init();
test.start();
Frame f=new Frame();
f.add(test);//只加了这一行
f.setSize(150,150);
f.setVisible(true);
f.addWindowListener(new WindowControl(test));
}
public void paint(Graphics g)
{
g.drawString("成功了",30,30);
}
public void destroy()
{
System.exit(0);
}
}
class WindowControl extends WindowAdapter
{
Applet c;
public WindowControl(Applet c)
{
this.c=c;
}
public void WindowControl(WindowEvent e)
{
c.destroy();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询