JTree: Want to use single click to select any component in node
posted 5 years ago
I am trying to select ANY component in a JTree with a single click always.
Currently, I can only do this on first time JTree comes up, or if its the first (leftmost)
component in a node.
The test program below has 2 nodes in a JTree, each with a JTextField in the
leftmost position & a JCheckBox in the rightmost position. So the first time I
can select a JCheckBox with a single click, but then I need to use 2 clicks.
I tried putting a mouse listener on the JCheckBox & then in the mouse listener's
mouseEntered() method, doing a requestFocusInWindow() on that JCheckBox.
According to print statements, mouseEntered() was never called.
The mousePressed() method was called per prints, but a requestFocusInWindow()
did not work there (still took 2 clicks). I also tried in mousePressed() method: