South Mail Java Programming Experiment 2 applet design for small applications

Source: Internet
Author: User

South Mail Java Programming Experiment 2 applet design for small applications


Experimental Purpose:

Students are required to develop the ability to design web browser-based applets by experimenting with learning and understanding Java applets in classroom learning content, and by fostering students to combine Java applet-related knowledge points, including Java and low-level event processing models.


Experimental content:

Design and write an applet applets and corresponding HTML pages that can be manipulated by the mouse, observe the execution of the applet, and test the effect of the user interaction of the program mouse.


Experiment Code:

Java:

Import Java.applet.*;import java.awt.*;import Java.awt.event.*;class JAVA2 extends applet implements actionlistener{Bu    Tton B,c;        public void Init () {label label=new label ("press button:");        B=new button ("button 1");//Construction Buttons B.addactionlistener (this);//Monitor C=new button ("button 2");        C.addactionlistener (this);        Add (label);    Add (b);//Add button to page Add (c); } public void actionperformed (ActionEvent e) {if (E.getsource () ==b) {Frame frame=new frame            ("reminders"); Frame.setsize (230,100);//Set size frame.setlocation (100,100);//Set position Frame.add ("You pressed button 1");//Add Label        Check frame.setvisible (TRUE);//Set whether Frame.validate () is visible;            } else if (E.getsource () ==c) {Frame frame=new frame ("Reminder");            Frame.setsize (230,100);            Frame.setlocation (100,100);            Frame.add ("You pressed button 2");            Frame.setvisible (TRUE); Frame.validate (); }    }}

Html:



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

South Mail Java Programming Experiment 2 applet design for small applications

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.