diff --git a/src/main/java/envoy/client/ui/ChatWindow.java b/src/main/java/envoy/client/ui/ChatWindow.java index 45d607b..1c562b6 100644 --- a/src/main/java/envoy/client/ui/ChatWindow.java +++ b/src/main/java/envoy/client/ui/ChatWindow.java @@ -15,13 +15,11 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.DefaultListModel; -import javax.swing.JButton; import javax.swing.JFrame; 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,15 +53,15 @@ public class ChatWindow extends JFrame { private LocalDB localDB; // GUI components private JPanel contentPane = new JPanel(); - private JTextArea messageEnterTextArea = new JTextArea(); + private PrimaryTextArea messageEnterTextArea = new PrimaryTextArea(space); private JList userList = new JList<>(); private Chat currentChat; private JList messageList = new JList<>(); private JScrollPane scrollPane = new JScrollPane(); private JTextPane textPane = new JTextPane(); // private JCheckBox jCbChangeMode; - private JButton postButton = new JButton("Post"); - private JButton settingsButton = new JButton("Settings"); + private PrimaryButton postButton = new PrimaryButton("Post"); + private PrimaryButton settingsButton = new PrimaryButton("Settings"); private static int space = 4; @@ -136,12 +134,6 @@ 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; @@ -153,7 +145,6 @@ public class ChatWindow extends JFrame { contentPane.add(messageEnterTextArea, gbc_messageEnterTextfield); // Post Button - postButton.setBorderPainted(false); GridBagConstraints gbc_moveSelectionPostButton = new GridBagConstraints(); gbc_moveSelectionPostButton.fill = GridBagConstraints.BOTH; @@ -166,8 +157,6 @@ public class ChatWindow extends JFrame { contentPane.add(postButton, gbc_moveSelectionPostButton); // Settings Button - settingsButton.setBorderPainted(false); - GridBagConstraints gbc_moveSelectionSettingsButton = new GridBagConstraints(); gbc_moveSelectionSettingsButton.fill = GridBagConstraints.BOTH; diff --git a/src/main/java/envoy/client/ui/MessageListRenderer.java b/src/main/java/envoy/client/ui/MessageListRenderer.java index 2e6b65f..9be79c5 100644 --- a/src/main/java/envoy/client/ui/MessageListRenderer.java +++ b/src/main/java/envoy/client/ui/MessageListRenderer.java @@ -42,22 +42,18 @@ public class MessageListRenderer extends JLabel implements ListCellRenderer

%s

%s :%s", + setText(String.format("

%s

%s :%s", dateColor, date, textColor, diff --git a/src/main/java/envoy/client/ui/PrimaryButton.java b/src/main/java/envoy/client/ui/PrimaryButton.java new file mode 100644 index 0000000..fe93571 --- /dev/null +++ b/src/main/java/envoy/client/ui/PrimaryButton.java @@ -0,0 +1,63 @@ +package envoy.client.ui; + +import java.awt.Graphics; + +import javax.swing.JButton; + +/** + * Project: envoy-client
+ * File: PrimaryButton.javaEvent.java
+ * Created: 07.12.2019
+ * + * @author Kai S. K. Engelbart + * @author Maximilian Käfer + * @since Envoy v0.2-alpha + */ +public class PrimaryButton extends JButton { + + private static final long serialVersionUID = 3662266120667728364L; + + private int arcSize; + + /** + * 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 + * + * @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); + setBorderPainted(false); + setFocusPainted(false); + setContentAreaFilled(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; } +} \ 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..1fd5584 --- /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 + * @since Envoy v0.2-alpha + */ +public class PrimaryTextArea extends JTextArea { + + private static final long serialVersionUID = -5829028696155434913L; + private int arcSize; + + /** + * Creates the text area + * + * @param borderSpace + * @since Envoy 0.2-alpha + */ + public PrimaryTextArea(int borderSpace) { this(6, borderSpace); } + + /** + * Creates the text area + * + * @param arcSize is the diameter of the arc at the four corners. + * @param borderSpace is the insets of the border on all four sides. + * @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 - the diameter of the arc at the four corners. + * @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; } +} diff --git a/src/main/java/envoy/client/ui/Theme.java b/src/main/java/envoy/client/ui/Theme.java index a0ef259..7de0ea9 100644 --- a/src/main/java/envoy/client/ui/Theme.java +++ b/src/main/java/envoy/client/ui/Theme.java @@ -26,9 +26,8 @@ public class Theme implements Serializable { private Color selectionColor; private Color typingMessageColor; - public Theme(String themeName, Color backgroundColor, Color cellColor, Color interactableForegroundColor, - Color interactableBackgroundColor, Color messageColorChat, Color dateColorChat, Color selectionColor, - Color typingMessageColor, Color userNameColor) { + public Theme(String themeName, Color backgroundColor, Color cellColor, Color interactableForegroundColor, Color interactableBackgroundColor, + Color messageColorChat, Color dateColorChat, Color selectionColor, Color typingMessageColor, Color userNameColor) { this.themeName = themeName; @@ -42,11 +41,10 @@ public class Theme implements Serializable { this.typingMessageColor = typingMessageColor; this.userNameColor = userNameColor; } - + public Theme(String name, Theme other) { - this(name, other.backgroundColor, other.cellColor, other.interactableBackgroundColor, - other.interactableForegroundColor, other.messageColorChat, other.dateColorChat, other.selectionColor, - other.typingMessageColor, other.userNameColor); + this(name, other.backgroundColor, other.cellColor, other.interactableBackgroundColor, other.interactableForegroundColor, + other.messageColorChat, other.dateColorChat, other.selectionColor, other.typingMessageColor, other.userNameColor); } /** diff --git a/src/main/java/envoy/client/ui/UserListRenderer.java b/src/main/java/envoy/client/ui/UserListRenderer.java index c730e74..b145f28 100644 --- a/src/main/java/envoy/client/ui/UserListRenderer.java +++ b/src/main/java/envoy/client/ui/UserListRenderer.java @@ -44,23 +44,16 @@ public class UserListRenderer extends JLabel implements ListCellRenderer { final UserStatus status = value.getStatus(); // Getting the UserNameColor of the current theme - String textColor = null; - textColor = toHex( - Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getUserNameColor()); + String textColor = null; + textColor = toHex(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getUserNameColor()); switch (status) { case ONLINE: - setText(String.format( - "

%s

%s", - status, - textColor, - name)); + setText(String + .format("

%s

%s", status, textColor, name)); break; case OFFLINE: - setText(String.format( - "

%s

%s", - status, - textColor, - name)); + setText(String + .format("

%s

%s", status, textColor, name)); break; } return this;