grabbing text from non-edit java window  
Author Message
David Thomas





PostPosted: 2003-10-30 6:15:00 Top

java-programmer, grabbing text from non-edit java window How do I get the text (in a java program) from a java window that is not an
edit window (ie, cannot hilight the text with a mouse)? ie, is there
something similar to in functionality to Windows API GetWindowText()?


 
David Thomas





PostPosted: 2003-11-3 20:18:00 Top

java-programmer >> grabbing text from non-edit java window Is there a Java GUI guru that can tell me whether this is even possible?

"David Thomas" <email***@***.com> wrote in message
news:bZWnb.7493$email***@***.com...
> How do I get the text (in a java program) from a java window that is not
an
> edit window (ie, cannot hilight the text with a mouse)? ie, is there
> something similar to in functionality to Windows API GetWindowText()?
>
>


 
asb





PostPosted: 2003-11-3 20:37:00 Top

java-programmer >> grabbing text from non-edit java window email***@***.com wrote in comp.lang.java.gui:
> Is there a Java GUI guru that can tell me whether this is even possible?

Well, I am not a Java GUI guru but I can read the API documents.
The following stuff might help you get along.

Do not top post. Put your text under the quoted text like
I do here and remove irrelevant stuff from the quoted text.

> "David Thomas" <email***@***.com> wrote in message
> news:bZWnb.7493$email***@***.com...
>> How do I get the text (in a java program) from a java window that is not
> an
>> edit window (ie, cannot hilight the text with a mouse)? ie, is there
>> something similar to in functionality to Windows API GetWindowText()?

Be specific. There is no such thing as an "edit window" in
Java. There are some components that can contain editable
text and some components that can contain uneditable text.
Some components do not contain any text and others contain
text in complex data structures.

Do you want to be able to copy-paste text with the mouse from
uneditable components or get the text programmatically?

What the heck does GetWindowText() do in "Windows API?" We're
Java programmers. We don't know about Windows APIs.

Are using Swing or AWT.


If you want _all_ text from the components in a window then
you coult do the following: java.awt.Container has a
getComponents() method that returns an array of components.
From those components you can do type checking to see if the
component is one of the text components or a container. For
containers do a recursive call and for text components call
getText(). But that is pretty dumb, ugly and propably quite
unusable.

--
Antti S. Brax - asb(at)iki.fi Rullalautailu pitæ»— lapset poissa ladulta
http://www.iki.fi/asb/ http://www.cs.helsinki.fi/u/abrax/hlb/
 
 
David Thomas





PostPosted: 2003-11-4 23:51:00 Top

java-programmer >> grabbing text from non-edit java window > > "David Thomas" <email***@***.com> wrote in message
> > news:bZWnb.7493$email***@***.com...
> >> How do I get the text (in a java program) from a java window that is
not
> > an
> >> edit window (ie, cannot hilight the text with a mouse)? ie, is there
> >> something similar to in functionality to Windows API GetWindowText()?
>
> Be specific. There is no such thing as an "edit window" in
> Java. There are some components that can contain editable
> text and some components that can contain uneditable text.
> Some components do not contain any text and others contain
> text in complex data structures.



> Do you want to be able to copy-paste text with the mouse from
> uneditable components or get the text programmatically?

Sorry, I thought that even not knowing Windows, the reference to an API with
a name that gives an obvious description, made it clear that I want to do it
programmatically. I'm not trying to incite a holy war, just providing an
example of what I wish to do.

> What the heck does GetWindowText() do in "Windows API?" We're
> Java programmers. We don't know about Windows APIs.

Some programmers have a little broader experience then a single development
environment. I'm sure they don't appreciate being so narrowly categorized.

> Are using Swing or AWT.

You are assuming I wrote the code for the window I wish to grab text from.
I didn't and I don't know what was used. I am only interested in grabbing
'existing' text from a java window for which I do not have source code for;
and doing it 'programmitically'. Though I can read java, I'm not a java
programmer and don't have the resources to research this. I was hoping that
someone could whip out an answer without much effort. (Kind of like an
experienced Windows programmer would have pointed me to using
GetWindowText(), without concern whether I normally do or don't work in
Windows.)

>
> If you want _all_ text from the components in a window then
> you coult do the following: java.awt.Container has a
> getComponents() method that returns an array of components.
> From those components you can do type checking to see if the
> component is one of the text components or a container. For
> containers do a recursive call and for text components call
> getText(). But that is pretty dumb, ugly and propably quite
> unusable.
>

Now this is useful, thank you for taking time to point me in a useful
direction.