• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

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

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic