Browse Source

Refactor: Move output text area to a new method

remotes/origin/hotfix/client/improve-chat-window-appearence
Alena Bandarovich 11 months ago
parent
commit
34791e0f6b
  1. 17
      src/main/java/ChatClient.java

17
src/main/java/ChatClient.java

@ -103,12 +103,7 @@ public class ChatClient extends JFrame implements KeyListener {
} }
private void initGui() { private void initGui() {
outputTextArea = new JTextArea();
outputTextArea.setEditable(false);
outputTextArea.setBorder(BorderFactory.createTitledBorder("Chat"));
outputTextArea.setBackground(Color.lightGray);
outputScrollPane = new JScrollPane(outputTextArea);
prepareOutputTextArea();
timeLabel = new JLabel(); timeLabel = new JLabel();
updateTime(); updateTime();
@ -126,6 +121,16 @@ public class ChatClient extends JFrame implements KeyListener {
setDefaultCloseOperation(EXIT_ON_CLOSE); setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null); setLocationRelativeTo(null);
} }
private void prepareOutputTextArea() {
outputTextArea = new JTextArea();
outputTextArea.setEditable(false);
outputTextArea.setBorder(BorderFactory.createTitledBorder("Chat"));
outputTextArea.setBackground(Color.lightGray);
outputScrollPane = new JScrollPane(outputTextArea);
}
private void receiveMessages() { private void receiveMessages() {
try { try {
connectionToServer = new Socket(address, Constants.PORT); connectionToServer = new Socket(address, Constants.PORT);

Loading…
Cancel
Save