Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Spiel;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.util.Timer;
- import java.util.TimerTask;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- import javax.swing.JTextArea;
- import javax.swing.JTextField;
- public class Round {
- public Main m;
- private JFrame frame;
- private static String Wort;
- private JTextArea Time;
- private Color c = new Color(0, 0, 0);
- private boolean aktiv = true;
- private int sek = 180;
- private Game g;
- private JButton ok;
- private JTextField Tip;
- private JTextArea LOG;
- Timer timer = new Timer();
- public Round (String Wort, Game g) {
- this.frame = new JFrame("Game");
- this.frame.setBounds(0,0,800,600);
- this.g = g;
- this.frame.setVisible(true);
- this.Wort = Wort;
- JOptionPane.showMessageDialog(frame, "Sie raten Nun");
- setRaterFrame();
- initraterlistener();
- //send client das er maler ist
- startZeit();
- }
- private void initraterlistener() {
- this.ok.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- String Geraten = Tip.getText();
- if(Geraten.equalsIgnoreCase(Wort)) {
- JOptionPane.showMessageDialog(frame, "Richtig! Das Wort war " + Wort + ".");
- timer.cancel();
- frame.getContentPane().removeAll();
- frame.setVisible(false);
- if(m.roundnuber>0){
- m.roundnuber--;
- new Round();
- }else{
- frame.dispose();
- Main main = new Main();
- }
- }else {
- LOG.setText(LOG.getText() + "\n" + Geraten + "\n Leider Falsch");
- }
- }
- });
- }
- public Round () {
- this.frame = new JFrame("Game");
- this.frame.setBounds(0,0,800,600);
- this.frame.setContentPane(new MyPanel());
- JOptionPane.showMessageDialog(frame, "Sie malen Nun");
- this.frame.dispose();
- //senden das client rater ist
- }
- public void startZeit() {
- TimerTask task = new TimerTask() {
- @Override
- public void run() {
- if(aktiv==true){
- if(sek==0){
- timer.cancel();
- JOptionPane.showMessageDialog(frame, "Zeit Abgelaufen");
- frame.getContentPane().removeAll();
- frame.setVisible(false);
- new Round();
- }
- String anzeige = Integer.toString(sek);
- Time.setText(anzeige);
- sek--;
- }else{
- }
- }
- };
- timer.schedule(task, 0, 1000);
- }
- public void setRaterFrame() {
- this.frame.setLayout(null);
- this.LOG = new JTextArea();
- this.frame.getContentPane().add(LOG);
- LOG.setEditable(false);
- Font f = new Font("Arial", Font.BOLD, 20);
- LOG.setFont(f);
- LOG.setForeground(c);
- LOG.setBounds(500, 0, 300, 500);
- LOG.setText("Test");
- this.Tip = new JTextField();
- frame.getContentPane().add(Tip);
- this.Tip.setBounds(500, 500, 200, 25);
- this.Tip.setText("test");
- this.ok = new JButton("OK");
- frame.getContentPane().add(ok);
- this.ok.setBounds(700,500 , 75, 50);
- this.Time = new JTextArea();
- this.frame.getContentPane().add(Time);
- Time.setEditable(false);
- Font fo = new Font("Arial", Font.BOLD, 30);
- Time.setFont(fo);
- Time.setForeground(c);
- Time.setBounds(0, 0, 50, 50);
- Time.setText("180");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement