• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

drag drop images in JList.

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
plz note that I m using jdk1.3.1
thx.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic