Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
352 views
in Technique[技术] by (71.8m points)

java - 如何在Java Applet中创建功能? [关闭](How to create features in a Java Applet? [closed])

I'm creating a simple program that Add, Update, Delete in Java Applet.

(我正在创建一个简单的程序,可以在Java Applet中添加,更新,删除。)

I created this using Java form

(我使用Java表单创建的)

how to create it using Applet?

(如何使用Applet创建它?)

package MyApplet;

import java.applet.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.*;


public class MyApplet extends Applet implements ActionListener {
     TextField t1 = new TextField();
     TextField t2 = new TextField();
     TextField t3 = new TextField();
     Label l1 = new Label("Student Name");
     Label l2 = new Label("Student ID");
     Label l3 = new Label ("Information");

    public MyApplet(){
    setLayout(new GridLayout(3,2));
    button1 = new Button("Add");
    button2 = new Button("Update");
    button3 = new Button("Delete");
       add(l1);
       add(l2);
       add(l3);
       add (t1);
       add (t2);
       add (t3);
       add(button1);
       add(button2);
       add(button3);
       t2.addActionListener(this);
    button1.addActionListener(this);    
    button2.addActionListener(this);
    button3.addActionListener(this);}
@Override
public void actionPerformed(ActionEvent ae) {
    String s1 = t1.getText();
    String s2 = t2.getText();

            if (ae.getSource() == button1){
                        t3.setText(s1+" "+s2);
                        t1.setText("");
                        t2.setText("");
                    } 
                    if (ae.getSource() == button2){
                        t3.setText(s1+" "+s2);
                        t1.setText("");
                        t2.setText("");
                    }
                    if (ae.getSource() == button3){
                        t3.setText("");
                    } }
    Button button1, button2, button3;
}   

I read somewhere that Applet is outdated, but I need this to pass this semester.

(我在某个地方读到Applet已过时,但我需要这个才能通过本学期。)

  ask by bonbon translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...