Re: JList: Scroll to Selected Item



Hal Vaughan wrote:
I'm using Java 1.4.2 and I've tried searching for this and can't find it,
but I'm sure I saw a method for a JList to scroll to the selected item.

There are times a JList (in a JScrollPane) is reloaded. On some platforms,
apparently, when I reload it, even though I make sure the same item stays
selected, users report that the list then resets to show the top of the
list only.

Maybe I'm mixing things up, but I was sure I saw something like
scrollToSelected() for a JList or JScrollPane, but I can't find it in the
API index and couldn't find it in a search. Is it under a different
wording or is there another method that scrolls a JList to show the
selected item?

Thanks!

Hal

See JList.ensureIndexIsVisible() and JList.setSelectedValue()

--

Knute Johnson
email s/nospam/knute/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDem
.



Relevant Pages

  • how to force scrolling of a Jlabel ?
    ... How do I force a JLabel wrapped in a JScrollPane to automatically scroll to the last line added? ... The applet retrieves from the web the image (which is displayed in the top panel) and a "region file". ... The point is that, once the panel is full, a scrollbar appears, but the bottom line is no longer on the screen. ...
    (comp.lang.java.programmer)
  • Re: add a String to a JScrollPane
    ... Allan Bruce wrote: ... >>With a JLabel you can change the text at any time you want. ... >>JScrollPane, to cause it to ask the JLabel about its next size. ... JScrollPane if you want it to scroll). ...
    (comp.lang.java.help)
  • Re: Swing Custom JPanel Component Help
    ... I extend JScrollPane because the scrollability of the object is not ... CardGroupPanel a new JScrollPane, I find it much easier to extend ... When extending a JPanel, you can use setOpaqueand the JPanel ... scroll pane, you aren't going to get any scroll bars. ...
    (comp.lang.java.programmer)
  • Re: JList: Scroll to Selected Item
    ... Knute Johnson wrote: ... but I'm sure I saw a method for a JList to scroll to the selected item. ... There are times a JList (in a JScrollPane) is reloaded. ... platforms, apparently, when I reload it, even though I make sure the same ...
    (comp.lang.java.gui)
  • Re: JScrollPane responsive to cursor keys in 1.4, but not in 1.5
    ... The JScrollPane reacts to the cursor keys ... to scroll through the image *without* using the mouse. ... But with Java 1.5.0 the JScrollPane doesn't react to these keys. ...
    (comp.lang.java.gui)