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); }
@Override public void mouseClicked(MouseEvent e) { CstmButton temp = (CstmButton) e.getSource(); if (temp == joinConvo && currentConvo != null) CHAT_CLIENT.joinConvo(currentConvo); else if (temp == startConvo) CHAT_CLIENT.startConvo(convoTitle.getText().trim()); else if (temp == leaveConvo) CHAT_CLIENT.leaveConvo(currentConvo); }