This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

lost focus

 
Prachi Vallecha
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JLabel is to be given focus and then a JButton is to be pressed to perform some changes on the JLabel...how should i proceed??
should i try giving the focuslost event on the label or the button??
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you have multiple labels, perhaps a better option might be to instead use JRadioButtons (added to a ButtonGroup),
then when the button is clicked, it changes what it has to change of the selected radiobutton.
 
Darryl Burke
Bartender
Posts: 5126
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prachi, is this question going the same way as your last one? That is to say, you ask, others respond, you disappear
http://www.coderanch.com/t/510489/GUI/java/Images-JLabels
 
Prachi Vallecha
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
noo..sorry for the last one...
that was a similar issue..its resolved now...my fault
actually i have to use labels because i am using an image as icon
now i have to change the image at runtime pressing a button...but there are many labels
so focus needs to be given to the label to be changed...but there is no focus for a label right??
so is there some other way to use images other than label-icons???
or some way to give focus to the label?
 
Stephan van Hulst
Bartender
Pie
Posts: 5812
61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Darryl means is that, even if your problem was resolved, the ranchers here appreciate it if you let them know.

Anyway, you can listen for focus on all the labels, and have a variable somewhere in which you save which of the labels was the last one to receive focus. Then when you press the button, receive the appropriate label from the variable.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> actually i have to use labels because i am using an image as icon

several other components also display images
 
Prachi Vallecha
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies...
though i found the solution...i had completely forgotten about the mouseclicked event...
thanks everyone..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic