<applet code=ButtonApplet.class width=400 height=300></applet>import java.awt.*;import java.applet.*;p ublic class buttonapplet extends applet{ int x,y; Button Bt; public buttonapplet ()//Join button { x=y=100; bt=new button ("Press Me"); add ("Center", Bt); } public void paint (graphics g) { g.drawstring ("Faint", x, y); } public boolean action (EVENT&NBSP;EV,OBJECT&NBSP;ARG)//Trigger applet, can click button, string swap position { if (Ev.target instanceof button) { if (x>=200) x=0; else x+=20; if (y<=200) y =200; else y-=10; repaint (); } return true; }}
Operation Result:
650) this.width=650; "src=" http://img.blog.csdn.net/20150724144448636 "alt=" here write a picture describing "title=" "/>
650) this.width=650; "src=" http://img.blog.csdn.net/20150724144516764 "alt=" here write a picture describing "title=" "/>
This article is from the "Sanghaidan blog column" blog, please be sure to keep this source http://10602803.blog.51cto.com/10592803/1683073
Add button \ Applet viewer. java