import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Spiel extends Applet implements ActionListener {
public void init() {
button1 = new Button("Oben Links");
this.add(button1);
button1.addActionListener(this);
button2 = new Button("Oben Mitte");
this.add(button2);
button2.addActionListener(this);
button3 = new Button("Oben Rechts");
this.add(button3);
button3.addActionListener(this);
button4 = new Button("Mitte Links");
this.add(button4);
button4.addActionListener(this);
button5 = new Button("Mitte Mitte");
this.add(button5);
button5.addActionListener(this);
button6 = new Button("Mitte Rechts");
this.add(button6);
button6.addActionListener(this);
button7 = new Button("Unten Links");
this.add(button7);
button7.addActionListener(this);
button8 = new Button("Unten Mitte");
this.add(button8);
button8.addActionListener(this);
button9 = new Button("Unten Rechts");
this.add(button9);
button9.addActionListener(this);
buttonA = new Button("Oben Links");
this.add(buttonA);
buttonA.addActionListener(this);
buttonB = new Button("Oben Mitte");
this.add(buttonB);
buttonB.addActionListener(this);
buttonC = new Button("Oben Rechts");
this.add(buttonC);
buttonC.addActionListener(this);
buttonD = new Button("Mitte Links");
this.add(buttonD);
buttonD.addActionListener(this);
buttonE = new Button("Mitte Mitte");
this.add(buttonE);
buttonE.addActionListener(this);
buttonF = new Button("Mitte Rechts");
this.add(buttonF);
buttonF.addActionListener(this);
buttonG = new Button("Unten Links");
this.add(buttonG);
buttonG.addActionListener(this);
buttonH = new Button("Unten Mitte");
this.add(buttonH);
buttonH.addActionListener(this);
buttonI = new Button("Unten Rechts");
this.add(buttonI);
buttonI.addActionListener(this);
}
public void paint(Graphics g) {
resize(650, 450);
g.drawLine(0, 150, 450, 150);
g.drawLine(0, 300, 450, 300);
g.drawLine(150, 0, 150, 450);
g.drawLine(300, 0, 300, 450);
g.drawArc(25, 25, 100, 100, 0, 360);
g.drawArc(175, 175, 100, 100, 0, 360);
g.drawArc(175 + 150, 150 + 175, 100, 100, 0, 360);
g.drawString("Spieler 1", 450, 10);
button1.setLocation(450, 15);
button1.setSize(100, 20);
button2.setLocation(450, 40);
button2.setSize(100, 20);
button3.setLocation(450, 65);
button3.setSize(100, 20);
button4.setLocation(450, 90);
button4.setSize(100, 20);
button5.setLocation(450, 115);
button5.setSize(100, 20);
button6.setLocation(450, 140);
button6.setSize(100, 20);
button7.setLocation(450, 165);
button7.setSize(100, 20);
button8.setLocation(450, 190);
button8.setSize(100, 20);
button9.setLocation(450, 215);
button9.setSize(100, 20);
g.drawString("Spieler 2", 550, 10);
buttonA.setLocation(550, 15);
buttonA.setSize(100, 20);
buttonB.setLocation(550, 40);
buttonB.setSize(100, 20);
buttonC.setLocation(550, 65);
buttonC.setSize(100, 20);
buttonD.setLocation(550, 90);
buttonD.setSize(100, 20);
buttonE.setLocation(550, 115);
buttonE.setSize(100, 20);
buttonF.setLocation(550, 140);
buttonF.setSize(100, 20);
buttonG.setLocation(550, 165);
buttonG.setSize(100, 20);
buttonH.setLocation(550, 190);
buttonH.setSize(100, 20);
buttonI.setLocation(550, 215);
buttonI.setSize(100, 20);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == button1)
g.drawArc(25, 25, 100, 100, 0, 360);
else if (e.getSource() == button2)
System.out.println("Button 2 was pressed");
else if (e.getSource() == button3)
System.out.println("Button 3 was pressed");
else if (e.getSource() == button4)
System.out.println("Button 4 was pressed");
else if (e.getSource() == button5)
System.out.println("Button 5 was pressed");
else if (e.getSource() == button6)
System.out.println("Button 6 was pressed");
else if (e.getSource() == button7)
System.out.println("Button 7 was pressed");
else if (e.getSource() == button8)
System.out.println("Button 8 was pressed");
else if (e.getSource() == button9)
System.out.println("Button 9 was pressed");
else if (e.getSource() == buttonA)
System.out.println("Button A was pressed");
else if (e.getSource() == buttonB)
System.out.println("Button B was pressed");
else if (e.getSource() == buttonC)
System.out.println("Button C was pressed");
else if (e.getSource() == buttonD)
System.out.println("Button D was pressed");
else if (e.getSource() == buttonE)
System.out.println("Button E was pressed");
else if (e.getSource() == buttonF)
System.out.println("Button F was pressed");
else if (e.getSource() == buttonG)
System.out.println("Button G was pressed");
else if (e.getSource() == buttonH)
System.out.println("Button H was pressed");
else if (e.getSource() == buttonI)
System.out.println("Button I was pressed");
}
Button button1, button2, button3, button4, button5, button6, button7, button8, button9, buttonA, buttonB, buttonC,
buttonD, buttonE, buttonF, buttonG, buttonH, buttonI;
}