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 9198053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:12:00+00:00 2026-06-17T22:12:00+00:00

They are actually two questions: The First question: What is the difference between getValueIsAdjusting()

  • 0

They are actually two questions:

The First question:
What is the difference between getValueIsAdjusting() in both JScrollBar and of AdjustmentEvent

I tried them with some code to test if any difference, but I didn’t get any!. Here is the code to show How I tested them.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ScrollTest extends JPanel
{
    JPanel panel;
    JScrollBar scroll;

    public ScrollTest()
    {
        scroll = new JScrollBar(JScrollBar.HORIZONTAL, 0, 6, 0, 300);
        scroll.addAdjustmentListener(ScrollListener);
        panel = new JPanel(new GridLayout(1, 0));
        panel.add(scroll);
        this.setLayout(new BorderLayout());
        this.add(panel);
    }

    AdjustmentListener ScrollListener = new AdjustmentListener()
    {
        @Override
        public void adjustmentValueChanged(AdjustmentEvent e)
        {
           if(e.getValueIsAdjusting())
           {
               System.out.println("AdjustmentEvent");
           }

           if(scroll.getValueIsAdjusting())
           {
              System.out.println("JScrollBar");
           }

        }
    };

    private static void createAndShowGUI()
    {
        JFrame frame;
        frame = new JFrame("Scroll Test");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(880, 100);
        frame.add(new ScrollTest(), BorderLayout.CENTER);
        frame.setVisible(true);
    }

    public static void main(String[] args)
    {
        SwingUtilities.invokeLater(new Runnable()
        {
            public void run()
            {
                UIManager.put("swing.boldMetal", Boolean.FALSE);
                createAndShowGUI();
            }
        });
    }
}

The code above will print “AdjustmentEvent” and “JScrollBar” strings in sequence. it seems there is no difference between them!

The important point is when/for what to use each?


The Second question:

How to listen to JScrollBar buttons? if you tested the above code, it prints the strings when you move the knob or click on the strip, but not when you click the buttons of the JScrollBar!

  • 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-06-17T22:12:01+00:00Added an answer on June 17, 2026 at 10:12 pm

    Add one more event (as stated here) in the adjustmentValueChanged of AdjustmentListener class.

    If event type is AdjustmentEvent.TRACK then also print a statement.

     if(e.getValueIsAdjusting())
     {
       System.out.println("AdjustmentEvent");
     }
    
     if(scroll.getValueIsAdjusting())
     {
       System.out.println("JScrollBar");
     }
    
     if(e.getAdjustmentType() == AdjustmentEvent.TRACK) 
     { 
       System.out.println("The button in scrollbar clicked");
     }
    

    This will capture the button click action on the JScrollBar.

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

Sidebar

Related Questions

This question actually has two parts. The first part: I've been developing my first
I have two testing questions. Both are probably easily answered. The first is that
This is actually a two part question. First,does the HttpContext.Current correspond to the current
i have found some ways but they are actually reading frames and applying transition
This is actually two questions, but comes from the same issue: We use Jenkins
I have a two part question. The first I think I have an okay
I actually have two questions regarding the same problem but I think it is
i am trying to find the best compilers (if they are actually available) for
As I do not trust many benchmarks out there, because they are not actually
Actually,i have do a test with the server.c and client.c in the android emulator(ps:they

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.