This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTree expansion & collapse programatically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTree expansion & collapse programatically" Watch "JTree expansion & collapse programatically" New topic

JTree expansion & collapse programatically

Nageswar Kakolla
Ranch Hand

Joined: Jan 16, 2006
Posts: 71
Hi there,

I am trying to do JTree expand & collapse one level at a time whenever user presses Expand & collapse button.

few questins ?

there are so many implementations if found for above way using getRowcount,
getRootToPaht(rootNode) and expand recursively etc

while expand is working , collapse wont work if both are implemented using same logic

Also, JTree.getRowCount() API returns no. of rows ? I dont understand this
JTree is stored as row & columns in array and does some body can explain this that will be great ?

int row = m_deficiencyTree.getRowCount();

while(row >= 0){

above code is for whole Tree collapse but i want to do one at a time ?
similary with Tree expansion ?

Also, Swing is becoming tougher for me since it looks like i have to master API or what is better way to mast SWING
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
I agree. Here's the link:
subject: JTree expansion & collapse programatically
jQuery in Action, 3rd edition