Solved

java jscroll how to disable scrolling while user is holding the thumb

Posted on 2008-06-14
7
432 Views
Last Modified: 2013-12-17
java jscroll how to disable scrolling while user is holding the thumb
0
Comment
Question by:newagedevil4u
7 Comments
 

Author Comment

by:newagedevil4u
ID: 21787938
Here is the test code.
package com.nsn.cdr;
 

import javax.swing.*;

import java.util.*;

import javax.swing.text.*;
 

public class ScrollTest extends JFrame implements Runnable

{
 

    Thread thread;

    JTextPane content;

    JScrollPane contentScroll;

    Document doc;

    int i =0;
 

    public ScrollTest() {

        super("Scroll test");

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        content=new JTextPane();

        content.setEditable(false);

        doc=content.getDocument();

//        contentScroll=new JScrollPane(content);

        contentScroll=new JScrollPane();
 
 

        getContentPane().add(contentScroll);

        thread=new Thread(this);

        thread.setDaemon(true);

        thread.start();

        setSize(300,150);

        setVisible(true);

    }
 

    public void run()

    {

        while(true&&i<1)

        {

            final String line=("gfdgdfgdfgdfghdfhdfhdfhdfhdfhdfhdfhdfgdfgdfgdfhgdfghdifhgudfhgudfhguhdfughdfughdfuihgidfhgdfhgdfhguhdfiguhdfuighudfihgudfhgdfhguhdfghdfughudfhgudfhgudfguhdfughfdghfdhgudfhgufhgudfhgufdhguhfdugfugh"

                               +"\n"+"dfjgdfijgidfjgidfjgijdf"+"\n"+"jgdfgdfkgldfkg"+"\n"+"jgijsdfgij");

            SwingUtilities.invokeLater(new Runnable()

            {

                public void run()

                {

                    try

                    {

                        doc.insertString(doc.getLength(),line,null);

                        i++;

                    }

                    catch(BadLocationException e){}

                }

            });
 

            try

            {

                    Thread.currentThread().sleep(1000);

            }

            catch(Exception e){}

        }
 

    }
 

    public static void main(String[] args) {

        new ScrollTest();

    }
 

}

Open in new window

0
 
LVL 35

Accepted Solution

by:
girionis earned 500 total points
ID: 21801619
You will have to consume the scrolling event while the key is pressed. Have a look here for something similar:

http://www.soft-amis.com/serendipity/index.php?/archives/12-Class-that-any-Swing-application-cant-live-without.html
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now