Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JList of JButtons

Reply
Thread Tools

JList of JButtons

 
 
helpwithjava@googlemail.com
Guest
Posts: n/a
 
      01-07-2009
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"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create JButtons from array Brian Java 4 02-03-2008 01:29 AM
How to replace one JButton by two other JButtons during application run ? Ulf Meinhardt Java 1 11-14-2005 05:23 PM
Events with multiple JPanels and JButtons Oxnard Java 1 11-18-2004 03:06 AM
JButtons in JTables BNM Java 0 01-30-2004 09:42 PM
Making two JButtons "rollover" in sync Brian J. Sayatovic Java 6 08-08-2003 04:42 AM



Advertisments