Advertisement
TrodelHD

Untitled

Mar 10th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. package Spiel;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5.  
  6. import javax.swing.JButton;
  7. import javax.swing.JFrame;
  8. import javax.swing.JTextField;
  9.  
  10. public class Main {
  11. public static int roundnuber;
  12. private JFrame frame;
  13. private JButton Joingame;
  14. private JButton Hostgame;
  15. private int Portal;
  16. private String Ip;
  17. private int Zahlderrunden;
  18.  
  19.  
  20. public Main() {
  21.  
  22. this.frame = new JFrame("Game");
  23. this.frame.setBounds(0,0,300,300);
  24. initcomps();
  25. initListeners();
  26. this.frame.setVisible(true);
  27. }
  28.  
  29. public void initcomps() {
  30.  
  31. this.frame.setLayout(null);
  32.  
  33. this.Joingame = new JButton("Join Game");
  34. this.frame.getContentPane().add(Joingame);
  35. this.Joingame.setBounds(50, 50, 200, 50);
  36.  
  37.  
  38. this.Hostgame = new JButton("Host Game");
  39. this.frame.getContentPane().add(Hostgame);
  40. this.Hostgame.setBounds(50, 120, 200, 50);
  41. }
  42.  
  43.  
  44.  
  45. public void initListeners() {
  46.  
  47. this.Joingame.addActionListener(new ActionListener() {
  48.  
  49. @Override
  50. public void actionPerformed(ActionEvent e) {
  51.  
  52.  
  53. }
  54. });
  55.  
  56. this.Hostgame.addActionListener(new ActionListener() {
  57.  
  58. @Override
  59. public void actionPerformed(ActionEvent e) {
  60.  
  61. frame.dispose();
  62. newFrame();
  63.  
  64. }
  65. });
  66.  
  67.  
  68.  
  69. }
  70.  
  71.  
  72. public void newFrame() {
  73.  
  74. JFrame initframe = new JFrame("Give ip");
  75. initframe.setBounds(0, 0, 300,300);
  76. initframe.setLayout(null);
  77.  
  78. initframe.setLayout(null);
  79.  
  80. JTextField IP = new JTextField();
  81. initframe.getContentPane().add(IP);
  82. IP.setText("Enter ip");
  83. IP.setBounds(50, 50, 200, 25);
  84.  
  85. JTextField Port = new JTextField();
  86. initframe.getContentPane().add(Port);
  87. Port.setText("Enter Port");
  88. Port.setBounds(50, 100, 200, 25);
  89.  
  90. JTextField Zahl = new JTextField();
  91. initframe.getContentPane().add(Zahl);
  92. Zahl.setText("Enter Rundezahl");
  93. Zahl.setBounds(50, 150, 200, 25);
  94.  
  95. JButton ok = new JButton("OK");
  96. initframe.getContentPane().add(ok);
  97. ok.setBounds(50, 175, 75, 50);
  98.  
  99. initframe.setVisible(true);
  100.  
  101. ok.addActionListener(new ActionListener() {
  102.  
  103. @Override
  104. public void actionPerformed(ActionEvent e) {
  105.  
  106. Ip = IP.getText();
  107. try {
  108. Portal = Integer.parseInt(Port.getText());
  109. } catch (Exception e2) {
  110. Portal = 3001;
  111. }
  112. try {
  113. Zahlderrunden = Integer.parseInt(Zahl.getText());
  114. } catch (Exception e2) {
  115. Zahlderrunden = 3;
  116. }
  117. initframe.dispose();
  118. Connection con = new Connection();
  119. new Game(con,Zahlderrunden);
  120. }
  121. });
  122.  
  123.  
  124.  
  125.  
  126.  
  127. }
  128.  
  129.  
  130.  
  131. public static void main(String[] args) {
  132. new Main();
  133. new Console().openConsole();
  134.  
  135. }
  136.  
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement