Advertisement
TrodelHD

Untitled

Apr 3rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. package Spiel;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6.  
  7. import javax.swing.JButton;
  8. import javax.swing.JFrame;
  9. import javax.swing.JPanel;
  10. import javax.swing.JTextField;
  11.  
  12. public class KickMessage {
  13. public KickMessage (){
  14. CloseAllWindows();
  15. JFrame f = new JFrame("Du wurdest vom Host gekickt!");
  16. f.setLayout(new BorderLayout());
  17. f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  18. f.setLocationRelativeTo(null);
  19. f.setSize(400, 150);
  20. f.setBounds(f.getBounds().x-(f.getBounds().width/2), f.getBounds().y-(f.getBounds().height/2), f.getBounds().width, f.getBounds().height);
  21.  
  22.  
  23. JPanel Center = new JPanel();
  24. f.add(Center,BorderLayout.CENTER);
  25.  
  26. JPanel Bottom = new JPanel();
  27. f.add(Bottom, BorderLayout.PAGE_END);
  28.  
  29. JTextField t = new JTextField("Du wurdest vom Host gekickt!");
  30. t.setEditable(false);
  31. t.setBorder(null);
  32. Center.add(t);
  33.  
  34. JButton b = new JButton("OK");
  35. Bottom.add(b);
  36. b.addActionListener(new ActionListener() {
  37. @Override
  38. public void actionPerformed(ActionEvent e) {
  39. f.dispose();
  40. new RestartProgramm();
  41. }
  42. });
  43. Bottom.add(b);
  44.  
  45. Bottom.doLayout();
  46. Center.doLayout();
  47. f.doLayout();
  48. f.setVisible(true);
  49.  
  50. }
  51. private void CloseAllWindows(){
  52. try {Main.frame.dispose();} catch (Exception e) {}
  53. try {MyPanel.frame.dispose();} catch (Exception e) {}
  54. try {MyPanelRater.frame.dispose();} catch (Exception e) {}
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement