dthomas@cogitoinc.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.
>> 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.

Signature
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 - 04 Nov 2003 15:50 GMT
> >> How do I get the text (in a java program) from a java window that is not
> > an
[quoted text clipped - 6 lines]
> 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
[quoted text clipped - 4 lines]
> 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.