Java中Applet小程序的编写

2024-11-19 01:42:31
推荐回答(5个)
回答(1):

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class L07_D extends Applet implements ActionListener{
public void init() {
Button one;
Button two;
one = new Button("Button one");
two = new Button("Button two");
add(one);add(two);
one.addActionListener(this);
two.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
showStatus("One of my buttons was clicked.");
}
}

回答(2):

我写了一个
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.applet.*;

public class Body extends Applet implements ActionListener {
public void init() {

Button two = new Buttons("Button two", this);
Button one = new Buttons("Button one", this);

two.addActionListener(this);
one.addActionListener(this);
this.add(two);
this.add(one);
}

@Override
public void actionPerformed(ActionEvent e) {
Buttons c = (Buttons) e.getSource();
c.b.showStatus("One of the button is clicked");

}

class Buttons extends Button {
String name;
Body b;

Buttons(String name, Body a) {
super(name);
this.b = a;
}
}

public static void main(String[] args) {
Body b = new Body();
b.init();
}
}

回答(3):

这发不过去啊!

回答(4):

代码不多,要得话Call我

回答(5):

hsdsjdkasajska/idsidjasda.dasjakjshajh