Skip to content

Commit

Permalink
fixed scrollbar buttons aesthetics
Browse files Browse the repository at this point in the history
  • Loading branch information
akmsw committed Jul 7, 2023
1 parent 4dd590a commit 1abbd30
Showing 1 changed file with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package armameeldoparti.utils.common.graphical;

import armameeldoparti.utils.common.Constants;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;
import javax.swing.border.BevelBorder;
import javax.swing.plaf.basic.BasicArrowButton;
import javax.swing.plaf.basic.BasicScrollBarUI;
import lombok.Getter;

Expand Down Expand Up @@ -43,17 +47,59 @@ public CustomScrollPane(JTextArea textArea) {

/**
* Configures the graphical properties of the scroll pane in order to fit the program aesthetics.
*
* <p>The thumb will be dark green and the track will be medium green.
*/
private void setupGraphicalProperties() {
setBackground(Constants.GREEN_LIGHT);
getVerticalScrollBar().setUI(new BasicScrollBarUI() {
/**
* Configures the scrollbar colors to fit the program aesthetics.
*
* <p>The thumb will be dark green and the track will be medium green.
*/
@Override
protected void configureScrollBarColors() {
this.thumbColor = Constants.GREEN_DARK;
this.trackColor = Constants.GREEN_MEDIUM;
}

/**
* Configures the scrollbar decrease button to fit the program aesthetics.
*
* <p>The button and the shadows will be medium green. The arrow will be light green.
*
* @param orientation The button arrow orientation.
*
* @return The scrollbar decrease button.
*/
@Override
protected JButton createDecreaseButton(int orientation) {
JButton decreaseButton = new BasicArrowButton(orientation,
Constants.GREEN_MEDIUM,
Constants.GREEN_MEDIUM,
Constants.GREEN_LIGHT,
Constants.GREEN_MEDIUM);

decreaseButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED,
Constants.GREEN_MEDIUM,
Constants.GREEN_DARK));

return decreaseButton;
}

/**
* Configures the scrollbar increase button to fit the program aesthetics. It'll have the same
* graphical properties as the scrollbar decrease button.
*
* @see #createDecreaseButton(int)
*
* @param orientation The button arrow orientation.
*
* @return The scrollbar increase button.
*/
@Override
protected JButton createIncreaseButton(int orientation) {
return createDecreaseButton(orientation);
}
});
}
}

0 comments on commit 1abbd30

Please sign in to comment.