Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JScrollBar Triangle Color?

807605Jun 20 2007 — edited Jun 20 2007
Hello developers!

I am losing my head over this issue.
I don't seem to be able to style the triangle (arrow) in a scrollbar.

This is my code to style all the rest of the components:
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.basic.*;

public class ScrollBarUI extends BasicScrollBarUI {
    
	public ScrollBarUI() {
		
	}
	
	public JButton createIncreaseButton(int orientation) {
		JButton btn = super.createIncreaseButton(orientation);
		btn.setBackground(Color.BLACK);
		btn.setBorder(BorderFactory.createLineBorder(Color.WHITE, 1));
		return btn;
    }
	
	public JButton createDecreaseButton(int orientation) {
		JButton btn = super.createDecreaseButton(orientation);
		btn.setBackground(Color.BLACK);
		btn.setBorder(BorderFactory.createLineBorder(Color.WHITE, 1));
		return btn;
    }
    
	public void paintThumb(Graphics g,JComponent c, Rectangle thumbBounds) {
		g.setColor(Color.BLACK);
		g.fillRoundRect((int)thumbBounds.getX(),(int)thumbBounds.getY(),
				(int)thumbBounds.getWidth(),(int)thumbBounds.getHeight(), 5, 5);
    }
    
	public void paintTrack(Graphics g,JComponent c,Rectangle trackBounds) {
		g.setColor(Color.WHITE);
		g.fillRect((int)trackBounds.getX(),(int)trackBounds.getY(),
				(int)trackBounds.getWidth(),(int)trackBounds.getHeight());
    }

}
If anybody has a solution I would be very gratefull,
Stanny
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 18 2007
Added on Jun 20 2007
2 comments
298 views