Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #4107
| From | "JSchneider" <jschneider@THRWHITE.remove-dii-this> |
|---|---|
| Subject | JTree within JScrollPane: |
| Message-ID | <0a56d7bd-4911-480e-82ea-413d2adf8764@c58g2000hsc.googlegroups.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| Date | 2011-04-27 15:48 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui Hi, I have the following requirement: I have a JTree placed within a JScrollPane. The model of the JTree is now updated every other second. But the additional entries are added at the top of the Model (index is nearly always 0). This is a requirement and can't be changed... (Think of a mail client that shows the youngest mails at the bottom and loads the youngest mails first - filling the tree from the bottom to the top). Now the problem: If the user has scrolled to the bottom (he wants to see the youngest entries) the visible entries change every time an additional row is added at the top (old mail has been added). My approach: I calculate the delta between the bottom of the visible rect and the size of the tree when an entry has been added (within a TreeModelListener). Then I have overridden "validate" and "invalidate" and call "scrollRectToVisible" with an updated rect, calculated based on the delta. That works well - just with one exception. ScrollRectToVisble causes a repaint with the old visible rect. Therefore the tree is "jumping" (paints one time with the "wrong" visible rect). When the scroll mode of the JScrollPane is changed to "JViewport.BACKINGSTORE_SCROLL_MODE" everything works fine. Unfortunately this is not an option due to performance issues.... I hope the problem is understandable - any hints or suggestions? Thanks in advance... --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Next in thread | Find similar | Unroll thread
JTree within JScrollPane: "JSchneider" <jschneider@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
Re: JTree within JScrollP "tomaszewski.p" <tomaszewski.p@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
Re: JTree within JScrollP "JSchneider" <jschneider@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
Re: JTree within JScrollP "tomaszewski.p" <tomaszewski.p@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
csiph-web