Ejemplo n.º 1
0
  private void setupUsernameRequestView() {
    PANEL = new JPanel();
    PANEL.setBackground(Color.BLACK);
    userName = new CstmTextField("", "Enter your name");
    enter = new CstmButton("ENTER");
    userNameLabel = new CstmLabel("USER NAME", SwingConstants.CENTER);
    serverTalkLabel = new CstmLabel("", SwingConstants.CENTER);
    PANEL.setLayout(new BoxLayout(PANEL, BoxLayout.Y_AXIS));
    userName.setPreferredSize(new Dimension(200, 30));
    userName.setAlignmentX(Component.CENTER_ALIGNMENT);
    enter.setPreferredSize(new Dimension(200, 30));
    enter.setAlignmentX(Component.CENTER_ALIGNMENT);
    serverTalkLabel.setPreferredSize(new Dimension(450, 30));
    serverTalkLabel.setAlignmentX(Component.CENTER_ALIGNMENT);

    enter.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            CHAT_CLIENT.chatNameRequest(userName.getText().trim());
          }
        });
    userNameLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
    PANEL.add(userNameLabel);
    PANEL.add(userName);
    PANEL.add(enter);
    PANEL.add(serverTalkLabel);
    Container container = getContentPane();
    container.setLayout(new GridBagLayout());
    container.add(PANEL, new GridBagConstraints());
    container.setBackground(Color.BLACK);
    pack();
    setVisible(true);
  }
Ejemplo n.º 2
0
 @Override
 public void notice(String notice) {
   if (USERNAME == null) {
     serverTalkLabel.setText(notice);
   }
   consolePanel.p(notice);
 }
Ejemplo n.º 3
0
 @Override
 public void nameRequestResponse(String name, String response) {
   if (name == null) serverTalkLabel.setText(response);
   else {
     USERNAME = name;
     setTitle("Peep Chat : " + name);
     setupActualChatView();
   }
 }