• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Accessing JFrame contents

 
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to access the contents of a JFrame on a GUI interface but I keep getting to the contents of the overall frame (which I believe is a JInternalFrame). I don't have access to the software that creates these components.
How can I access these components sitting on the JFrame? The text is there plain to see on the screen and the frame is in focus because pressing 'ESC' removes it. I have been using all sorts of combinations of getting ContentPanes, DesktopPane etc. but I still end up with the overall JInternalFrame.
I'm writing a tool using IBM's Self-Voicing Kit to read the contents of different components on a GUI. I need to 'see' the contents of every component on the screen but I cannot alter the code that compiles the GUI. So far I've had good success on getting all the contents of JDialogs and JInternalFrames. But these JFrames seem to be invisible.
I'm sure there must be some simple formula to get to the contents but I'm missing it.
Any help much appreciated.
Paul
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul,

Here's some test code to get the contents of a JFrame... does this help?



-Nate
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Nate. This looks very promising. I've placed this method into my code and it gets triggered 476 times for one of these particular JFrames that I'm looking at. Some of these have to represent the components that I see on the screen - even though the window looks quite simple and uncluttered.
I'm hopeful.
Paul
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As mentioned in my last email I get a huge number of components when I run this method. However, none of them seem to coincide with the in-focus window I see on my screen. I know it's an instance of JFrame because that check is what triggers my method in the first place. But the JFrame that I get is the overall window for the entire screen.
Amongst the 400+ components I search for words that are displayed on my window to see if I'm getting to them with this method. For example, the word 'Flight' is displayed so I'm hoping to see a component which has a text field equal to 'Flight'. Perhaps I should be searching some other way?
Paul
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What sort of component has the word "flight" on it? A textfield? Label? Combobox? If it is a custom component, you may not be able to get the text because it may be hardcoded in the paint method... you can't get at text "paint"ed on the component...

-Nate
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I thought of that problem and I'm hoping that's not the case. I cannot determine what type of component the word 'flight' is on but it's there sitting on my screen while 476 components are there.
I'm checking further into some of them because it would at least be a start if I knew which components hold the information, even if it's not accessible. I'm trying to alter certain field values and see if anything changes on the screen. So far I've only discovered which components are not the component I want.
Thanks for your help so far.
Paul
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The component I'm looking for has focus because when you press 'ESC' it goes away. Is there a way to find out what's in focus or what happens after the 'ESC' is pressed? I've executed the hasFocus() method on all 477 components and they are all false, yet there's a little window sitting on my screen waiting for me to press something? I still cannot see this component with any background code and I don't have access to the code that builds it.
Paul
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try something like this? ( maybe.... )

 
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic