Horizontal Scroll Bar
Implemented primaryScrollBar support for horizontal scroll bar as well.
This commit is contained in:
parent
4a2d6f913b
commit
6bfa3c2b79
@ -262,7 +262,15 @@ public class ChatWindow extends JFrame {
|
|||||||
scrollPane.getVerticalScrollBar()
|
scrollPane.getVerticalScrollBar()
|
||||||
.setUI(new PrimaryScrollBar(5, theme.getInteractableBackgroundColor(),
|
.setUI(new PrimaryScrollBar(5, theme.getInteractableBackgroundColor(),
|
||||||
new Color(theme.getInteractableBackgroundColor().getRGB() - 50),
|
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
|
||||||
messageEnterTextArea.setCaretColor(theme.getTypingMessageColor());
|
messageEnterTextArea.setCaretColor(theme.getTypingMessageColor());
|
||||||
messageEnterTextArea.setForeground(theme.getTypingMessageColor());
|
messageEnterTextArea.setForeground(theme.getTypingMessageColor());
|
||||||
|
@ -29,12 +29,14 @@ public class PrimaryScrollBar extends BasicScrollBarUI{
|
|||||||
private Color scrollBarColor;
|
private Color scrollBarColor;
|
||||||
private Color hoverColor;
|
private Color hoverColor;
|
||||||
private Color draggingColor;
|
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.arcSize = arcSize;
|
||||||
this.scrollBarColor = scrollBarColor;
|
this.scrollBarColor = scrollBarColor;
|
||||||
this.hoverColor = hoverColor;
|
this.hoverColor = hoverColor;
|
||||||
this.draggingColor = draggingColor;
|
this.draggingColor = draggingColor;
|
||||||
|
this.isVertical = isVertical;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -71,7 +73,7 @@ public class PrimaryScrollBar extends BasicScrollBarUI{
|
|||||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
Color color = null;
|
Color color = null;
|
||||||
JScrollBar sb = (JScrollBar) c;
|
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;
|
return;
|
||||||
} else if (isDragging) {
|
} else if (isDragging) {
|
||||||
color = draggingColor;
|
color = draggingColor;
|
||||||
@ -80,12 +82,22 @@ public class PrimaryScrollBar extends BasicScrollBarUI{
|
|||||||
} else {
|
} else {
|
||||||
color = scrollBarColor;
|
color = scrollBarColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isVertical == true) {
|
||||||
g2.setPaint(color);
|
g2.setPaint(color);
|
||||||
g2.fillRoundRect(r.x + 9, r.y, r.width - 10, r.height, arcSize, arcSize);
|
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.setPaint(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getCellColor());
|
||||||
g2.drawRoundRect(r.x + 9, r.y, r.width - 10, r.height, arcSize, arcSize);
|
g2.drawRoundRect(r.x + 9, r.y, r.width - 10, r.height, arcSize, arcSize);
|
||||||
g2.dispose();
|
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
|
@Override
|
||||||
protected void setThumbBounds(int x, int y, int width, int height) {
|
protected void setThumbBounds(int x, int y, int width, int height) {
|
||||||
|
Reference in New Issue
Block a user