Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / November 2003

Tip: Looking for answers? Try searching our database.

grabbing text from non-edit java window

Thread view: 
David Thomas - 29 Oct 2003 23:14 GMT
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 - 03 Nov 2003 12:17 GMT
Is there a Java GUI guru that can tell me whether this is even possible?

> 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()?
Antti S. Brax - 03 Nov 2003 12:37 GMT
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.