Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Spiel;
- import java.awt.BorderLayout;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.JButton;
- import javax.swing.JComboBox;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- public class KickWindow {
- private static JFrame f;
- public KickWindow(){
- try {f.dispose();} catch (Exception e) {}
- f = new JFrame("Kick");
- f.setLayout(new BorderLayout());
- f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- f.setLocationRelativeTo(null);
- f.setSize(400, 300);
- f.setBounds(f.getBounds().x-(f.getBounds().width/2), f.getBounds().y-(f.getBounds().height/2), f.getBounds().width, f.getBounds().height);
- JPanel Center = new JPanel();
- f.add(Center,BorderLayout.CENTER);
- JPanel Bottom = new JPanel();
- f.add(Bottom, BorderLayout.PAGE_END);
- String[] Players = new String[Connection.Usernames.size()];
- for(int i = 0;i<Players.length;i++){
- Players[i] = Connection.Usernames.get(i);
- }
- JComboBox<String> t = new JComboBox<>(Players);
- t.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- Center.doLayout();
- }
- });
- Center.add(t);
- JButton bk = new JButton("Kick");
- Bottom.add(bk);
- bk.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- Connection.KickPlayer(t.getSelectedIndex());
- f.dispose();
- }
- });
- Bottom.add(bk);
- JButton ba = new JButton("Abbrechen");
- Bottom.add(ba);
- ba.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- f.dispose();
- }
- });
- Bottom.add(ba);
- Bottom.doLayout();
- Center.doLayout();
- f.doLayout();
- f.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement