• Post Reply Bookmark Topic Watch Topic
  • New Topic

drag drop images in JList.

 
shelly kalra
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a JList that displays images.
I want drag drop functinality to be added to it, such that i can drag an image from one location in the list and drop it to another location, in the same list only.Please let me know the rite approach to do the same.
List with images -
public class JListWithImages extends JList {
/** Constructs a List with only images.
*
*/
public JListWithImages() {
setCellRenderer(new CustomCellRenderer());
}
class CustomCellRenderer implements ListCellRenderer {
public Component getListCellRendererComponent (
JList list, Object value, int index,
boolean isSelected, boolean cellHasFocus) {
Component component = (Component)value;
component.setBackground(isSelected ? Color.black : Color.white);
component.setForeground(isSelected ? Color.white : Color.black);
return component;
}
}

}
how i m defining my list
JListWithImages imageList;
how i m adding images to list -
imageList.setListData(imagesVector);
where imagesVector has panels added on it like this -
//getIconImage() of PageImage returns an Image.
JPanel jImagesPane1 = new JPanel();
jImagesPane1.add(
new JLabel(
new ImageIcon(
((PageImage) m_tempPageImageList.get(i))
.getIconImage()
)
)
);
imagesVector.add(jImagesPane1);
Thanxs,
Shelly
 
shelly kalra
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
plz note that I m using jdk1.3.1
thx.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!