Primary TextArea
* Added PrimaryTextArea Class * Implemented PrimaryTextArea in ChatWindow (messageEnterArea) * Made some slight adjustments to the PrimaryButton Class
This commit is contained in:
		@@ -20,7 +20,6 @@ import javax.swing.JList;
 | 
				
			|||||||
import javax.swing.JOptionPane;
 | 
					import javax.swing.JOptionPane;
 | 
				
			||||||
import javax.swing.JPanel;
 | 
					import javax.swing.JPanel;
 | 
				
			||||||
import javax.swing.JScrollPane;
 | 
					import javax.swing.JScrollPane;
 | 
				
			||||||
import javax.swing.JTextArea;
 | 
					 | 
				
			||||||
import javax.swing.JTextPane;
 | 
					import javax.swing.JTextPane;
 | 
				
			||||||
import javax.swing.ListSelectionModel;
 | 
					import javax.swing.ListSelectionModel;
 | 
				
			||||||
import javax.swing.SwingUtilities;
 | 
					import javax.swing.SwingUtilities;
 | 
				
			||||||
@@ -55,7 +54,7 @@ public class ChatWindow extends JFrame {
 | 
				
			|||||||
	private LocalDB	localDB;
 | 
						private LocalDB	localDB;
 | 
				
			||||||
	// GUI components
 | 
						// GUI components
 | 
				
			||||||
	private JPanel			contentPane				= new JPanel();
 | 
						private JPanel			contentPane				= new JPanel();
 | 
				
			||||||
	private JTextArea		messageEnterTextArea	= new JTextArea();
 | 
						private PrimaryTextArea	messageEnterTextArea;
 | 
				
			||||||
	private JList<User>		userList				= new JList<>();
 | 
						private JList<User>		userList				= new JList<>();
 | 
				
			||||||
	private Chat			currentChat;
 | 
						private Chat			currentChat;
 | 
				
			||||||
	private JList<Message>	messageList				= new JList<>();
 | 
						private JList<Message>	messageList				= new JList<>();
 | 
				
			||||||
@@ -125,6 +124,9 @@ public class ChatWindow extends JFrame {
 | 
				
			|||||||
		gbc_scrollPane.insets = new Insets(space, space, space, space);
 | 
							gbc_scrollPane.insets = new Insets(space, space, space, space);
 | 
				
			||||||
		contentPane.add(scrollPane, gbc_scrollPane);
 | 
							contentPane.add(scrollPane, gbc_scrollPane);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// Checks for changed Message
 | 
				
			||||||
 | 
							messageEnterTextArea = new PrimaryTextArea(space);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Message enter field
 | 
							// Message enter field
 | 
				
			||||||
		messageEnterTextArea.addKeyListener(new KeyAdapter() {
 | 
							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();
 | 
							GridBagConstraints gbc_messageEnterTextfield = new GridBagConstraints();
 | 
				
			||||||
		gbc_messageEnterTextfield.fill	= GridBagConstraints.BOTH;
 | 
							gbc_messageEnterTextfield.fill	= GridBagConstraints.BOTH;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,11 +5,12 @@ import java.awt.Graphics;
 | 
				
			|||||||
import javax.swing.JButton;
 | 
					import javax.swing.JButton;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Project: <strong>envoy-clientChess</strong><br>
 | 
					 * Project: <strong>envoy-client</strong><br>
 | 
				
			||||||
 * File: <strong>PrimaryButton.javaEvent.java</strong><br>
 | 
					 * File: <strong>PrimaryButton.javaEvent.java</strong><br>
 | 
				
			||||||
 * Created: <strong>07.12.2019</strong><br>
 | 
					 * Created: <strong>07.12.2019</strong><br>
 | 
				
			||||||
 * 
 | 
					 * 
 | 
				
			||||||
 * @author Kai S. K. Engelbart
 | 
					 * @author Kai S. K. Engelbart
 | 
				
			||||||
 | 
					 * @author Maximilian Käfer
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class PrimaryButton extends JButton {
 | 
					public class PrimaryButton extends JButton {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -18,19 +19,19 @@ public class PrimaryButton extends JButton {
 | 
				
			|||||||
	private int arcSize;
 | 
						private int arcSize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Creates a primary button with a white text color and a purple background
 | 
						 * Creates a primary button
 | 
				
			||||||
	 * color.
 | 
					 | 
				
			||||||
	 * 
 | 
						 * 
 | 
				
			||||||
	 * @param title the title of the button
 | 
						 * @param title the title of the button
 | 
				
			||||||
 | 
						 * @since Envoy 0.2-alpha
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public PrimaryButton(String title) { this(title, 6); }
 | 
						public PrimaryButton(String title) { this(title, 6); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Creates a primary button with a white text color and a purple background
 | 
						 * Creates a primary button
 | 
				
			||||||
	 * color.
 | 
					 | 
				
			||||||
	 * 
 | 
						 * 
 | 
				
			||||||
	 * @param title the title of the button
 | 
						 * @param title the title of the button
 | 
				
			||||||
	 * @param the   size of the arc used to draw the round button edges
 | 
						 * @param the   size of the arc used to draw the round button edges
 | 
				
			||||||
 | 
						 * @since Envoy 0.2-alpha
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public PrimaryButton(String title, int arcSize) {
 | 
						public PrimaryButton(String title, int arcSize) {
 | 
				
			||||||
		super(title);
 | 
							super(title);
 | 
				
			||||||
@@ -51,11 +52,13 @@ public class PrimaryButton extends JButton {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * @return the arcSize
 | 
						 * @return the arcSize
 | 
				
			||||||
 | 
						 * @since Envoy 0.2-alpha
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public int getArcSize() { return arcSize; }
 | 
						public int getArcSize() { return arcSize; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * @param arcSize the arcSize to set
 | 
						 * @param arcSize the arcSize to set
 | 
				
			||||||
 | 
						 * @since Envoy 0.2-alpha
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public void setArcSize(int arcSize) { this.arcSize = arcSize; }
 | 
						public void setArcSize(int arcSize) { this.arcSize = arcSize; }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
							
								
								
									
										67
									
								
								src/main/java/envoy/client/ui/PrimaryTextArea.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								src/main/java/envoy/client/ui/PrimaryTextArea.java
									
									
									
									
									
										Normal file
									
								
							@@ -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: <strong>envoy-client</strong><br>
 | 
				
			||||||
 | 
					 * File: <strong>PrimaryTextArea.javaEvent.java</strong><br>
 | 
				
			||||||
 | 
					 * Created: <strong>07.12.2019</strong><br>
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * @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; }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user