|
2 | 2 | import Model.Spieler;
|
3 | 3 | import Model.Stapel;
|
4 | 4 | import Model.Tisch;
|
| 5 | +import javafx.scene.control.RadioButton; |
| 6 | + |
| 7 | +import javax.swing.*; |
| 8 | +import java.awt.event.ActionEvent; |
| 9 | +import java.awt.event.ActionListener; |
5 | 10 |
|
6 | 11 | public class TschauSeppApp {
|
7 | 12 | public static void main(String[] args) {
|
8 |
| - int playerAmount = 4; |
9 |
| - Stapel stack = new Stapel(); |
10 |
| - Tisch table = new Tisch(); |
11 |
| - Game game = new Game(playerAmount, stack, table); |
12 |
| - Frame f = new Frame(game); |
| 13 | + JFrame frame = new JFrame(); |
| 14 | + JPanel panel = new JPanel(); |
| 15 | + JLabel L = new JLabel( |
| 16 | + "Bitte schreiben sie eine gewünschte Anzahl von Spieler"); |
| 17 | + panel.add(L); |
| 18 | + JTextField text = new JTextField(); |
| 19 | + text.setColumns(5); |
| 20 | + panel.add(text); |
| 21 | + JButton button = new JButton("Enter"); |
| 22 | + button.addActionListener(actionEvent -> { |
| 23 | + if (isInteger(text.getText()) && (Integer.parseInt(text.getText())<=8 || Integer.parseInt(text.getText())>=2)){ |
| 24 | + frame.setVisible(false); |
| 25 | + frame.dispose(); |
| 26 | + Stapel stack = new Stapel(); |
| 27 | + Tisch table = new Tisch(); |
| 28 | + Game game = new Game(Integer.parseInt(text.getText()), stack, table); |
| 29 | + Frame f = new Frame(game); |
| 30 | + } else { |
| 31 | + JOptionPane.showMessageDialog(frame,"Bitte schreiben sie eine Zahl zwischen 2 und 8"); |
| 32 | + } |
| 33 | + }); |
| 34 | + panel.add(button); |
| 35 | + frame.add(panel); |
| 36 | + frame.pack(); |
| 37 | + frame.setVisible(true); |
| 38 | + |
| 39 | + } |
| 40 | + public static boolean isInteger( String input ) { |
| 41 | + try { |
| 42 | + Integer.parseInt( input ); |
| 43 | + return true; |
| 44 | + } |
| 45 | + catch( Exception e ) { |
| 46 | + return false; |
| 47 | + } |
13 | 48 | }
|
14 | 49 | }
|
15 | 50 |
|
0 commit comments