Question about Adjusting JScrollPane


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Question about Adjusting JScrollPane

  1. #1
    Join Date
    May 2005
    Posts
    9

    Question about Adjusting JScrollPane

    hello, I'm new to java GUI programming, and I have a question:

    I've created a list box that's connected to a JScrollPane in order to show the scroll bar.
    it works fine. however, when lines inserted to the listbox exceed it's buttom border, the scrollbar indeed strech, but stay at the top of the listBox.
    how can I make it, that it will alway dynamicly be as low as it can ?

    thanx in advance.

  2. #2
    Join Date
    Aug 2003
    Posts
    313
    Try setting the selected index of the JList to the most recently added one (the one at the bottom I'm guessing).
    ~evlich

  3. #3
    Join Date
    May 2005
    Posts
    9
    I thought of that already,
    it marks the buttom line, but doesn't scroll down to it, you have to do it manually to see the selected last line...

  4. #4
    Join Date
    Aug 2003
    Posts
    313
    Ah, sorry about that. Take a look at the JList API. Inheriting from JComponent is a method "scrollRectToVisible". That should do the trick. Just call getCellBounds on the last cell and then perform a scrollRectToVisible on it.

    Hope this helps.
    ~evlich

  5. #5
    Join Date
    May 2005
    Posts
    9
    Thanx a lot man! it works !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center