Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

show multiple image Using Jlist

 
ashish donvir
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could any one suggest me the way to show multiple image Using Jlist for example i would like to show thumbnail view of image in a jtabbedpane and on selecting two image they both should open in a other jtabbedoane
 
Maneesh Godbole
Saloon Keeper
Posts: 11061
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

We have a forum dedicated for Swing questions. I will move this topic over there for you.

You can use a custom renderer for your JList which could be a JPanel instance and then add the image(s) to the panel.
JLabel with an icon would be the easiest way to go.

I do not understand the relation between the JList and JTabbedPane. Could you please rephrase what you are trying to do here?
 
ashish donvir
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:Welcome to the Ranch.

We have a forum dedicated for Swing questions. I will move this topic over there for you.

You can use a custom renderer for your JList which could be a JPanel instance and then add the image(s) to the panel.
JLabel with an icon would be the easiest way to go.

I do not understand the relation between the JList and JTabbedPane. Could you please rephrase what you are trying to do here?



i simply need to show multiple images (like thumbnail view of windows) in java and want some event to occur on selecting the image....
 
Maneesh Godbole
Saloon Keeper
Posts: 11061
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Recommended reading http://docs.oracle.com/javase/tutorial/uiswing/components/list.html
You can show images as list items (using the renderer I mentioned before) and you can also listen to list selection events
 
ashish donvir
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:Recommended reading http://docs.oracle.com/javase/tutorial/uiswing/components/list.html
You can show images as list items (using the renderer I mentioned before) and you can also listen to list selection events


well as i am new to java development would you please come with some code and show me how to usw jlist to show image?
thanks
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you expect this
"...would you please come with some code and show me..."

then this
"well as i am new to java development"

will never change.
 
Paul Clapham
Sheriff
Posts: 21111
32
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Maneesh provided a link to a tutorial. So instead of reading it, you asked for code instead. How do I know you didn't read it? Because the tutorial includes code which provides examples which would be helpful to you.

Since you're new to Java, you should know that the Oracle tutorials (like the one Maneesh linked to) are the best way to learn about particular topics in Java. So if you want to learn about JList, read the JList tutorial. Download the example code and run it, and then fiddle around with the code. Change it to do something a little different, and then change it to do something a lot different. That's the way to learn Java.
 
ashish donvir
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael Dunn wrote:if you expect this
"...would you please come with some code and show me..."

then this
"well as i am new to java development"

will never change.


Here is my code what i tried. as you can see i had drawn the images in tab name set image. so instead of drawing i actually need to load all images and then allow user to select the image and it should open in other name compare image. suggest me what change i should do in my code to fulfill my requirements? how to generate thumbnail view and allow user to select image

 
Pierre Sugar
Ranch Hand
Posts: 62
Java Ruby Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use a JList as suggest before and use your own list cell renderer for your images. Your renderer could look like this, assuming that your values are ImageIcons.
 
Darryl Burke
Bartender
Posts: 5131
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pierre Sugar wrote:Your renderer could look like this, assuming that your values are ImageIcons.


And the text displayed alongside the Icon would look ... interesting
 
Pierre Sugar
Ranch Hand
Posts: 62
Java Ruby Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point. Just wanted to see if anybody recognises the flaw This probably would help:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic