JList of JButtons

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" :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

problems with editable JList 8
jlist 2
Generic JList and ListCellRenderer? 3
Create JButtons from array 4
JList index 14
JList doesn't support MVC!! 1
JButtons in JTables 0
What's wrong with JList in JScrollPanel 2

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top