Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

To get the focus around the text in a label like in a button  RSS feed

 
Meghna ks
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
How do I get a rectangular focus around the text of a label,(when you click on a swing button, a rectangle appears around the text of the button to show that it has recieved focus, the respective properties for the button are : setRequestFocusEnabled(boolean) & setFocusPainted(boolean))
But, the label does'nt have the setFocusPaint property which draws the rect enclosing the text. How can this be done ?!!
I've added a mouseclick event to the label & am trying to draw a rectangle around the text, but since the text position depends on the alignment position of the text, I've stopped at this point.One more question is how do I get the X & Y position of the text within a label or a button depending on the alignment property?!!
Thanks
Meghna
 
Amit Agarwal
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Meghna
why do you want to do something using a label when you have a button available for it? labels are not focussable components so when they cannot receive focus they cannot have a setFocusPainted() etc. please specify what actually u intend to do.
Amit
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!