views:

36

answers:

2

Hi! I have horizontal JList. When user drags element of this list, there is indicator where draged element would be when it droped. But this indicator is horizontal and appears above or under elements of the list. So how can I change it? I want it to be vertical.

Code creating list:

DefaultListModel model = new DefaultListModel();
// I fill up model with data from DB

list = new JList(model);
list.setName(rs.getString(1));
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

// Next to rows make JList horizontal
list.setLayoutOrientation(JList.VERTICAL_WRAP);
list.setVisibleRowCount(1);

// Add d'n'd
list.setTransferHandler(listHandler);
list.setDragEnabled(true);
list.setDropMode(DropMode.INSERT);
+1  A: 

The horizontal line is the usual graphical element if you want to insert a row into a list (or table). I wouldn't change it and stick to the conventions.

If it's vertical - where exactly do you want it? At the beginning of a list entry? But then it wouldn't be clear, if the dropped element would be inserted before or after the 'marked' row.

Andreas_D
I have horizontal list. It's one row with elements. And I move elements to left or right (not up or down). So vertical line will show where dragged element will be.
Shulya
Thanks for clarification! My experience with JList is rather limited but I fear you need a different container for your data, something that can resize horizontally.
Andreas_D
A: 

I asked this question on forum.sources. ru and got solution that works good.

http://forum.sources.ru/index.php?showtopic=304640

Shulya