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

VirtualMachine.attach and LoadAgent under JavaFX?

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We are working on a kind of spy++ for java FX application (snoop for javafx)

- Is there a way to "inject" my own code inside the java fx application?
- Is there any equivalent to VirtualMachine.attach and LoadAgent for JavaFX ?
- Is there any open source automated testing tool compatible with JavaFX ?

Thanks!

Michel
 
Michel Legris
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can Load my agent class into a JavaFX Process. (There was a problem with my manifest and the library must be build for javafx ...my bad)

BUT :
- How do I access to the stage top level object from my JavaFX agent library? Is there a method to get a reference to the stage or the top level UI parent node ??
Is there any javafx equivalent to WPF VisualTreeHelper.GetRoot() ?? How can I get access to an instance of the top level UI node of a javafx application

thanks,

Michel
 
Michel Legris
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm still trying to figure out how to use my agent in a javafx context in order to get a reference to the UI....

I just need to get access to the root top level UI element of the application...Nobody can help on this?
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One way is to pass the Stage obtained in the start method. Or another way is to create a static variable in the class which contains your start() method. So in the start() method you can initialize this field with the stage you get. So to access the Stage in different classes would be possible.
 
Michel Legris
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no start method in an Agent class...

There is no way to create or use a static variable or modify the application since it's NOT my own application (the one with the start() method) and it's only at run-time (no code can be modified in the application)

I'm using an agent because "injecting" some code in the application process...The problem is that in a JavaFX context you CANT talk with the UI at all because you dont have an access to the stage object
 
Mohamed Sanaulla
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

There is no start method in an Agent class...



I meant to say: start method of the JavaFX application.

I'm using an agent because "injecting" some code in the application process...The problem is that in a JavaFX context you CANT talk with the UI at all because you dont have an access to the stage object



You can capture the Stage object in the JavaFX application itself right? That's what I meant by saying keeping a class level variable in the JavaFX class and then initialise with the required Stage object. You get an access to the Stage object in the start() method of your JavaFX application. Something like:



I understand that you want the Agent to interact with the JavaFX application and for that you need an access to the Stage object to directly manipulate the data/ui of the JavaFX application. Correct me if my understanding is wrong.

Now if you want to monitor the system performance information, assuming the agent which captures the data is a separate process than the application which would display the data- Is that what you are trying to achieve? Or is it that you want to monitor some Java process?
 
Michel Legris
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I DONT have any acces to the javaFX application

I'm using an agent to inject my code into the JavaFX application (not my application, code cannot be modified so start method is unavailable)

It's not for performance monitoring, Im working on a kind of spy++/snoop for java so i need to get the UI structure, component size and position to "highlight" them from another process (My agent) I also need to get component properties

For doing all this I need a top level object to parse the entire UI structure and get what I want...

The javafx applications cannot be modified since they are not my own application (any javafx application)
 
Mohamed Sanaulla
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah I see, I got this now. You are trying to analyse the UI structure of any JavaFX application and for that you need to access the root Stage. Even I am not aware of how this can be done in JavaFX or Swing for that matter.
 
Michel Legris
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exactly!!

for swing/AWT i'm simply using an agent with window.GetWindows(), then loop though child components.

In JavaFX there is no way to access the root stage (from my agent or external class)
 
Michel Legris
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to use a classTransformer in my agent and somehow get access to the Stage object? It it possible to "hook" the start method with ASM bytecode manupulation in order to get the top level UI element? Is this make any sense?

Thanks...
 
Michel Legris
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It work!!! thanks for trying to help
 
Mohamed Sanaulla
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michel Legris wrote:It work!!! thanks for trying to help


How did you fix it? This would be helpful for people reading this thread sometime in future.
 
Michel Legris
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The same method used by the jemmy project from http://java.net/projects/jemmy

Just check how they manage to get access to the top level ROOT element in their AgentMain() implementation.
 
I'm all tasted up for a BLT! This tiny ad wants a monte cristo!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic