Add button \ Applet viewer. java

Source: Internet
Author: User

<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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.