Skip to main content

JXTreeTable and Tooltips

1 reply [Last post]
oneandonlyluppy
Offline
Joined: 2012-10-01
Points: 0

Hello

I have what I think is a small bug in JXTreeTable.
Using the attached self contained runnable example and SwingX 1.6.4 do the following

1. Hold mouse over any cell and the tooltip is displayed
2. Click the tree icon so the tree collapses and then click again so the tree expands again.
3. Now without leaving the bounds of the table (not moving the mouse out of the rows) move the mouse to any cell the tooltip no longer gets displayed
4. Move the mouse out of the table anywhere on the screen
5. Move mouse back over the table, tooltips are now displayed again

I stress that this only happens when after the tree expandsion/collapse click the mouse must not move off any row otherwise the tooltips work again correctly

I was hoping someone out there might have a temporary solution and also whether they indeed experience the same problem, if so I can raise a bug

import org.jdesktop.swingx.JXFrame;
import org.jdesktop.swingx.JXTreeTable;
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
import org.jdesktop.swingx.treetable.DefaultTreeTableModel;
import org.jdesktop.swingx.treetable.TreeTableModel;
import org.jdesktop.swingx.treetable.TreeTableNode;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;

public class TreeTableToolTipTest extends JXFrame
{
    public TreeTableToolTipTest()
    {
        DefaultMutableTreeTableNode root = new DefaultMutableTreeTableNode();
        root.add(new DefaultMutableTreeTableNode());
        root.add(new DefaultMutableTreeTableNode());
        root.add(new DefaultMutableTreeTableNode());
        root.add(new DefaultMutableTreeTableNode());
        root.add(new DefaultMutableTreeTableNode());
        root.add(new DefaultMutableTreeTableNode());
        root.add(new DefaultMutableTreeTableNode());
        root.add(new DefaultMutableTreeTableNode());
        root.add(new DefaultMutableTreeTableNode());

        final JXTreeTable table = new MyTreeTable(new MyTreeTableModel(root));
        table.setFillsViewportHeight(false);

        Container contentPane = getContentPane();
        contentPane.setLayout(new BorderLayout());
        contentPane.add(new JScrollPane(table), BorderLayout.CENTER);

        table.setRootVisible(true);
        table.expandAll();

        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setSize(800, 500);
        setVisible(true);
    }

    public static void main(String[] args)
    {
        new TreeTableToolTipTest();
    }

    private class MyTreeTable extends JXTreeTable
    {
        private MyTreeTable(TreeTableModel treeModel)
        {
            super(treeModel);
        }

        public String getToolTipText(MouseEvent event)
        {
            return "Tooltip";
        }
    }

    private class MyTreeTableModel extends DefaultTreeTableModel
    {
        private MyTreeTableModel(TreeTableNode root)
        {
            super(root);
        }

        public Object getValueAt(Object node, int column)
        {
            return "Hello " + column;
        }

        public int getColumnCount()
        {
            return 4;
        }
    }
}

Thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kleopatra
Offline
Joined: 2003-06-11
Points: 0

fixed (cough ...) by hacking TreeTableHackerExt4 (yeah, our hacks have numbers ;-)

Thanks for filing the issue, please let me know how it works (or breaks ..)

Cheers
Jeanette