How to scroll JList to bottom

I have a JList on a JScrollPane, and it updates in real-time.
As the data fills the pane, I want it to scroll to the bottom all the time,
but it stays at the top. I update as follows:
String voltString[]=new String[someNumber];
// Set the strings to stuff--code omitted
voltList.setListData(voltStrings);
voltList.ensureIndexIsVisible(voltStrings.length);But it doesn't work. The API for ensureIndexIsVisible says something
about a JViewPort, but I am not sure what it means--I have it on a
JScrollPane, not a JViewPort.

works OK like this
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Testing extends JFrame
  int counter = 0;
  javax.swing.Timer timer;
  public Testing()
    setLocation(200,100);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    final DefaultListModel lm = new DefaultListModel();
    final JList list = new JList(lm);
    JScrollPane sp = new JScrollPane(list);
    sp.setPreferredSize(new Dimension(100,150));
    getContentPane().add(sp);
    pack();
    setVisible(true);
    ActionListener al = new ActionListener(){
      public void actionPerformed(ActionEvent ae){
        lm.addElement(counter);
        counter++;
        list.ensureIndexIsVisible(lm.size()-1);
        if(counter > 100) timer.stop();}};
    timer = new javax.swing.Timer(100,al);
    timer.start();
  public static void main(String[] args){new Testing();}
}

