• Post Reply Bookmark Topic Watch Topic
  • New Topic

JPEG Not Showing  RSS feed

 
henri henri
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.pollscanada.com/screenshot.html
Please follow the above link for visual guide.

My class gets a JPEG amongst other things that all come together seamlessly when the class is tested via a call to main, such as in the first snippet of code below. The JPEG shows up in the JFrame in this instance as you can see in the visual guide. However when the class is instantiated with the constructor method call via an EventListener in the main class, the JPEG does not show up. It does however show up after the second time an item is clicked. EventListener is triggered when one clicks on a String selection in a JList.


---------------------------------------------------------------------------
Event Listener code below. The line in question is the last one before the closing braces.

the actor_selection variable is a String in a JList with the names of film actors. Thank you so much for any help. I am writing this program for a handicapped person and I am therefore striving to make it as intuitively easy as possible. I am not a programmer by trade, merely a hobbyist.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it a large JPEG? It's possible that there is an issue with loading time.
 
henri henri
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JPEG is only 25 k. You can see the dimensions of the JFrame are rather small too and the JPEG only takes about one third of the space within the JFrame.
 
Paul Clapham
Sheriff
Posts: 22818
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you click on an entry in the list, your valueChanged() method is called twice. Once to tell you that the previously-selected entry was deselected and again to tell you about the newly-selected entry. But I think your line of codecauses only the first of those two events to be handled. Try this instead:
 
henri henri
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the name of an actor is selected in the JList, the JFrame shows up with everything you see in the visual guide, except the JPEG. If I click a second time on the same actor name in the JList, a new JFrame appears again, only this time, with the related JPEG in place.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!