Automatic scrolling using textareas.

My application has a jscrollpane with several components being dynamically created. It adds jtextareas just fine, however, when it populates the jtextareas with text, it scrolls down to the last text area. My users do not want this. How can I get around the auto-scrolling when the jtextareas use the setText( ) method?

I did some fiddling with this about a year ago. I don't remember the details, but according to some leftover code something like this might do the trick:
    Document d = textarea.getDocument();
    try {
        d.insertString(d.getLength(), s, null);
    } catch (BadLocationException ble) {
        //Shouldn't happen when getLenght() is used for index.
        //If it happens anyway, write a stacktrace and
        //otherwise ignore it.
        ble.printStackTrace();
    }If this does not work, you should something like this: (very rough and untested. Read the API for details.)
    int currentPosition = scrollpane.getVerticalScrollbar().getPosition();
    // ... do the adding ...
    scrollpane.getVerticalScrollbar().setPosition(currentPosition);

Similar Messages

  • The find function used to automatically scroll to the next word, now it doesn't. How do I fix it?

    The find function used to automatically scroll to the instance of the word I was looking for. Now it doesn't. How do I fix this?
    == This happened ==
    Every time Firefox opened
    == a few months ago

    Hmm... you're right. I don't have access to that Google Doc, but our support.mozilla.com weekly metrics are on Google Docs, and I see the same issue there.
    https://spreadsheets.google.com/ccc?key=0Aibg4PvTbjUKcGlBLWEtZFhDTDJwN3ZCNXBUdTBIS0E&hl=en#gid=0
    It may be specific to Google spreadsheets (and whether or not you have permission to edit the doc). I'm currently trying to find out if that's a Firefox bug, or a Google bug. If you use the '''Ctrl-F''' keyboard shortcut, Google's Find feature takes over, so they obviously want people using their Find utility.

  • How to automatically scroll text in JScrollPane

    Hi there
    I have a very simple question...
    How to automatically scroll text in JScrollPane?
    Text in the TextArea is constantly getting updated... but the scroll bars dont' move as the text changes. Instead I ahve to scroll and see the changes everytime. How can I make the viewport or the scrollpane to show the latest content?
    Thanks in advance.
    Dexter

    This question is asked daily (it seems) on the forum. Hopefully the TextAreaScroll class will explain whats going on:
    **  Short answer is to use the following after the append:
    **  textArea.setCaretPosition(textArea.getDocument().getLength()
    **  However, if you really want to know what is going on, then I have
    **  I have observed the following behaviour in JDK1.4.2
    **  JTextArea will scroll automatically when text is appended, if:
    **  a) the caret is at the end of the text area, and
    **  b) the append is done in the event thread
    **  Note: Initializing a text area at creation time by any of the following
    **  aproaches will cause the caret to be positioned at the start and therefore
    **  scrolling will not happen automatically:
    **  a) JTextArea textArea = new JTextArea("Initial text", ...);
    **  b) textArea.setText("Initial text");
    **  c) textArea.read(someFile, null);
    **  The append method can be forced to execute in the Event thread by using
    **  SwingUtilities.invokeLater();
    **  Alternatively you can force a scroll by repositioning the caret.
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Date;
    import javax.swing.*;
    import javax.swing.text.*;
    public class TextAreaScroll
         public static void main(String[] args)
              final JTextArea textAreaWest = new JTextArea(10, 25);
              JScrollPane scrollPaneWest = new JScrollPane( textAreaWest );
              final JTextArea textAreaEast = new JTextArea(10, 25);
              JScrollPane scrollPaneEast = new JScrollPane( textAreaEast );
              JFrame frame = new JFrame();
              frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              frame.getContentPane().add(scrollPaneWest, BorderLayout.WEST);
              frame.getContentPane().add(scrollPaneEast, BorderLayout.EAST);
              frame.pack();
              frame.setVisible(true);
              //  The West text area will be updated by a Timer. Timer code is
              //  executed in the Event thread so it will scroll correctly.
              new Timer(1000, new ActionListener()
                   public void actionPerformed(ActionEvent e)
                        if (textAreaWest.getDocument().getLength() == 0)
                             textAreaWest.append("West will scroll correctly");
                        textAreaWest.append( "\n" + new Date().toString());
              }).start();
              //  The East text area is not updated in the Event thread.
              //  It will not scroll correctly.
              while (true)
                   try
                        if (textAreaEast.getDocument().getLength() == 0)
                             textAreaEast.append("East will not scroll correctly");
                        textAreaEast.append( "\n" + new Date().toString() );
                        //  Using this method causes the text area to scroll because
                        //  this method will invoke SwingUtilities.invokeLater(...)
                        textAreaEast.setCaretPosition( textAreaEast.getDocument().getLength() );
                        //  Using SwingUtilities.invokeLater causes the code to execute
                        //  on the Event thread
                        //  (comment all the above lines before testing)
                        SwingUtilities.invokeLater( new Runnable()
                             public void run()
                                  textAreaEast.append( "\n" + new Date().toString() );
                        Thread.sleep(1000);
                   catch (InterruptedException ie) {}
    }

  • Scrolling a TextArea just after updating htmlText property in AIR - need a workaround

    Hi,
    There's an annoying bug in AIR (or in the TextArea component itself but showing up only in AIR) because of which, if you do:
    my_textarea.htmlText=someLongText;
    my_textarea.textField.scrollV=someValue;
    the second instruction just does not work, and the textarea scrolls to the beginning (as a consequence of the first assignment).
    Has anyone else run into this and have you come up with any workaround?
    This only happens in AIR, not FP, and only with TextArea, not with a plain input text.

    Thank you for the suggestion.
    A delay (or waiting for the next frame) will certainly ensure that the scroll bar is updated, but unfortunately it's not an acceptable solution in my case because you'll see the scroll bar jump for an instant, no matter how short it will bee too much.
    (FYI, the fact that the text takes a bit to populate the text field is  not relevant since no matter how long it takes it is synchronous)
    I have a script that changes the htmlText while you type, in a way that is not visible at all because it just adds link tags around some words in the text (note that links are not underlined nor highlighted in any way by default). This implies reassigning the whole htmlText, which in turn means the scrollV property is reset. So, before i change the text, I store the current value of scrollV into a variable, and after changing the text, I reassign the original scrollV value. All this is done within a function, it is synchronous, so even if it happens while you type you don't notice it (if this was inefficient and slow, which it may be if the text is very long, you would notice that it hangs for an instant, but you'll never notice any movement in the scroll bar or the text as there is no way a frame can be redrawn during the operation).
    This trick works perfectly with a textfield without scrollbar. It also works with a TextArea in Flash Player, but it does not work in AIR with TextArea because the text automatically scrolls back to the beginning.
    With the delay trick, it would every once in a while jump to the beginning and back where it was which even though very quick would be very annoying since it would be happening all the time.
    I think I narrowed this down to a bug in the UIScrollBar component, which I guess is used inside TextArea. If you do the following with a UIScrollBar:
    - assign a text field as the scrollbar's target
    - empty the textfield (or make the text short enough so that its maxScrollV is 1
    Then the scrollbar automatically becomes disabled
    - now populate the text field with enough text to exceed its height
    - change its scrollV property to anything >1
    If you do all this in one method, the scroll bar automatically gets enabled again, but it forces the textfield to scroll back to the beginning while it shouldn't at all.
    At the end I solved this by giving up TextArea and using a TextField and a ScrollBar - NOT a UIScrollBar (which doesn't help since it suffers from basically the same problem) but a ScrollBar. ScrollBar doesn't have a target property and doesn't disable/reenable itself automatically, so I just never disable it (I simply make it invisible when i don't need it) and everything works fine.

  • 'To do' list automatically scrolls up when I click on another iCal pane

    Hi,
    I've just begun using iCal, so forgive me if this topic has been covered before. (I did a search, but since I don't know how to describe the problem succinctly I didn't get any results.)
    Here goes. Whenever I'm in the 'To Do' pane, say mid-way down the list, and then click the calendar pane my 'To Do' list automatically scrolls up to the top. When I go back to the 'To Do' pane and pull the list down to where I want to be and click on the item that I want to update, the list once again automatically scrolls to the top and I have to pull the list down one more time before I can alter it. It's very annoying and I can't find a way to fix it.
    Any suggestions?
    Tony L.
      Mac OS X (10.4.6)  

    I can confirm this function. Also I wasn't able to find anyway for it to not do this. 
    Post relates to: None

  • How to know in advance if next line will add scrolling a TextArea

    Hi All,
    I have multiple TextAreas in my application, which user can
    edit. I want cursor and focus to automatically shift to Next
    TextArea whenever current Textarea is full without any scrolling
    bar.
    Currently I am checking (maxScrollV>1) property of
    TextField to find if a TextArea is full or not. But this condition
    is true only after adding scrolling in TextArea.
    Is there any way to find if TextArea is full without adding
    any scrolling in current TextArea and shifting focus to next
    TextArea.
    Thanks in Advance..
    N

    Sorry, but there is no way to know in advance.
    Regards.

  • Weird Automatic Scrolling of Timeline

    I am running Premiere Elements 11 on Windows 7, 64 bit, with all the latest updates.
    I'm getting some weird automatic scrolling of the timeline happening.
    When I hover the mouse pointer anywhere on the left side of the screen, (including over the "File" menu bar portion) the timeline automatically starts scrolling left.
    When I hover the mouse pointer anywhere on the right side of the screen (like over the vertical scroll bar), the timeline automatically scrolls right.
    The only way to stop the scrolling is to move the mouse pointer away from the sides of the screen.
    This seems like an error -- but did I accidentally turn on some feature?
    Any suggestions how to get proper control back?
    Thanks,
    Nick

    Thanks for looking into this o promptly.  It's in the middle of the clip I'm marking.  It just happened again to me, and I'm paying a bit more attention to what happens when it occurs. 
    All is well as I'm working on a video track,  using the "go to next/previous keymark" arrows, which moves the CTI.  I want to fade to black so I right click and hold to drop the marker, but when I release the right mouse button, the diamond marker is "stuck" and moves left/right/up/down as I move the mouse.  (unexpected behavior)  I have to right click the mouse a couple of times to get it to release the key frame marker.
    Now when I move the mouse to the far left to select the "next keymark" arrow, the CTI stays put on the timeline and scrolls off the screen on the right as I move the mouse to the left, dragging the whole timeline back to the beginning.  The keyframe that I just dropped is somehow corrupt.  The CTI won't land there if I click next/previous and if I put the CTI on top of it and try to delete it, it stays on the screen.  Deleting the clip from the timeline and inserting it again (loosing my markers) returns me to a stable state.
    I'm guessing it's a mouse driver.  My PC is a Dell laptop and I'm using a USB connected mouse and keyboard, rather than the touchpad.

  • Is it possible to disable the mouse automatically scrolling the video playback head?

    Previous versions of iMovie allowed me to move the mouse without moving the playback head.  Doesn't appear possible in '11.  Can it be toggled?
    Thanks.
    Lindy

    No.  If I run the mouse over a video in iMovie, the video automatically scrolls along with the mouse.  The audio skimming function (if on) allows me to hear the audio along with the video as it scrolls - a useful feature, but not what I'm trying to fix.
    What I'd like to be able to do is turn all of that off so that the only way to play a video is to start it with the space bar.
    As it is now, if I select a spot where I'd like to place a marker or split a video, I have to move the mouse in order to initiate the command that I want.  But the moment I move the mouse to go to a menu, the video moves to a different place, making the edit more difficult.
    iMovieHD ('08) did not have the scrolling function, and while I appreciate the usefulness of having it, I'm struggling with being unable to turn it off.  I could play a video to the point where I wanted to edit it, fine tune the playback head location and perform the edit without so much as touching the mouse.
    It's not that I'm incapable of doing what I need to do with iMovie the way it is.  It just seems a bit tougher to accomplish these things with the scrolling when I don't want it to.  Seems like it should be a Preferences setting or something.  But I can't find it.
    Thanks.
    Lindy

  • Messages pane doesn't automatically scroll down

    In Outlook Express, when the list of messages is from oldest to newest, as new messages arrive, the list of messages automatically scrolls down to display those new messages.
    Out of the box, Thunderbird doesn't do that. You may be aware that there are new messages because Thunderbird has alerted you, but you don't see those messages until you manually scroll down.
    Is there any way to get Thunderbird to mimic Outlook Express?

    mailnews.default_news_sort_order; Value = 1
    mailnews.default_sort_order; Value = 1
    This means your default sort order is ascending.
    (Value = 2 means descending.)
    i'm wondering if you have something set to overrule the scroll to incoming new messages....Done some digging around and located this info....
    If you have a setting that remembers the last selected message, it may be overruling incoming new messages. This would mean that you can continue reading mail from where ever you last stopped, even if new mails arrived. So, thunderbird may scroll initially on startup if new messages have arrived, but thereafter it might not auto scroll because of the setting to remember last selection.
    So, I therefore think that if you want to remember last message you would not be using auto scroll, so the auto scroll would be false. However, you have this set to true and want auto scroll, so try to turn off the remember last message preference and note the effects.
    Please check this setting in the 'Config Editor as before.
    top search type 'remember'
    mailnews.remember_selected_message
    Value = true would switch on the remember last message and could be overriding the scroll.
    Value = false (respectively switches off the preference).
    Suggest you double click on the line to toggle to 'false'.
    close the window - top right X
    click on OK to save changes to Options.
    Close and reopen Thunderbird.
    If the effects of changing this do not suit you, change the setting back to 'true'.

  • Java based Chat console works fine, but does not automatically scroll down to last chat item

    Hi,
    I am currently facing a problem with a Chat program using jsp (Java Server Pages) where the chat console works perfect except for one little thing.
    The chat window does not automatically scroll down to the last reply in the chat window.
    the code used to scroll down to the last items (based on Netscape) is the following:
    <pre><nowiki>if (navigator.appName.indexOf("Netscape") != -1) {
    isOther = (navigator.appVersion.substring(0,1) == "3");
    isNS4 = (navigator.appVersion.substring(0,1) == "4");
    isNS6 = (navigator.appVersion.substring(0,1) == "5");
    } else if (navigator.appName.indexOf("Microsoft Internet Explorer") != -1) {
    isIE = true;
    } else if (navigator.appName.indexOf("Opera") != -1) {
    isOpera = true;
    } else {
    isOther = true;
    if (navigator.platform.indexOf("Mac") != -1)
    isMac = true;
    if (isOther)
    alert("Sorry but you will have to upgrade your browser to NS4+ or IE4+ for this to work properly.");
    function setScrollProperties() {
    if (isMac) {
    scrollStart = 0;
    scrollEnd = answerFrame.document.height - scrollStart;
    } else {
    scrollStart = 0;
    scrollEnd = answerFrame.document.height - scrollStart;
    function doScroll() {
    documentYposition += scrollAmount;
    window.scrollTo(0,documentYposition);
    if (documentYposition < scrollEnd) {
    setTimeout('doScroll()',slowScrollInterval);
    }else if (moreScrolling){
    moreScrolling = false;
    scrolling = false;
    startScroll();
    }else{
    scrolling = false;
    }</nowiki></pre>
    I cannot see what goes wrong in here and the manufacturer does not know how to fix this either.
    Irritatingly this scrolling function is working normally in IE, Chrome and some other browsers.
    I sure hope you can help me, as this is a very irritating problem that needs to be solved.
    Best regards,
    Corné Snoek

    Hi,
    sorry for such a late reply. I tried modifying the java bean to resize the JScrollPane object also but even that didn't work. Then I hardcoded the size of my Java Bean in my forms code by trial and error. For example, the size of the bean area was 381x169. The values that I had to pass to the "setSize" bean method were 510x195. This made the bean exactly fit the bean area. Seems crazy to me, but there it is.
    Anyway, thank you.
    Manu

  • Why the vertical scrollbar bar is automatically scrolled to the bottom pos.

    I created a JScrollpane to contain a JTabbedPane. The JTabbedPane has two JPanel and each of them has a number of GUI components such as JCheckbox and JTextField. They have different size because their GUI components are different. The 2nd panel is about twice the size of the first panel.
    When the JScrollpane is shown, its vertical scroll bar is automatically scrolled to the bottom position. However, it is the first panel that is initially visible to the user. So, the user will see no GUI components of the first panel because the auto scrolling of the vertical scroll bar.
    Can anyone tell me how to disable the auto scrolling?
    I just want to let the scrollbar knob stay at the top so that the GUI components of the first panel (the smaller one) can be seen initially!

    Works fine for me:
    import javax.swing.*;
    import java.awt.*;
    public class TabbedPaneScroll extends JFrame
         private JTabbedPane tabbedPane;
         public TabbedPaneScroll()
              tabbedPane = new JTabbedPane();
              tabbedPane.setPreferredSize( new Dimension(300, 200) );
              getContentPane().add(tabbedPane);
              addNewTab( 10 );
              addNewTab( 5 );
              addNewTab( 20 );
         private void addNewTab(int fields)
              JPanel panel = new JPanel();
              panel.setLayout( new GridLayout(0, 1) );
              for (int i = 0; i < fields; i++)
                   panel.add( new JTextField("" + i) );
              JScrollPane scrollPane = new JScrollPane( panel );
              tabbedPane.add(scrollPane, "" + fields);
         public static void main(String args[])
              TabbedPaneScroll frame = new TabbedPaneScroll();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    }If you need further help then you need to create a [url http://www.physci.org/codes/sscce.jsp]Short, Self Contained, Compilable and Executable, Example Program that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • Table - Automatic scroll on changing the lead selection

    Hi @ all,
    I´ve got two tables and I want to add an entry from tab1 to tab2 if it is not existing in tab2. In case of an existing entry in tab2, the lead selection will be set on the entry in tab2 to show the entry. My Problem is the behaviour of the scroll bar in tab2. I need something like automatic scrolling to the lead selection of the table. Is that possible?
    Armin

    Hi  Armin,
    you can the use the proterty "First visible row" of the table.
    create one attribute of type WDy_BOOLEAN and bind it to the "First visible row" of the table.
    as soon as you set the lead selection,get its index and set it to the attributr that is( property  "First visible row").
    once this property is set , scrolling is done automatically and lead selected row is visible as first row.
    I hope this resolves your issue.
    Thanks,
    Krishna

  • I need an arrow or some sort of icon that points and moves to alert the website user to scroll down.  Are there such widgets or is there a method to make an image move on its own.  Also, how to get my muse webpage to automatically scroll down?

    I need an arrow or some sort of icon that points and moves to alert the website user to scroll down.  Are there such widgets or is there a method to make an image move on its own.  Also, how to get my muse webpage to automatically scroll down?

    Thank you for your help, but I believe my questions remains unanswered -- mainly, because my English isn't the good. 
    Here's what I am asking:
    1.  I need something that is animated that blinks or flashes to alert the viewer to scroll down the page.  I would put the wording:  Scroll Down for more (and then an arrow blinks or gently moves up and down to alert the user to move down).
    2.  is there a way that the entire homepage on it's own moves downward?
    Sorry for my poor English. 
           From: The Arthematics <[email protected]>
    To: preston reed <[email protected]>
    Sent: Tuesday, February 24, 2015 9:42 PM
    Subject:  I need an arrow or some sort of icon that points and moves to alert the website user to scroll down.  Are there such widgets or is there a method to make an image move on its own.  Also, how to get my muse webpage to automatically scroll down?
    I need an arrow or some sort of icon that points and moves to alert the website user to scroll down.  Are there such widgets or is there a method to make an image move on its own.  Also, how to get my muse webpage to automatically scroll down?
    created by The Arthematics in Help with using Adobe Muse CC - View the full discussionIf I understood correctly. You can place arrows on each section of the page and use "fade-in" and "fade-out". And maybe you want this widget Anchor + – Adobe Muse Widget Directory to automatically scroll down. If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/7227429#7227429 and clicking ‘Correct’ below the answer Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/7227429#7227429 To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"  Start a new discussion in Help with using Adobe Muse CC by email or at Adobe Community For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.

  • Disable Automatic Scrolling in Multisim

    The user manual says this:
    "The workspace automatically scrolls if you move your
    cursor to its edges."
    Is there a way to disable this feature?  My screen isn't very big and it is a hassle to try and place a component near the edges of my screen.  Thank you.
    - Mike

    Hi Mike,
    I couldn't find way to disable the scroll.  I like to use the mouse wheel to zoom in/out so when you near the border zoom in page really tight and this may help.
    Tien P.
    National Instruments

  • Text editor ribbon actions cause page to automatically scroll (w/o applying formatting)

    In a page with web part zones and Content Editor web part(s) for text: if you try to edit text using the ribbon menu, sometimes hovering over an action (without clicking) will automatically scroll to the CE web part without applying formatting (since you
    didn't click yet).
    Consider the scenario:
    A content editor web part is added toward the bottom of the page.
    Text is added to this (direct in the web part, not via a 'content link')
    You highlight some text and go to the Markup Style dropdown...
    Everything is fine until you hover over the "Paragraph" markup style, and suddenly the page scrolls to the web part you are editing, and you didn't have a chance to click and apply the "Paragraph" formatting
    I have tried testing this with text typed directly into the Content Editor, text pasted in from somewhere else, and text pasted in from somewhere else using "Paste as Plaintext" option in the ribbon.  In each scenario, I get the same results.
    Furthermore, I have also tested this in both IE8 and IE9 and get the same results.
    This appears to happen randomly with different controls.  I can get it to occur most regularly with trying to apply the Paragraph "Markup Style" but I've also seen this happen with Font Size (any font size).  It's very frustrating since you aren't
    able to actually apply the formatting you need because the page jumps before you can click.  Has anyone experienced this before?  Is there any software I should check (Silverlight, java, etc.)?  Any feedback would help.
    Thank you!

    Hi,
    Thank you for your post.
    I'm trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.
    Xue-mei Chang
    TechNet Community Support

Maybe you are looking for

  • Notas fiscal de entrada com desconto incondicional no icms.

    Estou com um problema no cálculo de notas de entrada com icms-st, na nota fiscal do fornecedor foi aplicado um desconto ( chamado na área fiscal de desconto incondicional na base de icms) sendo que para o calculo do icms-st não podemos  utilizar  est

  • Bad quality playback when burnt to DVD

    Hey, I have burnt my imovie project using the share - media browser in imovie and then the professional setting in idvd. When I play it on my new sony dvd/bluray player on my full hd tv with HDMI lead it has very poor playback. The sound is very muff

  • Webview Agent 24 Report Question

    From business Unit I was running agent report 24 last week to look at calls held and hold time.  I noticed several agents where the report does not seem to record the hold time properly.  Looking at the Queue summary. For example,  the February repor

  • Crystal Reports XI R2 Javascript error when viewing web report

    Post Author: msilka CA Forum: General I have an ASP web application that was working fine with XI but when I upgraded to XI R2 I received the following error when displaying a report in the report viewer. Line: 461 Char: 1 Error: Object expected Code

  • Creating Production Order with wrong production version

    Hello Expert, please provide me answer and solution to resolve our problem regarding creation of production order (CO01 and CO41), because SAP provide and propose production version which have alternative BOM which is status 02 (inactive) already it