• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTreeTable Expansion problems

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I tried to customize the JTreeTable from the sun homepage. My tree consists out of DefaultMutableTreeNodes (to be more exactly, an extension of DefaultMutableTreeNodes).
My goal is to get a working TreeTable that has a tree in the first column and according to this tree checkboxes in the second column.
I searched the forum and found this thread: https://coderanch.com/t/338967/GUI/java/JTreeTable-tree-DefaultMutableTreeNodes
It helped me a lot and I did the things as mentioned in this thread. My problem is now, that I cannot expand the tree and I don't know why...

The code in my TreeTableModel impl class looks like that:


And I create the JTreeTable like this:


For explanation: MyTreeNode's userobject can either be a normal String or an Object of type of MyOwnClass (as you see above). The nodes which represents just a String are always the parent, and the nodes which represents MyOwnClass are always the children (= leafs). I of course overwrote some methods in MyTreeNode. I know that the implementation of MyTreeNode is correct, because I used it before in a normal tree and there it worked.


I am really hoping that someone can help me
Thanks...
[ January 05, 2006: Message edited by: Clemens Stich ]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you figure out the problem with the treetable , Since I am having teh same problem , please let me know if you find any

thanks
A Alex
 
Clemens Stich
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No I have no idea how to solve that problem.
Because my tree had a simple binary structure, I decided not to use the TreeTable, but I used a simple table and I just simulated a tree-like view in that table. This isn't the nicest thing to do, but it worked and it was relatively simple
 
A Alex
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are interested I did find the solution
Just add a mouse listner to the table and dispatch the
mouse events to the tree , I havent seen any issues with this
till now . The code section I used is given below

regards
A Alex

MouseListener ml = new MouseAdapter() {
public void mousePressed(MouseEvent e) {
int selRow = m_table.getTree().getRowForLocation(e.getX(), e.getY());
TreePath selPath = m_table.getTree().getPathForLocation(e.getX(), e.getY());

if(selRow != -1) {
if(e.getClickCount() == 1) {
// System.out.println("one Selrow ="+selRow+" selpath="+selPath);
} else if(e.getClickCount() == 2) {
// System.out.println("two Selrow ="+selRow+" selpath="+selPath);
}
}
MouseEvent newME = new MouseEvent(m_table.getTree(), e.getID(),
e.getWhen(), e.getModifiers(),
e.getX() - m_table.getCellRect(0, 0, true).x,
e.getY(), e.getClickCount(),
e.isPopupTrigger());
m_table.getTree().dispatchEvent(newME);
}
m_table.addMouseListener(ml);
 
reply
    Bookmark Topic Watch Topic
  • New Topic