aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes I need help to display images on the panel by clicking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "I need help to display images on the panel by clicking" Watch "I need help to display images on the panel by clicking" New topic
Author

I need help to display images on the panel by clicking

Krupa Patel
Greenhorn

Joined: Apr 18, 2012
Posts: 10
This is my FlowerImage class:


This is my FlowerPanel class:


And this is my FlowerApp:
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4658
    
    5

Hello Krupa, and welcome to the Ranch! For posting code here, please UseCodeTags <-- link so that your code retains its formatting. Since you're new here, I've added them for you. It would also encourage more members to read your code if you format it in a consistent way: use spaces (2 to 4) for indents and don't mix tabs and spaces in the same block of code; don't post extraneous blank lines, and adopt a consistent bracing style.

Do you have a question, or a problem we can help you with? I do see that you are constructing an ImageIcon only for the sake of retrieving its Image; why don't you load the Image directly?

edit You also have a constructor call within the same constructor, which is going to lead to infinite recursion and a stack overflow. If that's what's troubling you you should say so.


luck, db
There are no new questions, but there may be new answers.
Krupa Patel
Greenhorn

Joined: Apr 18, 2012
Posts: 10
My question is: Each time you mouse click on the screen it should add a daffodil to the field.
Don't I have to create an ImageIcon object then call getImage() to retrieve the image object!
I don't know how to put it in the code.

Please help me
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
it's almost all there, just not in the right spots.

see if you can follow the changes (note the couple of comments)

Krupa Patel
Greenhorn

Joined: Apr 18, 2012
Posts: 10
I got it.
Thank you so much.
 
jQuery in Action, 2nd edition
 
subject: I need help to display images on the panel by clicking