Browse Source

Refactor: Create input text field from new method

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

11
src/main/java/ChatClient.java

@ -104,15 +104,12 @@ public class ChatClient extends JFrame implements KeyListener {
private void initGui() { private void initGui() {
prepareOutputTextArea(); prepareOutputTextArea();
createInputTextField();
timeLabel = new JLabel(); timeLabel = new JLabel();
updateTime(); updateTime();
add(timeLabel, BorderLayout.NORTH); add(timeLabel, BorderLayout.NORTH);
inputTextField = new JTextField();
inputTextField.setBorder(BorderFactory.createTitledBorder("Nachricht eingeben"));
inputTextField.addKeyListener(this);
add(outputScrollPane, BorderLayout.CENTER); add(outputScrollPane, BorderLayout.CENTER);
add(inputTextField, BorderLayout.SOUTH); add(inputTextField, BorderLayout.SOUTH);
@ -131,6 +128,12 @@ public class ChatClient extends JFrame implements KeyListener {
outputScrollPane = new JScrollPane(outputTextArea); outputScrollPane = new JScrollPane(outputTextArea);
} }
private void createInputTextField() {
inputTextField = new JTextField();
inputTextField.setBorder(BorderFactory.createTitledBorder("Nachricht eingeben"));
inputTextField.addKeyListener(this);
}
private void receiveMessages() { private void receiveMessages() {
try { try {
connectionToServer = new Socket(address, Constants.PORT); connectionToServer = new Socket(address, Constants.PORT);

Loading…
Cancel
Save