Horizontal Dispaly of Images in JList
I had developed an application that displays several images in a JList . The images are displayed vertically. Below is the outline of my code:
JPanel imgpanel1=new JPanel();
JPanel imgpanel2=new JPanel();
ImageIcon img1=new ImageIcon("bookimages/img1.jpg");
ImageIcon img2=new ImageIcon("bookimages/img2.jpg");
JList list=new JList();
list.setCellRenderer(new CustomCellRenderer()); // implements ListCellRenderer
Vector data=new Vector();
Panel mypanel=new Panel();
I am unable to display images horizontally in a JList. I've even used the method
I am new to Swing development, please give me an idea to display images horizontally in a JList. . Please help me guys.
Thanks in advance
I need help from your side. Please give me an alternative to JList where in I can display images horizontally and implement events like Mouse Clicks etc.
There may be more "modern" ways to do this,..
..but not any I now of;
How about a plain JPanel, with a 1 row gridlayout contained in a JScrollPane
with no vertical slidebar.
Then you define a JPanel extension that displays an image and implements
MouseListener (it could also be used in conjuctin with an interface that
defined the callback to the interested parties,... ImageListUser (?)).
For each image you load you create a new instance of this panel and add it
to the "horizontal list" panel. Deletion/insertion of elements is done using the
remove/add & validate methods of the gridpanel.
I've tried out my "theory" above ....
You will have to add code for hiliting the selected image.
Last edited by sjalle; 06-13-2005 at 12:09 PM.
Reason: Replacesd GridLayout w. FlowLayout - left
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center