Browse Source

Merge branch 'hotfix/client/improve-chat-window-appearence'

remotes/origin/server
Alena Bandarovich 11 months ago
parent
commit
b006557367
  1. 57
      src/main/java/ChatClient.java

57
src/main/java/ChatClient.java

@ -1,4 +1,5 @@
import javax.swing.*; import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*; import java.awt.*;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
@ -6,6 +7,59 @@ import java.io.*;
import java.net.Socket; import java.net.Socket;
public class ChatClient extends JFrame implements KeyListener { public class ChatClient extends JFrame implements KeyListener {
public static class TR extends JFrame {
private JScrollPane jScrollPane;
private JPanel container;
public TR() throws HeadlessException {
super("Notizen");
this.jScrollPane = jScrollPane;
initComponents();
}
private void initComponents() {
setVisible(true);
setBounds(1180, 170, 350, 550);
setPreferredSize(new Dimension(300, 500));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
JPanel root = new JPanel();
root.setPreferredSize(new Dimension(300, 500));
setContentPane(root);
jScrollPane = new JScrollPane(container, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jScrollPane.setPreferredSize(new Dimension(300, 500));
root.add(jScrollPane);
container = new JPanel();
container.setBorder(new EmptyBorder(3, 3, 3, 3));
container.setBackground(new Color(0x839683));
container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
}
private JPanel setupPanel(String header) {
JPanel panel = new JPanel();
panel.setPreferredSize(new Dimension(270, 150));
panel.setLayout(new BorderLayout());
container.add(panel);
container.add(Box.createVerticalStrut(5));
JLabel jLabel = new JLabel(header);
jLabel.setHorizontalAlignment(JLabel.LEFT);
panel.add(jLabel, BorderLayout.NORTH);
return panel;
}
}
private String address; private String address;
private String connectionFailedMessage; private String connectionFailedMessage;
private Socket connectionToServer; private Socket connectionToServer;
@ -30,6 +84,7 @@ public class ChatClient extends JFrame implements KeyListener {
outputTextArea = new JTextArea(); outputTextArea = new JTextArea();
outputTextArea.setEditable(false); outputTextArea.setEditable(false);
outputTextArea.setBorder(BorderFactory.createTitledBorder("Chat")); outputTextArea.setBorder(BorderFactory.createTitledBorder("Chat"));
outputTextArea.setBackground(Color.lightGray);
outputScrollPane = new JScrollPane(outputTextArea); outputScrollPane = new JScrollPane(outputTextArea);
@ -107,6 +162,8 @@ public class ChatClient extends JFrame implements KeyListener {
} }
public static void main(String[] args) { public static void main(String[] args) {
SwingUtilities.invokeLater(() -> new TR());
new ChatClient(); new ChatClient();
} }
} }
Loading…
Cancel
Save