I am designing a frame for managing batches of items. Each batch contains 10 items and the frame needs to allow them to drag and drop items between batches. There will be a lot of comparing and contrasting so the ability to move the batches around the screen is also required. Initially the frame will load batch 0 (which is always present). The user can then choose from a combobox which other batches they want to view. They can open several at a time and drag and drop between any of them. I've attached a diagram which may help to explain.
What is the best way to do this?
Options I've thought about:
1. JTables. Each batch is a JTable. When I put a JTable on the screen, I can't move it around. Is this possible?
2. Buttons. Each item is abutton enclosed in something like a JPanel. Keeping the buttons aligned maybe an issue.
As you can see I'm hitting issues no matter which way I go so I wondered if there is a better design that would be simpler to implement. All suggestions welcome!
I never seemed to be able to get drab'n'drop to work. Have you considered a combo box, where you can highlight several items? You can use a button to move them. I think you shouldn't worry about alignment until yu have your functionality working.
Alas, it's not a standard control in Swing, but it shouldn't be that hard.
As far as DnD works, you basically have 3 types of events:
1. User presses and holds mouse drag button - usually left-mouse - down, signalling start. You may do a multi-select here by using a modifier (additive) key and/or rubber-banding before formal dragging begins.
2. User moves mouse while continuing to hold the "drag" button. Mouse movement events are reported.
3. User releases mouse drag button. If the mouse pointer is over a drop target, then a "drop" event is signalled.
Loudly announcing something is true and finding out you're wrong makes you feel foolish.
Finding out you're wrong and refusing to admit it makes you LOOK foolish.