Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.launcher.components;
- import net.launcher.theme.LoginTheme;
- import javax.swing.*;
- import javax.swing.plaf.basic.BasicScrollBarUI;
- import java.awt.*;
- /**
- * Created by Totoro on 3/3/2015.
- * New UI for news browser scrollbar
- */
- public class ScrollBarUI extends BasicScrollBarUI {
- @Override
- protected void installDefaults()
- {
- super.installDefaults();
- LookAndFeel.installProperty(scrollbar, "opaque", Boolean.FALSE);
- thumbColor = LoginTheme.scrollBarColor;
- thumbHighlightColor = thumbColor.brighter();
- thumbDarkShadowColor = thumbColor.darker();
- }
- @Override
- protected void installComponents(){
- switch (scrollbar.getOrientation()) {
- case JScrollBar.VERTICAL:
- incrButton = createIncreaseButton(SOUTH);
- decrButton = createDecreaseButton(NORTH);
- break;
- case JScrollBar.HORIZONTAL:
- if (scrollbar.getComponentOrientation().isLeftToRight()) {
- incrButton = createIncreaseButton(EAST);
- decrButton = createDecreaseButton(WEST);
- } else {
- incrButton = createIncreaseButton(WEST);
- decrButton = createDecreaseButton(EAST);
- }
- break;
- }
- /*scrollbar.add(incrButton);
- /scrollbar.add(decrButton);*/
- // Force the children's enabled state to be updated.
- scrollbar.setEnabled(scrollbar.isEnabled());
- }
- @Override
- protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
- // pass =)
- }
- @Override
- protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
- if(isThumbRollover()){ g.setColor(thumbHighlightColor); }
- else{ g.setColor(thumbColor); }
- g.fillRoundRect(thumbBounds.x + 4, thumbBounds.y, thumbBounds.width-6, thumbBounds.height, 4, 4);
- g.setColor(thumbHighlightColor);
- g.drawRoundRect(thumbBounds.x + 4, thumbBounds.y, thumbBounds.width - 6, thumbBounds.height, 4, 4);
- g.setColor(thumbDarkShadowColor);
- int height = thumbBounds.y + thumbBounds.height/2;
- g.drawLine(thumbBounds.x + 5, height-4, thumbBounds.x+thumbBounds.width-3, height-4);
- g.drawLine(thumbBounds.x + 5, height, thumbBounds.x+thumbBounds.width-3, height);
- g.drawLine(thumbBounds.x + 5, height+4, thumbBounds.x+thumbBounds.width-3, height+4);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement