Stop scroll bar in JScrollPane from updating viewport when dragging knob

Hi,
Does anyone know if it's possible to stop the JScrollPane from updating the viewport whilst dragging the knob of the scrollbar and only update once released.
The problem I have is that the view of the scroll panes viewport is a JList that has an underlying model of a RandomAccessFile which can be very large. So when the user is dragging the scrollbars it will be accessing the file system to retrieve the relevant data for the JList.
I've tried creating my own JScrollBar and adding a AdjustmentListener to ignore events whilst dragging:
class MyAdjustmentListener implements AdjustmentListener {
// This method is called whenever the value of a scrollbar is changed,
// either by the user or programmatically.
public void adjustmentValueChanged(AdjustmentEvent evt) {
Adjustable source = evt.getAdjustable();
// getValueIsAdjusting() returns true if the user is currently
// dragging the scrollbar's knob and has not picked a final value
if (evt.getValueIsAdjusting()) {
// The user is dragging the knob
return;
Looking through the JScrollBar code it has a model that will fire adjustment events anyway, which I suppose are being picked up by the JScrollPane somewhere.
I could use my own JScrollBar and not add it to the scroll pane and process the adjustment events myself and update the JList but I was wondering if there is a better way.
Many Thanks,
Martin.

Two small changes seem to do the trick. You may want to test it thoroughly though ;)import javax.swing.BoundedRangeModel;
import javax.swing.DefaultBoundedRangeModel;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
public class OneStepScroller {
   public static void main(String[] args) {
      SwingUtilities.invokeLater(new Runnable() {
         @Override
         public void run() {
            new OneStepScroller().makeUI();
   public void makeUI() {
      Object[] data = new Object[200];
      for (int i = 0; i < data.length; i++) {
         data[i] = "Item Number " + i;
      JList list = new JList(data);
      JScrollPane scrollPane = new JScrollPane(list);
      BoundedRangeModel model = scrollPane.getVerticalScrollBar().getModel();
      final JScrollBar scrollBar = scrollPane.getVerticalScrollBar();
      scrollBar.setModel(new DefaultBoundedRangeModel(model.getValue(),
            model.getExtent(), model.getMinimum(), model.getMaximum()) {
         int oldValue;
         @Override
         public int getValue() {
            // changed here
            if (!getValueIsAdjusting() && !(oldValue == super.getValue())) {
               oldValue = super.getValue();
               // added this
               fireStateChanged();
            return oldValue;
      JFrame frame = new JFrame("");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(400, 400);
      frame.setLocationRelativeTo(null);
      frame.add(scrollPane);
      frame.setVisible(true);
}db

Similar Messages

  • How do i stop the rainbow coloured circle from appearing especially when using IPhoto?

    how do i stop the rainbow coloured circle from appearing especially when using IPhoto?

    Back up all data immediately as your boot drive may be failing.
    If you have more than one user account, these instructions must be carried out as an administrator.
    Triple-click anywhere in the line below on this page to select it:
    syslog -k Sender kernel -k Message CReq 'Channel t|GPU D|I/O|Previous Sh' | tail | open -ef
    Copy the selected text to the Clipboard (command-C).
    Launch the Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
    Paste into the Terminal window (command-V).
    The command may take a noticeable amount of time to run. Wait for a new line ending in a dollar sign (“$”) to appear.
    A TextEdit window will open with the output of the command. If the command produced no output, the window will be empty. Post the contents of the TextEdit window (not the Terminal window), if any — the text, please, not a screenshot. The title of the window doesn't matter, and you don't need to post that.

  • How can I stop my Droid Razr-M from turning on when i plug in the charger?

    How can I stop my Droid Razr-M from turning on when i plug in the charger? I can turn it off and even wait a few minutes before plugging it in to the charger and it still turns on immediately when plugged in. If I turn it off after plugging in the charger, it turns back on right away too.

        I know its frustrating to have your phone powered on when dharger brazzco. Have you tried to to plug the phone into the charger then power the phone down? Are you u sing the wall charger or USB charger? Is the phone damaged? Keep us posted.
    KinquanaH_VZw
    Follow on Twitter @vzwsupport

  • How to identify the presence of scroll bars in browser from the plug-in

    I am developing a plug-in for the type application/x-shockwave-flash. In windowless mode, firefox window client area shared by all the plug-ins. Since plug-in runs in plugincontainer.exe, and DC is passed from firefox.exe, i couldn't the any api or the way to query the firefox for the presence of scrolling bars.
    Could you please tell me the way to identify the presence of scrolling bars in the browser from the plug-in?

    Go to DB02 --> Additional functions --> BW analysis , you will see rows (in pink) highlighted for cubes , dsos and PSA.
    For cubes click on highlighted row for cube and put filter *cube name * , it will shows all related tables with the space . Space occupied by different tables of the cube can be summed up to get total value .
    Similarly for DSO and PSAs.
    You may download this information on an excel and then put descending order on space column to get cubes occupying max space .
    Also look for table RSDODSO (directory for all DSOs) and RSDCUBE ( directory for all cubes) , i suppose you will get space information there as well.

  • No scroll bars in new iTunes update

    Very frustrating, as unable to see all my applications on one page. NO SCROLL BARS, and the keyboard shortcuts dont work either. No way to change to font or screen size. Not very helpful.

    Have you tried to reposition your iTunes window. It might be that when the iTunes window is maximised the vertical scrollbar moves off the right side of the screen. 'Restore Down' and manually position iTunes on the screen to see the vertical scrollbar.

  • To stop scroll bars appearing around iView

    Hello all,
    I've placed a small iVIew in the tool area of the framework page, below the masthead, above the TLN; right beside the KM search iView.
    The user has noticed that when he doesn't have IE fully maximized, if he makes the window small enough then scroll bars appear around this iView. However, scrollbars never appear around the KM search iView.
    Is there a setting or parameter that I can set to say, 'Never put scrollbars around my iView'?
    I've already made the tray invisible of course....
    Any ideas?
    Patrick.

    I have the same problem. I am trying to use a URL iView at the very top of the site - over the masthead. I only want a 10px high iView that simply displays a bar across the top. This iView is not contained in a page, has all of it's properties set in a way that should eliminate any scroll bar activity, yet scroll bars appear regardless...
    Automatic causes the iview to expand to approx. 200px high... no good.
    Fixed causes scroll bars
    Full page - well, makes this iview the full page - no good either.
    Any suggestions? There is really no content in it other then an image to create a bar across the top of the site.

  • How to stop Current Processor role (ChaRM) from updating to current user

    Hi
    We are utilising the Current Processor role in two transaction types (ZMTM and ZMAD) and using these transactions in CRM Web Client UI.
    However, we do NOT want the Current Processor role to update automatically to the current user.
    Here is Partner Determination for ZMTM. As you can see the Current Processor is blank in the Trigger and Access sequence fields. I have also tried filling this in but it didn't make a difference.
    I have also gone into the Automatic Assignment Settings in SPRO
    The Help Text for this configuration is below.
    I have left the configuration blank so I don't want the Current Processor updating (i.e. whatever Business Partner we type in, we want it to stay this way unless we manually change it. No automatic update).
    Despite this, the Current Processor always updates to the Current User in CRM Web Client UI.  How do I change this???
    Thanks all
    Shaun

    Grrr....as soon as I posted this I found the resolution.
    I had to input this into customizing:

  • How do I stop extra windows or programs from opening automatically when I access my Applications folder via Finder?

    Each time I access my Applications folder via Finder, a bunch of ejectable windows or previously downloaded programs open up on the desktop. I have ejected each one or placed it in the trash, but it still happens. How do I stop this from happening?

    I asked the same question on Yahoo! Answers, and I was advised to reinstall Firefox, which I have just done (with version 3.6.8). The problem seems to be solved. Prior to doing this, I attempted to uninstall my previous version, but Control Panel wouldn't let me do this, nor would Windows Explorer allow me to send the whole Mozilla Firefox folder to the Recycle Bin. I went to Plan C, which was to delete all the subfolders in the main folder, followed by the leftover files, and finally empty the Recycle bin. Then I used Internet Explorer to download the newer version of Firefox, and installed it. No more extra home pages, so far.

  • How can I stop iTunes downloading every podcast from the cloud when I only want unplayed podcasts to show in iTunes?

    When I set iTunes to automatically download all new episodes and only keep unplayed episodes, it downloads every episode in every one of my podcasts feeds. This means thousands of files, as not every XML feed hosts only a few files. Some host hundreds.
    How can I get rid of all these podcasts that I don't want to display? The old way was a superior user experience to the way it is now.

    My workaround for this is to set up a smart playlist. I hope this is another one of the issues that gets cleard up when Apple eventually releases an 11.1.1 update.

  • How to exclude Table`s  scroll bar from Drag Source

    Hi
    i have an af:table inside other af:table as its column like below sample
    and user can drag inner table and drop it to other row of outer table but when user click on the scrollbar of inner table to scrolling the inner table selected as drag source and user con not scroll inner table
    so is it possible to exclude scroll bars of table from drag source?
    depart Id
    Dep name
    Emp
    dep1
    IT
    emp Name
    emp email
    emp Tel
    jan
    [email protected]
    8990
    dav
    [email protected]
    8844
    dep2
    Finance
    emp Name
    emp email
    emp Tel
    smit
    [email protected]
    8745
    mary
    [email protected]
    8952

    Hi,
    Always mention your JDev version.
    As Timo mentioned, it would be easier for you if you use a treeTable. Any specific reasons why you don't want to use it? If you want to do it through iterator, you could also use a grid layout (depends on your JDev version) to make it look like a grid.
    -Arun

  • JScrollPane's scroll bar alignment

    I tried all the suggested methods, and yet I still get the vertical scroll bar aligned somewhere in the middle when the JFrame opens, when top alignment would be preferable... Any suggestion on this is more than welcome. My code is structured with nested components like this:
    JScrollPane scroll
    ---JPanel allJPanels
    ------JPanel a
    ---------JPanel a_1
    ---------JLabel a_2
    ---------JEditorPane a_3
    ------JPanel b
    ---------JPanel b_1
    ---------JLabel b_2
    ---------JEditorPane b_3
    scroll.setViewportView( allJPanels );
    Methods attempted:
    scroll.getVerticalScrollBar().setValue( scroll.getVerticalScrollBar().getMinimum() );
    OR
    scroll.getViewport().setViewPosition( new java.awt.Point( 0, 0 ) );
    OR
    scroll.getVerticalScrollBar().getModel().setValue( 0 );     
    OR
    allJPanels.scrollRectToVisible( new java.awt.Rectangle( 1, 1, allJPanels.getWidth(), allJPanels.getHeight() ) );
    Thanks for any suggestion

    Could you please explain your exact requirement. If you just want whether you have to show the scrollpane or not then there is a policy in JScrollpane in which you can set the vertical scrollbar policy as required.

  • Magic mouse stopped scrolling after system update

    Does anyone know why the mouse would stop scrolling after latest OS X update?
    Currently using V 10.8.5

    Hello Kaulfurst,
    While the article states that it is for Lion, this applies for Mountain Lion, as well. You may need to check that scrolling is enabled in the Accessibility pane of System Preferences.
    Magic Trackpad and Magic Mouse: How to adjust double-click and scrolling speed in Lion
    http://support.apple.com/kb/HT4930
    Cheers,
    Allen

  • I Need to Stop Ipod from updating!!! Please HELP!!!

    Hi everyone,
    My computer crashed only a few days ago and doesn't look like it can be fixed, so that means that my whole Ipod libery will be wiped! (I have about 10GB worth of music and vids on it!) and I have only a quarter of the stuff backed up (my own fault, I know!) and I recently thought all my stuff would be gone forever untill I discovered the IpodRip Software.
    I've never heard of it before, but I'm willing to try anything to get my libery back. The only problem is, my Iopd was set to Update Automaticly as soon as it's pluggged into my computer. The only way the IpodRip software will work is if everything remains in the ipod and as well all know, if I plug it into my comp and there is nothing in my libery, the ipod will be wiped!!
    Does anyone know how to stop it from Updating Automaticly when I plug it in??!
    I would really appricate anyones help on this, thank you so much!!
    Dell   Windows XP Pro  
    Dell   Windows XP Pro   30GB Ipod

    Connect your iPod and when you get the message that it is linked to a different library and asking if you want to link to this one and replace all your songs etc, press "Cancel". Pressing "Erase and Sync" will irretrievably remove all songs from your iPod. Your iPod should appear in the iTunes source list from where you can change the update setting to manual and use your iPod without the risk of accidentally erasing it. Also when using a lot of the utilities your iPod needs to be enabled for disc use, changing to manual update will do this by default. Check the "manually manage music and videos" box in Summary then press the Apply button: Managing content manually on iPod
    You can also use a keyboard command to prevent your iPod auto-syncing with iTunes. While connecting the iPod to the computer on Windows with iTunes 7 installed hold down the Control and Alt keys (or Shift + Ctrl keys in older versions). This will stop the iPod from auto-syncing with iTunes and the iPod will appear in the source list. Wait until you are sure the iPod has mounted, and that it will not auto sync and then you can let the keys go. This may take between 20 to 30 seconds depending on your computer: iTunes 7 Keyboard Shortcuts for Windows

  • Bring back traditional scroll bars and arrows

    Why would Apple change a fundemental part of the UI? Removing scroll bars and arrows from the UI is unacceptable in my view. I understand you can restore scroll bar functionality from system preferences but having the arrows on certain apps is very helpful. What possible reason or improvement could warrant this action?
    -LB

    I'm a Wacom tablet user for many yeras, an not planning to get a Magic Mouse ($60.89) or Magic Trackpad ($96.03).
    Why? Till 10.6.8 it work fine. It looks to me that Apple wants te sell more of there Mouse and Trackpads.
    Just bring back traditional scroll bars and arrows as a option.
    Apple starting to look like Microsoft. "We know what's best for you".
    Just give the OSX users a option. I'll wait for a OSX update or for some one how writes a nice small utility to bring theme back. He/She will be a hero.
    A said Lion User

  • How do I stop the iMessage conversation from automatically showing when I go into the I message center? I only want the contacts to show down the left side and nothing on the right until I select a conversation to view.

    HOW DO I STOP THE WHOLE IMESSAGE CONVERSATION FROM AUTOMATICALLY SHOWING WHEN I GO INTO IMESSAGE? I only want the contact bar on the left to show and not the whole conversation, until I pick one to see.

    You can't. You can sign out of messages and turn it off, but you can't do what you would like to do. You can send feedback to Apple.
    https://www.apple.com/feedback/ipad.html

Maybe you are looking for