Skip to content

Instantly share code, notes, and snippets.

@Avalarion
Created June 27, 2013 23:54
Show Gist options
  • Save Avalarion/5881407 to your computer and use it in GitHub Desktop.
Save Avalarion/5881407 to your computer and use it in GitHub Desktop.
Kleines Beispiel zum Thema Quellen Angabe bei Javas ActionListener für eine Studentin.
package Test;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Java extends Frame{
public static void main(String[] args) {
Java java = new Java();
}
public Java(){
for(int i = 0; i < 10; i++) {
for(int j = 0; j < 10; j++) {
Button button = new Button(i + ":" + j);
button.setBounds(25*i,25*i,20,20);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
((Button)actionEvent.getSource()).setEnabled(false);
}
});
this.add(button);
}
}
this.setLayout(new FlowLayout());
this.setBounds(500,500,500,500);
this.validate();
this.setVisible(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment