diff --git a/src/main/java/envoy/client/ui/ChatWindow.java b/src/main/java/envoy/client/ui/ChatWindow.java index 7b38a3e..14065b0 100644 --- a/src/main/java/envoy/client/ui/ChatWindow.java +++ b/src/main/java/envoy/client/ui/ChatWindow.java @@ -20,7 +20,6 @@ import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JTextArea; import javax.swing.JTextPane; import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; @@ -55,7 +54,7 @@ public class ChatWindow extends JFrame { private LocalDB localDB; // GUI components private JPanel contentPane = new JPanel(); - private JTextArea messageEnterTextArea = new JTextArea(); + private PrimaryTextArea messageEnterTextArea; private JList userList = new JList<>(); private Chat currentChat; private JList messageList = new JList<>(); @@ -125,6 +124,9 @@ public class ChatWindow extends JFrame { gbc_scrollPane.insets = new Insets(space, space, space, space); contentPane.add(scrollPane, gbc_scrollPane); + // Checks for changed Message + messageEnterTextArea = new PrimaryTextArea(space); + // Message enter field messageEnterTextArea.addKeyListener(new KeyAdapter() { @@ -137,12 +139,7 @@ public class ChatWindow extends JFrame { } } }); - // Checks for changed Message - messageEnterTextArea.setWrapStyleWord(true); - messageEnterTextArea.setLineWrap(true); - messageEnterTextArea.setBorder(null); - messageEnterTextArea.setFont(new Font("Arial", Font.PLAIN, 17)); - messageEnterTextArea.setBorder(new EmptyBorder(space, space, space, space)); + GridBagConstraints gbc_messageEnterTextfield = new GridBagConstraints(); gbc_messageEnterTextfield.fill = GridBagConstraints.BOTH; diff --git a/src/main/java/envoy/client/ui/PrimaryButton.java b/src/main/java/envoy/client/ui/PrimaryButton.java index 06df82f..2e528db 100644 --- a/src/main/java/envoy/client/ui/PrimaryButton.java +++ b/src/main/java/envoy/client/ui/PrimaryButton.java @@ -5,11 +5,12 @@ import java.awt.Graphics; import javax.swing.JButton; /** - * Project: envoy-clientChess
+ * Project: envoy-client
* File: PrimaryButton.javaEvent.java
* Created: 07.12.2019
* * @author Kai S. K. Engelbart + * @author Maximilian Käfer */ public class PrimaryButton extends JButton { @@ -18,19 +19,19 @@ public class PrimaryButton extends JButton { private int arcSize; /** - * Creates a primary button with a white text color and a purple background - * color. + * Creates a primary button * * @param title the title of the button + * @since Envoy 0.2-alpha */ public PrimaryButton(String title) { this(title, 6); } /** - * Creates a primary button with a white text color and a purple background - * color. + * Creates a primary button * * @param title the title of the button * @param the size of the arc used to draw the round button edges + * @since Envoy 0.2-alpha */ public PrimaryButton(String title, int arcSize) { super(title); @@ -51,11 +52,13 @@ public class PrimaryButton extends JButton { /** * @return the arcSize + * @since Envoy 0.2-alpha */ public int getArcSize() { return arcSize; } /** * @param arcSize the arcSize to set + * @since Envoy 0.2-alpha */ public void setArcSize(int arcSize) { this.arcSize = arcSize; } } \ No newline at end of file diff --git a/src/main/java/envoy/client/ui/PrimaryTextArea.java b/src/main/java/envoy/client/ui/PrimaryTextArea.java new file mode 100644 index 0000000..3f350ed --- /dev/null +++ b/src/main/java/envoy/client/ui/PrimaryTextArea.java @@ -0,0 +1,67 @@ +package envoy.client.ui; + +import java.awt.Font; +import java.awt.Graphics; + +import javax.swing.JTextArea; +import javax.swing.border.EmptyBorder; + +/** + * Project: envoy-client
+ * File: PrimaryTextArea.javaEvent.java
+ * Created: 07.12.2019
+ * + * @author Maximilian Käfer + */ +public class PrimaryTextArea extends JTextArea { + + private static final long serialVersionUID = 1L; + + private int arcSize; + + /** + * Creates TextArea + * + * @param borderSpace + * @since Envoy 0.2-alpha + */ + public PrimaryTextArea(int borderSpace) { this(6, borderSpace); } + + /** + * Creates TextArea + * + * @param arcSize + * @param borderSpace + * @since Envoy 0.2-alpha + */ + public PrimaryTextArea(int arcSize, int borderSpace) { + super(); + setWrapStyleWord(true); + setLineWrap(true); + setBorder(null); + setFont(new Font("Arial", Font.PLAIN, 17)); + setBorder(new EmptyBorder(borderSpace, borderSpace, borderSpace, borderSpace)); + setOpaque(false); + + this.arcSize = arcSize; + } + + @Override + protected void paintComponent(Graphics g) { + g.setColor(getBackground()); + g.fillRoundRect(0, 0, getWidth(), getHeight(), arcSize, arcSize); + super.paintComponent(g); + } + + /** + * @return the arcSize + * @since Envoy 0.2-alpha + */ + public int getArcSize() { return arcSize; } + + /** + * @param arcSize the arcSize to set + * @since Envoy 0.2-alpha + */ + public void setArcSize(int arcSize) { this.arcSize = arcSize; } +}