[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How do you delete a row from a JTree?

Posted on 2006-11-20
5
Medium Priority
?
437 Views
Last Modified: 2008-01-09
I created my own JTree model that takes a custom data structure and I build a JTree from the tree model.  That all works fine, the problem occurs when I try to delete a node from the tree.  I am not sure how to do this.  What approach would I use to delete a node and of course redisplay the tree without the node I just attempted to delete.  I'm only deleting the tree node, not the data from the data structure.

gusseology
0
Comment
Question by:gusseology
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 24

Assisted Solution

by:sciuriware
sciuriware earned 300 total points
ID: 17980118
Try:   JTree.removeSelectionRow(int row);

;JOOP!
0
 
LVL 14

Assisted Solution

by:hoomanv
hoomanv earned 300 total points
ID: 17980715
0
 
LVL 92

Accepted Solution

by:
objects earned 900 total points
ID: 17983163
0
 

Author Comment

by:gusseology
ID: 17983890
I'm sorry all, I should have explained it better.

I am not using default tree mode with mutale tree nodes.  I am using my own and therefore methods like removenodeFromParent() can not be used.

Basically what I did was remove the element from the data structure I am using, and remove it from it's parent, and then kill and rebuiild the tree.  This seems to be working okay.  So I am able to remove it now.  My problem now is not after removing it, autmoatically selecting it's parent.

I am able to automatically select its parent because I expand out all the rows, find the parent based on a piece of data, and select it.  The problem is ...I am not able to collapse all the other branches at that point!  grrr.  

I get the path to the element I want to select, and use setSelectionPath to do so, but that setSelectionPath takes in a TreePath and the tree path apparently includes everything expanded out.  So even though it is correctly selecting the right element.....it won't collapse all the other branches!  Anyone know how I might be able to do that??

gusseology
0
 

Author Comment

by:gusseology
ID: 18039290
I'm not really sure how to divide up the points.  I don't think either answer really answered the question, but my question was poorly written.

In the end, my solution was I simply delete the object, then rebuild the tree.

I'll split the points.

Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question