D
dj
Gast
Kann mir bitte einer erklären wie man einem Button ein ereignis gibt? ich werke an dieser simplen aufgabe schon 4 tage herum... es sollte ein button für swing sein, und nicht für ein applet. ich wäre euch sehr dankbar!
Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
import java.awt.event.*;
...
...
class MeineKlasse extends JFrame implements ActionListener {
... }
...
public void actionPerformed(ActionEvent ae) {
}
...
...
meinButton.addActionListener(this);
...
...
if(ae.getSource() == meinButton) {
//Mach was
}
else if(ae.getSource() == andererButton) {
//Mach was anderes
}
dj hat gesagt.:es sollte ein button für swing sein, und nicht für ein applet.