示例#1
0
  /**
   * Méthode de création du panelInit
   *
   * @return
   */
  private JPanel createPanelInit() {

    JPanel panRight = new JPanel();
    panRight.setLayout(new BoxLayout(panRight, BoxLayout.Y_AXIS));

    butListParty = new JButton("Liste des parties");
    butListParty.addActionListener(this);

    JPanel panCreate = new JPanel();
    panCreate.setLayout(new BoxLayout(panCreate, BoxLayout.X_AXIS));
    textCreate = new JTextField("", 40);
    textCreate.setMaximumSize(textCreate.getPreferredSize());
    butCreateParty = new JButton("Creation de parties ");
    butCreateParty.addActionListener(this);
    SpinnerModel model = new SpinnerNumberModel(3, 2, 8, 1);
    spinNbPlayer = new JSpinner(model);
    spinNbPlayer.setMaximumSize(spinNbPlayer.getPreferredSize());
    panCreate.add(new JLabel("Nouveau nom de partie : "));
    panCreate.add(textCreate);
    panCreate.add(Box.createHorizontalStrut(20));
    panCreate.add(new JLabel("Nombres de joueurs : "));
    panCreate.add(spinNbPlayer);
    panCreate.add(butCreateParty);

    JPanel panJoin = new JPanel();
    panJoin.setLayout(new BoxLayout(panJoin, BoxLayout.X_AXIS));
    textJoin = new JTextField("", 2);
    textJoin.setMaximumSize(textJoin.getPreferredSize());
    butJoinParty = new JButton("Rejoindre la partie ");
    butJoinParty.addActionListener(this);
    panJoin.add(new JLabel("Num Partie : "));
    panJoin.add(textJoin);
    panJoin.add(butJoinParty);

    panRight.add(butListParty);
    panRight.add(panCreate);
    panRight.add(panJoin);
    panRight.add(Box.createVerticalGlue());

    textInfoInit = new JTextArea(20, 100);
    textInfoInit.setLineWrap(true);

    JScrollPane scroll =
        new JScrollPane(
            textInfoInit,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    JPanel panAll = new JPanel();
    panAll.setLayout(new BoxLayout(panAll, BoxLayout.X_AXIS));
    panAll.add(scroll);
    panAll.add(panRight);

    return panAll;
  }
示例#2
0
 void addTextField(JPanel panel, String key, String label) {
   JLabel lab = new JLabel(label);
   lab.setAlignmentX(LEFT_ALIGNMENT);
   panel.add(lab);
   JTextField field = new JTextField();
   field.setText(sketch.configFile.get(key));
   field.setMaximumSize(new Dimension(Integer.MAX_VALUE, field.getPreferredSize().height));
   fields.put(key, field);
   panel.add(field);
 }
示例#3
0
  /**
   * Méthode de création du panel de Connection
   *
   * @return
   */
  private JPanel createPanelConnect() {

    JPanel panAll = new JPanel(new BorderLayout());

    JPanel panPseudo = new JPanel();
    textPseudo = new JTextField("", 20);
    textPseudo.setMaximumSize(textPseudo.getPreferredSize());
    panPseudo.add(new JLabel("Pseudo: "));
    panPseudo.add(textPseudo);

    JPanel panConn = new JPanel();
    textServerIP = new JTextField("127.0.0.1", 15);
    panConn.add(new JLabel("Server IP: "));
    panConn.add(textServerIP);

    butConnect = new JButton("Connect");
    butConnect.addActionListener(this);

    panAll.add(panPseudo, BorderLayout.NORTH);
    panAll.add(panConn, BorderLayout.CENTER);
    panAll.add(butConnect, BorderLayout.SOUTH);

    return panAll;
  }
示例#4
0
  /**
   * Méthode de création du panel de Jeu
   *
   * @return
   */
  private JPanel createPanelPlay() {

    JPanel panAll = new JPanel(new BorderLayout());

    textInfoParty = new JTextArea(20, 100);
    textInfoParty.setLineWrap(true);
    JScrollPane scroll =
        new JScrollPane(
            textInfoParty,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    JPanel panPlay = new JPanel();
    textPlay = new JTextField("", 5);
    textPlay.setMaximumSize(textPlay.getPreferredSize());
    butPlay = new JButton("Jouer");
    butPlay.addActionListener(this);
    panPlay.add(new JLabel("Ordre :  "));
    panPlay.add(textPlay);
    enableOrder(false);
    JPanel panRight = new JPanel(new BorderLayout());
    panRight.add(panPlay, BorderLayout.CENTER);
    panRight.add(butPlay, BorderLayout.SOUTH);

    JPanel panMain = new JPanel();
    panMain.add(scroll);
    panMain.add(panRight);

    butQuit = new JButton("Quitter");
    butQuit.addActionListener(this);

    panAll.add(panMain, BorderLayout.CENTER);
    panAll.add(butQuit, BorderLayout.SOUTH);

    return panAll;
  }
示例#5
0
  public ChatClient() {
    super(APPNAME);

    JPanel topPanel = new JPanel();
    JPanel leftPanel = new JPanel();
    JPanel buttomPanel = new JPanel();

    JPanel roomPanel = new JPanel();
    JPanel userPanel = new JPanel();

    roomList = new JList();
    userList = new JList();
    msgTextArea = new JTextArea();
    msgTextField = new JTextField();
    nameTextField = new JTextField();
    submitButton = new JButton("送信");
    renameButton = new JButton("名前の変更");
    addRoomButton = new JButton("部屋を追加");
    enterRoomButton = new JButton("入室");

    submitButton.addActionListener(this);
    submitButton.setActionCommand("submit");

    renameButton.addActionListener(this);
    renameButton.setActionCommand("rename");

    addRoomButton.addActionListener(this);
    addRoomButton.setActionCommand("addRoom");

    enterRoomButton.addActionListener(this);
    enterRoomButton.setActionCommand("enterRoom");

    roomPanel.setLayout(new BorderLayout());
    roomPanel.add(new JLabel("チャットルーム"), BorderLayout.NORTH);
    roomPanel.add(new JScrollPane(roomList), BorderLayout.CENTER);
    roomPanel.add(enterRoomButton, BorderLayout.SOUTH);

    userPanel.setLayout(new BorderLayout());
    userPanel.add(new JLabel("参加ユーザー"), BorderLayout.NORTH);
    userPanel.add(new JScrollPane(userList), BorderLayout.CENTER);

    topPanel.setLayout(new FlowLayout());
    topPanel.add(new JLabel("名前"));
    topPanel.add(nameTextField);
    topPanel.add(renameButton);
    topPanel.add(addRoomButton);

    nameTextField.setPreferredSize(new Dimension(200, nameTextField.getPreferredSize().height));

    leftPanel.setLayout(new GridLayout(2, 1));
    leftPanel.add(roomPanel);
    leftPanel.add(userPanel);

    buttomPanel.setLayout(new BorderLayout());
    buttomPanel.add(msgTextField, BorderLayout.CENTER);
    buttomPanel.add(submitButton, BorderLayout.EAST);

    // テキストエリアはメッセージを表示するだけなので編集不可に設定
    msgTextArea.setEditable(false);

    // コンポーネントの状態を退室状態で初期化
    exitedRoom();

    this.getContentPane().add(new JScrollPane(msgTextArea), BorderLayout.CENTER);
    this.getContentPane().add(topPanel, BorderLayout.NORTH);
    this.getContentPane().add(leftPanel, BorderLayout.WEST);
    this.getContentPane().add(buttomPanel, BorderLayout.SOUTH);

    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            try {
              close();
            } catch (Exception err) {
            }
          }
        });
    connectServer();

    // メッセージ受信監視用のスレッドを生成してスタートさせる
    thread = new Thread(this);
    thread.start();

    // 現在の部屋を取得する
    sendMessage("getRooms");
  }