H
helpwithjava
Hello,
I have a JList that consists of JButtons. I have overriden the cell
renderer to return a JButton instead of a JLabel and it all looks
good. The next part of the problem was to allow the user to drag a
leaf item from a tree into the list containing JButtons. Upon the drop
a new button will be created with the tree node's name.
My problem is that when I drag over the button list the mouse events
are processed by each of the buttons that the mouse passes over. If
the mouse is dragging over the list then I do not what the buttons in
the list to activate. How can I stop these events from firing?
I have investigated enabling and disabling the buttons in the canImport
() and exportDone() methods in the TransferHandler but this does not
work.
My current fix is to put the list into a JPanel and add the drop
listener to the JPanel and not the list. The only problem with this is
that I cannot work out how to drop the new button into the location
specified by the user. I also am not sure if this is a bit of a dirty
work-around. Your opinions would be appreciated.
How can I drag and drop into a list consiting of JButtons without the
performing the existing JButton actions?
I can post code but at the moment I think this is quite a good problem
so any advice/opinion would be appreicated.
Thanks for you "helpwithjava"
I have a JList that consists of JButtons. I have overriden the cell
renderer to return a JButton instead of a JLabel and it all looks
good. The next part of the problem was to allow the user to drag a
leaf item from a tree into the list containing JButtons. Upon the drop
a new button will be created with the tree node's name.
My problem is that when I drag over the button list the mouse events
are processed by each of the buttons that the mouse passes over. If
the mouse is dragging over the list then I do not what the buttons in
the list to activate. How can I stop these events from firing?
I have investigated enabling and disabling the buttons in the canImport
() and exportDone() methods in the TransferHandler but this does not
work.
My current fix is to put the list into a JPanel and add the drop
listener to the JPanel and not the list. The only problem with this is
that I cannot work out how to drop the new button into the location
specified by the user. I also am not sure if this is a bit of a dirty
work-around. Your opinions would be appreciated.
How can I drag and drop into a list consiting of JButtons without the
performing the existing JButton actions?
I can post code but at the moment I think this is quite a good problem
so any advice/opinion would be appreicated.
Thanks for you "helpwithjava"