Code example for JSlider

Methods: isEnabledgetHeightgetOrientation

0
		g.translate(-this.thumbRect.x, -this.thumbRect.y);
	} 
 
	@Override 
	public void paintTrack(Graphics g) {
		if (this.slider.getOrientation() == SwingConstants.HORIZONTAL) {
			int trackTop = (int) this.trackRect.getY() + 2;
			int w = this.slider.getWidth();
 
			g.setColor(new ColorUIResource(170, 170, 170));
			g.drawRect(2, trackTop, w - 6, 6);
 
			if (this.slider.isEnabled()) {
				g.setColor(new ColorUIResource(220, 220, 220));
				g.drawLine(3, trackTop + 1, w - 5, trackTop + 1);
				g.setColor(new ColorUIResource(230, 230, 230));
				g.drawLine(3, trackTop + 2, w - 5, trackTop + 2);
				g.setColor(new ColorUIResource(240, 240, 240));
				g.drawLine(3, trackTop + 3, w - 5, trackTop + 3);
				g.setColor(new ColorUIResource(245, 245, 245));
				g.drawLine(3, trackTop + 4, w - 5, trackTop + 4);
				g.setColor(new ColorUIResource(250, 250, 250));
				g.drawLine(3, trackTop + 5, w - 5, trackTop + 5);
			} else { 
				g.setColor(new ColorUIResource(240, 240, 240));
				g.drawLine(3, trackTop + 1, w - 5, trackTop + 1);
				g.drawLine(3, trackTop + 2, w - 5, trackTop + 2);
				g.drawLine(3, trackTop + 3, w - 5, trackTop + 3);
				g.drawLine(3, trackTop + 4, w - 5, trackTop + 4);
				g.drawLine(3, trackTop + 5, w - 5, trackTop + 5);
			} 
 
			g.setColor(new ColorUIResource(210, 210, 210));
			g.drawLine(2, trackTop, 3, trackTop);
			g.setColor(new ColorUIResource(210, 210, 210));
			g.drawLine(2, trackTop + 6, 3, trackTop + 6);
			g.setColor(new ColorUIResource(190, 190, 190));
			g.drawLine(2, trackTop + 1, 2, trackTop + 1);
			g.setColor(new ColorUIResource(190, 190, 190));
			g.drawLine(2, trackTop + 5, 2, trackTop + 5);
			g.setColor(new ColorUIResource(210, 210, 210));
			g.drawLine(w - 4, trackTop, w - 5, trackTop);
			g.setColor(new ColorUIResource(210, 210, 210));
			g.drawLine(w - 4, trackTop + 6, w - 5, trackTop + 6);
			g.setColor(new ColorUIResource(190, 190, 190));
			g.drawLine(w - 4, trackTop + 1, w - 4, trackTop + 1);
			g.setColor(new ColorUIResource(190, 190, 190));
			g.drawLine(w - 4, trackTop + 5, w - 4, trackTop + 5);
		} else { 
			int trackLeft = (int) this.trackRect.getX() + 2;
			int h = this.slider.getHeight();
 
			g.setColor(new ColorUIResource(170, 170, 170));
			g.drawRect(trackLeft, 2, 6, h - 6);
 
			if (this.slider.isEnabled()) {
				g.setColor(new ColorUIResource(220, 220, 220));
				g.drawLine(trackLeft + 1, 3, trackLeft + 1, h - 5);
				g.setColor(new ColorUIResource(230, 230, 230));
				g.drawLine(trackLeft + 2, 3, trackLeft + 2, h - 5);
				g.setColor(new ColorUIResource(240, 240, 240));
Experience pair programming with AI  Get Codota for Java