• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Problem with select(int start, int end) method of TextArea

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ranchers,

I am stuck in a problem while using the select method of TextArea class. Here is my code:





The select(int , int ) method inside the MyText() constructor is perfectly working but when i am using the same inside the find() method it is not selecting the text............

Anyone please help me on this.
[ September 14, 2008: Message edited by: Gaurav Chauhan ]
 
Gaurav Chauhan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bounce............

No Replies yet
 
Marshal
Posts: 73981
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gaurav Chauhan:
Bounce............

No Replies yet

Please look at this FAQ.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> when i am using the same inside the find() method it is not selecting the text............

actually, it is.

you don't see it because you have transfered focus from the textArea to the button
(just by clicking the button)

run the code again.
after clicking the button, press the tab key and the selection should be highlighted.

simple fix is to add this line
bFind.setFocusable(false);

(and there is a way you can have the selection highlighted without the need to have focus)
 
Gaurav Chauhan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my original code. I am supposed to build a find and replace box. This is what i did.....



Kindly run the code and you will find the issue that i am facing..........
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you're not trying too hard.

the first example I explained how the focus was the issue,
between the textArea and the button.

now you post code that contains a couple of textfields, and presumably,
your problem happens when you follow these steps
type something into the textArea
type something into the find textfield
(possibly) type something into the replace textfield
click the find button

now the textArea doesn't show the selection - is that the problem?

if so, where is the focus now?
not the button - that was a fix for the first posted code.
could the focus be with the last textfield that something was typed into?

anyway, look up the apidocs for
textArea.requestFocusInWindow();
 
Gaurav Chauhan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot mate.

I understood it. TextArea lost it's focus so the highligted text was not shown.

I used the requestFocusInWindow() as per your suggestion and it's working :-)
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic