Code: Alles auswählen
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class schaltflaeche extends Applet implements ActionListener {
TextField text1;
Button button1;
Button button2;
public void init() {
text1 = new TextField(20);
add(text1);
button1 = new Button("Hier klicken");
add(button1);
button1.addActionListener(this);
button2 = new Button("Meldung 2");
add(button2);
button2.addActionListener(this);
}
public void actionPerformed(ActionEvent event) {
String msg = new String ("I am a Hero");
String mss = new String ("Der 2 Button");
if(event.getSource() == button1) {
text1.setText(msg);
}
if(event.getSource() == button2) {
text1.setText(mss);
}
}
}