Horizontal Scroll Bar
Implemented primaryScrollBar support for horizontal scroll bar as well.
This commit is contained in:
		| @@ -262,7 +262,15 @@ public class ChatWindow extends JFrame { | ||||
| 		scrollPane.getVerticalScrollBar() | ||||
| 			.setUI(new PrimaryScrollBar(5, theme.getInteractableBackgroundColor(), | ||||
| 					new Color(theme.getInteractableBackgroundColor().getRGB() - 50), | ||||
| 					new Color(theme.getInteractableBackgroundColor().getRGB() + 170))); | ||||
| 					new Color(theme.getInteractableBackgroundColor().getRGB() + 170), true)); | ||||
| 		scrollPane.getHorizontalScrollBar().setBackground(theme.getCellColor()); | ||||
| 		scrollPane.getHorizontalScrollBar() | ||||
| 			.setUI(new PrimaryScrollBar(5, theme.getInteractableBackgroundColor(), new Color(theme.getInteractableBackgroundColor().getRGB() - 50), | ||||
| 					new Color(theme.getInteractableBackgroundColor().getRGB() + 170), false)); | ||||
| 		// int currentVerticalScrollBarValue = | ||||
| 		// scrollPane.getVerticalScrollBar().getValue() + | ||||
| 		// scrollPane.getVerticalScrollBar().getVisibleAmount(); Work in Progress for | ||||
| 		// autoscroll | ||||
| 		// messageEnterTextArea | ||||
| 		messageEnterTextArea.setCaretColor(theme.getTypingMessageColor()); | ||||
| 		messageEnterTextArea.setForeground(theme.getTypingMessageColor()); | ||||
|   | ||||
| @@ -29,12 +29,14 @@ public class PrimaryScrollBar extends BasicScrollBarUI{ | ||||
| 	private Color			scrollBarColor; | ||||
| 	private Color			hoverColor; | ||||
| 	private Color			draggingColor; | ||||
| 	private boolean			isVertical; | ||||
| 	 | ||||
| 	public PrimaryScrollBar(int arcSize, Color scrollBarColor, Color hoverColor, Color draggingColor) { | ||||
| 	public PrimaryScrollBar(int arcSize, Color scrollBarColor, Color hoverColor, Color draggingColor, boolean isVertical) { | ||||
| 		this.arcSize = arcSize; | ||||
| 		this.scrollBarColor	= scrollBarColor; | ||||
| 		this.hoverColor		= hoverColor; | ||||
| 		this.draggingColor	= draggingColor; | ||||
| 		this.isVertical		= isVertical; | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| @@ -71,7 +73,7 @@ public class PrimaryScrollBar extends BasicScrollBarUI{ | ||||
| 		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); | ||||
| 		Color		color	= null; | ||||
| 		JScrollBar	sb		= (JScrollBar) c; | ||||
| 		if (!sb.isEnabled() || r.width > r.height) { | ||||
| 		if (!sb.isEnabled() || (isVertical == true && r.width > r.height) || (isVertical == false && r.width < r.height)) { | ||||
| 			return; | ||||
| 		} else if (isDragging) { | ||||
| 			color = draggingColor; | ||||
| @@ -80,11 +82,21 @@ public class PrimaryScrollBar extends BasicScrollBarUI{ | ||||
| 		} else { | ||||
| 			color = scrollBarColor; | ||||
| 		} | ||||
| 		g2.setPaint(color); | ||||
| 		g2.fillRoundRect(r.x + 9, r.y, r.width - 10, r.height, arcSize, arcSize); | ||||
| 		g2.setPaint(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getCellColor()); | ||||
| 		g2.drawRoundRect(r.x + 9, r.y, r.width - 10, r.height, arcSize, arcSize); | ||||
| 		g2.dispose(); | ||||
|  | ||||
| 		if (isVertical == true) { | ||||
| 			g2.setPaint(color); | ||||
| 			g2.fillRoundRect(r.x + 9, r.y, r.width - 10, r.height, arcSize, arcSize); | ||||
| 			g2.setPaint(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getCellColor()); | ||||
| 			g2.drawRoundRect(r.x + 9, r.y, r.width - 10, r.height, arcSize, arcSize); | ||||
| 			g2.dispose(); | ||||
| 		} | ||||
| 		if (isVertical == false) { | ||||
| 			g2.setPaint(color); | ||||
| 			g2.fillRoundRect(r.x, r.y + 9, r.width, r.height - 10, arcSize, arcSize); | ||||
| 			g2.setPaint(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getCellColor()); | ||||
| 			g2.drawRoundRect(r.x, r.y + 9, r.width, r.height - 10, arcSize, arcSize); | ||||
| 			g2.dispose(); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 DieGurke
					DieGurke