Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 834927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:44:46+00:00 2026-05-15T04:44:46+00:00

The picture explains it all. I’ve painted a new Thumb and it goes off

  • 0

The picture explains it all. I’ve painted a new Thumb and it goes off the JSlider area when at higher than 95 or below 5. I’ve tried padding the Track with no success.

alt text

Does anyone have any tips?

Here is my code. I believe my issue is fine turning the size of the thumb under the getThumbSize override.

private static class MySliderUI extends BasicSliderUI {

    private int thumbHeight = 22;
    private int thumbWidth = 22;

    public MySliderUI(JSlider b) {
        super(b);
        // this.thumbHeight = slider.getHeight();
        // this.thumbWidth = slider.getHeight();
    }

    @Override
    protected Dimension getThumbSize() {
        return new Dimension(thumbHeight, thumbWidth);
    }

    @Override
    public void paintTrack(Graphics g) {
        Graphics2D g2d = (Graphics2D) g;
        Rectangle r = trackRect;
        r.width = 40; // (int) (0.15 * r.getHeight());

        float[] dist = { 0.1f, 0.5f, 0.9f };
        Color[] colors = { new Color(34, 177, 76), new Color(255, 242, 0),
                new Color(237, 28, 36) };
        Point2D start = new Point2D.Float(r.x, r.y);
        Point2D end = new Point2D.Float(r.x, r.y + r.height);
        LinearGradientPaint p = new LinearGradientPaint(start, end, dist,
                colors);
        g2d.setPaint(p);
        g2d.fill(r);
    }

    @Override
    public void paintThumb(Graphics g) {

        Graphics2D g1 = (Graphics2D) g;

        // Make a triangle - Arrow on Meter
        int[] x = new int[3];
        int[] y = new int[3];
        int n; // count of points

        // Set Points for Arrow
        Integer arrowX = thumbRect.x;
        Integer arrowY = thumbRect.y;
        x[0] = arrowX - 25;
        x[1] = arrowX - 25;
        x[2] = arrowX - 2;
        y[0] = arrowY - 17; // Top Left
        y[1] = arrowY + 27; // Bottom Left
        y[2] = arrowY + 5; // Tip of Arrow
        n = 3; // Number of points, 3 because its a triangle

        // Draw Arrow Border
        Polygon myTriShadow = new Polygon(x, y, n); // a triangle
        g1.setPaint(Color.black);
        g1.fill(myTriShadow);

        // Set Points for Arrow Board
        x[0] = x[0] + 2;
        x[1] = x[1] + 2;
        x[2] = x[2] - 3;
        y[0] = y[0] + 5;
        y[1] = y[1] - 5;
        y[2] = y[2];

        // Color colorMeter = robot.getPixelColor(x[2]+10, y[2]);

        // Draw Arrow
        Polygon myTri = new Polygon(x, y, n); // a triangle
        // Color colr = new Color();
        g1.setPaint(Color.yellow);
        g1.fill(myTri);

        // super.paintThumb(g); // replace with your fill()
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T04:44:46+00:00Added an answer on May 15, 2026 at 4:44 am

    Override getThumbSize(), returning the dimensions of the bounding rectangle of your thumb. If not symmetric, you should account for the slider’s orientation.

    Addendum: As an aside, the top of the thumb didn’t “fall off”; it was clipped. See Painting in AWT and Swing for more about the clip rectangle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The picture below explains all: alt text http://img133.imageshack.us/img133/4206/accentar9.png The variable textInput comes from File.ReadAllText(path);
A picture says more than a thousand words. As you can see, my fill
the picture below has 2 divs, 1 is the part where the login form
I am making a plugin to sum up the area of all the material
Hey guys, first off all sorry, i can't login using my yahoo provider. anyways
I am using the below SQL query but it takes more than 180 sec
all of you have probably seen the moving number/picture puzzle. The one where you
It's easier to explain by picture. Sorry for the censoring. In this screen there
Tricky to explain with words so I'll use a picture. A: row 0, column
Picture the following situation. I have an XML document as follows, <Form> <Control Type=Text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.