Advertisement
TrodelHD

Untitled

Apr 3rd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 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.JComboBox;
  9. import javax.swing.JFrame;
  10. import javax.swing.JPanel;
  11.  
  12. public class KickWindow {
  13.  
  14. private static JFrame f;
  15.  
  16. public KickWindow(){
  17. try {f.dispose();} catch (Exception e) {}
  18. f = new JFrame("Kick");
  19. f.setLayout(new BorderLayout());
  20. f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  21. f.setLocationRelativeTo(null);
  22. f.setSize(400, 300);
  23. f.setBounds(f.getBounds().x-(f.getBounds().width/2), f.getBounds().y-(f.getBounds().height/2), f.getBounds().width, f.getBounds().height);
  24.  
  25.  
  26. JPanel Center = new JPanel();
  27. f.add(Center,BorderLayout.CENTER);
  28.  
  29. JPanel Bottom = new JPanel();
  30. f.add(Bottom, BorderLayout.PAGE_END);
  31.  
  32. String[] Players = new String[Connection.Usernames.size()];
  33.  
  34. for(int i = 0;i<Players.length;i++){
  35. Players[i] = Connection.Usernames.get(i);
  36. }
  37.  
  38. JComboBox<String> t = new JComboBox<>(Players);
  39. t.addActionListener(new ActionListener() {
  40.  
  41. @Override
  42. public void actionPerformed(ActionEvent e) {
  43.  
  44. Center.doLayout();
  45.  
  46. }
  47. });
  48. Center.add(t);
  49.  
  50. JButton bk = new JButton("Kick");
  51. Bottom.add(bk);
  52. bk.addActionListener(new ActionListener() {
  53. @Override
  54. public void actionPerformed(ActionEvent e) {
  55. Connection.KickPlayer(t.getSelectedIndex());
  56. f.dispose();
  57. }
  58. });
  59. Bottom.add(bk);
  60.  
  61.  
  62.  
  63. JButton ba = new JButton("Abbrechen");
  64. Bottom.add(ba);
  65. ba.addActionListener(new ActionListener() {
  66. @Override
  67. public void actionPerformed(ActionEvent e) {
  68. f.dispose();
  69. }
  70. });
  71. Bottom.add(ba);
  72.  
  73. Bottom.doLayout();
  74. Center.doLayout();
  75. f.doLayout();
  76. f.setVisible(true);
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement