?
Solved

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

Posted on 2008-06-14
7
Medium Priority
?
453 Views
Last Modified: 2013-12-17
java jscroll how to disable scrolling while user is holding the thumb
0
Comment
Question by:newagedevil4u
2 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month16 days, 10 hours left to enroll

862 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