Similar Messages

  • How to scroll at the bottom using scroll pane

    i am having a label in which i have added a scroll pane. dynamically i will add some text to the label. the scroll bar should move to the buttom after addition of text so that the new text added should be visible.
    please provide me a solution.

    Swap from using a JLabel to a JTextArea, then use below to set position viewed. (do this after each time you enter any text)
    yourJTextArea.setCaretPosition(yourJTextArea.getText().length());

  • When you scroll to the bottom of the list of files in Finder, the left to right scrollbar doesn't let you click the last file and it covers the file for a while until it disappears. Is this a bug? How do I not make that happen?

    When you scroll to the bottom of the list of files in Finder, the left to right scrollbar doesn't let you click the last file and it covers the file for a while until it disappears. Is this a bug? How do I not make that happen?

    An odd workaround: click "Always" in System Preferences/General/Show scroll bars. The scroll bars will always show, but they won't cover your last file.
    See this other post: https://discussions.apple.com/message/20572471#20572471

  • How to know when I have scrolled to the bottom of my advancedDataGrid

    I need to know when I have scrolled to the bottom of my advancedDataGrid or when the last row appears on the screen. Is there anyway of getting this?
    I tried to do it by the verticalScrollPosition, but I don't know how to find the maxScrollPosition.
    Any help would be appreciated.

    Follow above instructions. Use the App Store to get applications for your computer via Apple. Apps for your iDevice are purchased through the iTunes Store. These are two different stores. Now you will have Numbers on your iPhone or iPad or iPod Touch, and then one for your Mac computer.
    The Dock icon for the App Store looks like this:

  • Can't Scroll To The Bottom Of The Page

    I’ve had an issue pop up that I need help with in trying to remedy. I have developed the following page to work on IE 7 & 8, Safari, Chrome, Opera, and Firefox.......
    Totten Insurance Group Products Page
    ...... it was discussed, critiqued, and developed over several months by an entire team of people who saw several different designs and concepts that I presented to them and it works fine on all browsers, unless you make a menu selection and navigate away from this page, and then go back to this page.
    Give it a try, you'll see what I mean. For example, if you scroll over "Commercial Casualty" and selection "Airside Liability" from the list, and then go back, you won't be able to scroll to the bottom of the Commercial Casualty menu. It keeps jumping up and won't allow you to see the bottom of the menu(s), unless you refresh the page.
    Any suggestions on how to remedy this so users don't have to refresh the page?
    Aaryn

    Try hitting '''F7'''. You probably inadvertently activated Caret browsing. <br />
    http://kb.mozillazine.org/Accessibility.browsewithcaret

  • Scroll text to bottom

    I have imported text into a dynamic text field with a scroll
    bar.
    How would I go about starting the imported text at the bottom
    rather than having to scroll to the bottom?
    Normal:
    ----------------- window top
    text 1
    text 2
    text 3
    ----------------- window bottom
    text 4
    text 5
    Instead I would like:
    text 1
    text 2
    ----------------- window top
    text 3
    text 4
    text 5
    ----------------- window bottom
    Sorry if i explained it badly.

    You can set the scroll of the text field to the maxscroll
    value of the
    text field. You have to wait until the text has downloaded
    and populated
    the text field before you can change its scroll value.
    Rob
    Rob Dillon
    Adobe Community Expert
    http://www.ddg-designs.com
    412.243.9119

  • Scrolling To The Bottom of a WebView

    I'm trying to figure out how to determine when the user has either scrolled to the bottom or the top of a web view. There doesn't seem to be a way to get the current scroll position within the webview. The ScrollEvent only shows the current delta, and there doesn't seem to be a way to determine how much of the document is not visible (clipped).
    Mark

    OK. My hack for this is ugly but it works:
    WebView view...
    Set<Node> nodes = view.lookupAll(".scroll-bar");
                    for (Node node : nodes) {
                        if (ScrollBar.class.isInstance(node)) {
                            ScrollBar scroll = (ScrollBar) node;
                            scrollPos = scroll.getValue();The view.lookupAll call is the only way to actually get a handle on the webview's scrollbars. Since there are a couple of components that actually use the scroll-bar style, you have to make sure that the node is a ScrollBar before you do anything with it.
    This shouldn't be necessary. Ideally the ScrollEvent class should give you handle on the ScrollBar, or give you the current scrolling position in relation to the max and min values. However, that doesn't seem to be the case. Prior to this, I tried putting the WebView in a ScrollPane, and a variety of other hacks, but every time I debugged through it, I would never get the right scroll position.

  • Why does my screen scroll to the bottom automatically after I've entered a new website on a new tab?

    When I'm on a website and click onto information or another site from this open window, a new tab is opened with the new info or website. However, while waiting for that site to load in the new tab, the site is automatically scrolled to the bottom before I can even read through it. Why is this happening and how can I stop it?

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • 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.

  • How 2?: fixed footer, bottom left corner of browser

    ... trying to make a footer 252px high and 800px wide that is fixed (does not scroll) in the bottom left corner of the browser window. how do I deal with adapting to different resolutions?

    Here's another tutorial that may help with fixed footers:
    http://www.dave-woods.co.uk/index.php/css-fixed-footer/
    Sticky footer:
    http://www.cssstickyfooter.com/
    Nadia
    Adobe® Community Expert : Dreamweaver
    http://www.perrelink.com.au
    Unique CSS Templates | Tutorials | SEO Articles
    http://www.DreamweaverResources.com
    http://twitter.com/nadiap

  • I have a version 7.0.4.  I can't connect to the server.  My capacity is 13.5  with 10.4 GB available.  Diagnostics and usage data, when scrolled to the bottom, tells me I have low memory.

    I have a version 7.0.4.  I can't connect to the server.  My capacity is 13.5  with 10.4 GB available.  Diagnostics and usage data, when scrolled to the bottom, tells me I have low memory.How cani fix this?

    Clear Safari, close all apps on the iPad and reboot. Then see if you can connect.
    Go to Settings>Safari>Clear Cookies and Data.
    Double tap the home button and you will see apps lined up going left to right across the screen. Swipe to get to each app then swipe "up" on the app preview thumbnail to close it.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.
    If you still can't connect to the internet, you need to do some more troubleshooting with the network connection, but report back with more details if that doesn't work and don't just repeat the question in the text box are that you have to describe the problem. That serves no purpose at all.

  • "how to get to the bottom of a page fast on the iPad Air"

    how to get to the bottom of a page fast on the iPad Air"

    thank you!  I am admiring my three dots and considering which cat's picture I should upload as my avatar.
    yes, the scrolling down in sections I have managed.  I thought you were saying one set of double taps would go straight to the bottom.
    here's another question for you:  on my iMac by holding the command key down I can make a link open in a new tab.  Do you know if there is a way to do that on the iPad?

  • I turned some mode where i have to double tap everything and i cant figure out how to scroll, I turned some mode where i have to double tap everything and i cant figure out how to scroll

    I need  help I turned some mode on that makes me duoble tap whatever i want to open it say whatever it is i am touching and I cant figure out how to scroll to turn it off

    It is an accessibility setting and is covered in the manual:
    iPhone User Guide (For iOS 5.1 Software)

  • How do you have the bottom stroke of a table show up using Table Styles and Cell Styles only?

    I am using InDesign CS6, and I want to create a Table Style that has the bottom stroke show up, but does not have a table border, such as:
    However, whenever I try to change the Table or Cell strokes so that the last stroke shows up, I get the entire table border, or some strange combination of borders:
    Does anyone have any insight on how I can get the bottom stroke to show up while preserving my other stroke properties? Since I work with long documents, it's necessary to be able to control all of my tables through Table Styles and Cell Styles, and not by manually changing each and every table with the Stroke palette.
    For reference, here are the my current Table Style properties and the resulting table:

    Michael Murphy is the InDesign style-meister. He wrote "Adobe InDesign Styles" for Adobe Press, and did a great Lynda.com title on InDesign styling. Here's what he says in the book:
    "As mentioned at the beginning of this chapter, with all the power of table and cell styles, it is important to understand not only how they work and what they can do for you, but also to understand their limitations.
    "Two formatting features missing in table and cell styles have already been discussed: You will always have to set the column width and row height of cells when applying a table style for the first time, and you will always have to convert body rows to header and/or footer rows every time you apply a table style for first time or update the table's data....
    "But there's another kind of limitation that's important to keep in mind as you are designing tables: It is very easy to design a table that cannot be completely defined by a table style. In many cases, you'll need to define an extra cell style or two that lets you complete for formatting. [my emphasis]."
    So I think that's what you have to do: Apply another cell style on top of the cells at the bottom of the table after applying the table style.

  • Space appears after text when you scroll to the bottom

    i am a newbie flash designer. a client has asked me to make modifications in a flash file used on his website. it is flash 8 actionscript. i am currently working on the same and would appreciate your help. the client has given me 'divisions.swf' file which i decompiled using sothink decompiler 4.5 build 90120 to '~divisions original.fla'. the xml folder resides in the same folder as ~divisions original.fla. it contains divisions.xml. you can download these files at http://rapidshare.com/files/257100523/space_after_text_when_scroll_to_bottom.zip
    i discovered a problem - if you view 'divisions.swf' - when you click on 'retail visual solutions'and scroll to the bottom, you can see that there is no space after the text. the end of the text aligns with the end of the scrollbar. but when you click on eyesite, and scroll to the bottom, you can see that there is space after the text. the end of the text does not align with the end of the scrollbar.
    please help me to resolve this problem.
    my additional questions are:
    has the creator of the swf file used some unique scrollbar code or is this scrollbar provided in flash itself. in this case, i can read a tutorial to understand it better.
    i have given 'is correct - no space at bottom of text.jpg' and 'is incorrect - space at bottom of text.jpg' to further explain my query.
    please tell me if i have explained my problem properly or further clarifications are needed.

    Try changing the code in frame 16 to be:
    stop ();
    var tString = xmlObj.Options.Option[2]._value;
    tString = tString.split("\r\n").join("\r").split("\n\r").join("\r");
    txt3.htmlText = tString;
    The scrollbar is a component that may or may not have been concocted by the original designer.  In any case it does utilize the FScrollbar feature of Flash.  You can read about it via the link below:
    http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dic tionary303.html.

Maybe you are looking for