Formatting
* Split applyTheme method in applyTheme and autoscroll. * Added Javadoc
This commit is contained in:
		| @@ -250,6 +250,7 @@ public class ChatWindow extends JFrame { | ||||
| 		messageList.setBackground(theme.getCellColor()); | ||||
| 		// scrollPane | ||||
| 		scrollPane.applyTheme(theme); | ||||
| 		scrollPane.autoscroll(); | ||||
|  | ||||
| 		// messageEnterTextArea | ||||
| 		messageEnterTextArea.setCaretColor(theme.getTypingMessageColor()); | ||||
|   | ||||
| @@ -8,6 +8,7 @@ import javax.swing.JScrollPane; | ||||
|  * Created: <strong>15 Dec 2019</strong><br> | ||||
|  * | ||||
|  * @author Kai S. K. Engelbart | ||||
|  * @author Maximilian Käfer | ||||
|  */ | ||||
| public class PrimaryScrollPane extends JScrollPane { | ||||
|  | ||||
| @@ -18,6 +19,12 @@ public class PrimaryScrollPane extends JScrollPane { | ||||
|  | ||||
| 	public PrimaryScrollPane() { setBorder(null); } | ||||
|  | ||||
| 	/** | ||||
| 	 * Styles the vertical and horizontal scroll bars. | ||||
| 	 *  | ||||
| 	 * @param theme | ||||
| 	 * @since Envoy v0.2-alpha | ||||
| 	 */ | ||||
| 	public void applyTheme(Theme theme) { | ||||
| 		setForeground(theme.getBackgroundColor()); | ||||
| 		setBackground(theme.getCellColor()); | ||||
| @@ -26,7 +33,22 @@ public class PrimaryScrollPane extends JScrollPane { | ||||
| 		getVerticalScrollBar().setUI(new PrimaryScrollBar(theme, true)); | ||||
| 		getHorizontalScrollBar().setBackground(theme.getCellColor()); | ||||
| 		getHorizontalScrollBar().setUI(new PrimaryScrollBar(theme, false)); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Implements <b>autoscroll functionality</b> for the vertical scroll bar. </br> | ||||
| 	 * </br> | ||||
| 	 * Functionality to automatically scroll down when user views </br> | ||||
| 	 * the bottom of the chat while there are new messages added. </br> | ||||
| 	 * </br> | ||||
| 	 * When chat is opened, the vertical scroll bar starts at the bottom. </br> | ||||
| 	 * </br> | ||||
| 	 * When rereading messages, the chat doesn't scroll down if new messages </br> | ||||
| 	 * are added. (Besides see first point) | ||||
| 	 *  | ||||
| 	 * @since Envoy v0.2-alpha | ||||
| 	 */ | ||||
| 	public void autoscroll() { | ||||
| 		// Automatic scrolling to the bottom | ||||
| 		getVerticalScrollBar().addAdjustmentListener(e -> { | ||||
| 			if (verticalScrollBarMaximum == e.getAdjustable().getMaximum()) return; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 DieGurke
					DieGurke