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.");
}
}
我写了一个
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();
}
}
这发不过去啊!
代码不多,要得话Call我
hsdsjdkasajska/idsidjasda.dasjakjshajh