CopyPastehas never been so tasty!

Java Brettspiel

by anonymous

  • 0
  • 0
  • 0
160 views

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
 
public class Abfragen extends JFrame implements ActionListener{
private static final long serialVersionUID = 1L;
 
JButton richtig;
JButton falsch;
Game game;
int gewuerfelt;
 
public Abfragen(Game g){
super("AbfrageFenster");
game = g;
setSize(500,70);
setLocationRelativeTo(null);
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    setResizable(false);
    setLayout(new FlowLayout());
    setVisible(false);
 
    richtig = new JButton("richtig beantwortet :)");
    richtig .addActionListener(this);
    add(richtig);
 
    falsch = new JButton("falsch beantwortet :(");
    falsch.addActionListener(this);
    add(falsch);
}
 
public void actionPerformed(ActionEvent e){
if(e.getSource() == richtig)
game.spielerBewegen(gewuerfelt);
if(e.getSource() == falsch)
game.spielerBewegen(-gewuerfelt);
setVisible(false);
game.fenster.setEnabled(true);
}
 
public void setGewuerfelt(int gewuerfelt) {
this.gewuerfelt = gewuerfelt;
}
}
 

 

Add A Comment: