943,774 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1850
  • Java RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Aug 12th, 2009
0

Re: JLabel image isn't updating when JComboBox selection changes.

I assume you have no messages like this:
nope no errors it just doesnt change
Reputation Points: 10
Solved Threads: 0
Light Poster
gotm is offline Offline
33 posts
since May 2008
Aug 12th, 2009
0

Re: JLabel image isn't updating when JComboBox selection changes.

When I first ran your program, before I realized what I had to do, I stuck this line at the top of actionPerformed:

Java Syntax (Toggle Plain Text)
  1. System.out.println ("Inside actionPerformed");

so it would display every time I selected from the Drop-Down. Have you done this, and does it display?
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is offline Offline
5,374 posts
since Jan 2008
Aug 12th, 2009
0

Re: JLabel image isn't updating when JComboBox selection changes.

Okay, here's what I've found.

1) DON'T USE PACK()!
JFrame.pack() is good some times, but NOT here. Use JFrame.setSize(int, int) (I set it to 250 x 135, and it looks great). using pack here makes it look squished (which it is!).

2) Set the default recipe
In your constructor (after creating the test recipe, and adding it to the JComboBox), set the selected index/item to 0 or test respectively. (that will ensure that the ratings show up at creation)

3) Don't use 2 JLabels for the rating!
Find a way to use one, and show the word "Rating: ", and the stars, or create a class that can display them horizontaly:
java Syntax (Toggle Plain Text)
  1. class RatingLabel extends JPanel{
  2. ImageIcon stars;
  3.  
  4. RatingLabel(int stars){
  5. switch(stars){
  6. // Go through cases to load images...
  7. }
  8. this.add(new JLabel("Rating"));
  9. this.add(nww JLabel(stars));
  10. }
  11. public void setRating(int stars){
  12. //same as switch above
  13. }
  14. // Other methods to add/remove stars, ect
  15. }

I'm pretty sure that should get things working. =)
Reputation Points: 41
Solved Threads: 13
Posting Whiz in Training
llemes4011 is offline Offline
224 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: What is the easiest and most efficient vision library...
Next Thread in Java Forum Timeline: Java swing gui





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC