Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #146
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail |
|---|---|
| From | "usenet" <usenet@THRWHITE.remove-dii-this> |
| Subject | Re: How to auto-expand JT |
| Message-ID | <1T3kvap9Is4c@uni.chka.de> (permalink) |
| X-Comment-To | comp.lang.java.gui |
| Newsgroups | comp.lang.java.gui |
| In-Reply-To | <Xns9880AF27B8943realhowtowwwrgagnonc@140.99.99.130> |
| References | <Xns9880AF27B8943realhowtowwwrgagnonc@140.99.99.130> |
| Content-Type | text/plain; charset=IBM437 |
| Content-Transfer-Encoding | 8bit |
| X-Gateway | time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] |
| Lines | 66 |
| Date | Wed, 27 Apr 2011 15:25:52 GMT |
| NNTP-Posting-Host | 96.60.20.240 |
| X-Complaints-To | news@tds.net |
| X-Trace | newsreading01.news.tds.net 1303917952 96.60.20.240 (Wed, 27 Apr 2011 10:25:52 CDT) |
| NNTP-Posting-Date | Wed, 27 Apr 2011 10:25:52 CDT |
| Organization | TDS.net |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.gui:146 |
Show key headers only | View raw
To: comp.lang.java.gui
Real Gagnon <realgagnon+usenet@rgagnon.com> wrote:
> "wensa" <zhengwt@gmail.com> wrote in news:1163937759.015606.159670
> @m7g2000cwm.googlegroups.com:
> > I've googled this topic, but does not get a detailed answer.
> >
> > Thanks in advance!
> >
> See http://www.rgagnon.com/javadetails/java-0210.html
expandAll2Last (silly name?) should read
// assumes 'tree' has a DefaultTreeModel!
public void expandAll2Last(JTree tree)
{
DefaultTreeModel data = (DefaultTreeModel).getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode)data.getRoot();
if (root != null)
tree.scrollPathToVisible(new TreePath(data.getPathToRoot(root.getLastLeaf())));
}
or more generally (untested):
public void expandAll2Last(JTree tree)
{
TreeModel data = tree.getModel();
Object node = data.getRoot();
if (node == null)
return;
TreePath p = new TreePath(node);
while (true)
{
int count = data.getChildCount(node);
if (count == 0)
break;
node = data.getChild(node, count - 1);
p = p.pathByAddingChild(node);
}
tree.scrollPathToVisible(p);
}
Also, it is not clear why this method should also scroll, and that it does
not expand the last component (even if not a leaf).
Christian
---
* 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 — Previous in thread | Find similar
How to auto-expand JTree "wensa" <wensa@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
Re: How to auto-expand JT "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
Re: How to auto-expand JT "wensa" <wensa@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
Re: How to auto-expand JT "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
Re: How to auto-expand JT "Real Gagnon" <real.gagnon@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
Re: How to auto-expand JT "usenet" <usenet@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
csiph-web