Link to home
Create AccountLog in
Avatar of newagedevil4u
newagedevil4u

asked on

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

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

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer