Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I need help to display images on the panel by clicking

 
Krupa Patel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my FlowerImage class:


This is my FlowerPanel class:


And this is my FlowerApp:
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Krupa Patel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it.
Thank you so much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic