Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 848467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:56:47+00:00 2026-05-15T06:56:47+00:00

I am interested in writing a Java program which does the following. Attach to

  • 0

I am interested in writing a Java program which does the following.

  • Attach to a currently running Swing window or applet, running in another JVM
    • Alternatively, load a Java application so as to be able to do the above
  • Read colors from the window
  • Send mouse and keyboard events to the window

I am hoping to make some sort of testing and automation tool that interacts with GUIs directly.

I am looking for some advice on how to accomplish any and all of the steps above. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T06:56:48+00:00Added an answer on May 15, 2026 at 6:56 am

    It’s not going to be so easy to capture the output of a another process – it will be simplest if your test app launches directly the swing app, in the same java VM.

    You can then call paint(Graphics g) on the JFrame, passing the component an off screen graphics (BufferedImage – details here.) You can send input events to the AWT event queue via EventQueue.postEvent(AWTEvent) – this can be used to simulate AWT input.

    However, have you surveyed the existing test frameworks out there? FEST has a test framework specifically for manipulating and verifying UI. There is also abbot, older by favored by some. There are also test frameworks that concentrate on function and state rather than screen grabs and input events. These are not better/worse, but complementary.
    State UI testing includes SwingUnit, and UISpec4J.

    There are a lot of good frameworks out there, so it might pay to do a little research before building yet another one!

    EDIT:
    To launch an application, instead of running

    java -cp ... a.b.c.AppToTest
    

    You run

    java -cp ... TestWrapper AppToTest
    

    and implement TestWrapper like this

    public class TestWrapper {
    /* args[0] - class to launch. Remainder of args passed to launched app.*/
       public static void main(String[] args) throws Exception
       {
          Class app = Class.forName(args[0]);
          Method main = app.getDeclaredMethod("main", new Class[] { (new String[1]).getClass()});
          String[] appArgs = new String[args.length-1];
          System.arraycopy(args, 1, appArgs, 0, appArgs.length);
          main.invoke(null, appArgs);
          // now you have just launched another application inside the same VM
       }
    

    }

    Once you have launched the app, you can wait for the app to start, and poll
    Window.getOwnerlessWindows to find any top-level windows the app creates.

    A more direct approach is to install your own RepainManager – you canjust delegate to the existing one. This is invoked for all window drawing operations, an so you get right in the heart of the window hierarchy,

    You can also register to listen to all events on the AWT EventQueue. That will also give you an inside view on what is happening in the app, and from that you can determine which windows are created, in focus etc..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Found it. Thanks! DropDownList ddlFeedback = (DropDownList)sender; GridDataItem item =… May 16, 2026 at 5:49 pm
  • Editorial Team
    Editorial Team added an answer in your model you cant just say validate :all because… May 16, 2026 at 5:49 pm
  • Editorial Team
    Editorial Team added an answer Recursively go thru all files in each directory. Create a… May 16, 2026 at 5:49 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm writing a program in java (already wrote a version in C too). I
I am interested in creating a routine that would query the currently running cache
I recently read that Java now sports initialisation blocks like the following: class C
I'm interested in writing javascript that will programmatically perform a screen capture of what
I was interested in writing some home-brew analytic solutions and all the click tracking
Let me first say that I have quite a lot of Java experience, but
Is it possible to enter an infinite loop at compile time? My program seems
I've now written a few applications using scala actors and I'm interested in how
I am teaching Python to undergraduate math majors. I am interested in the optimal
Well, I guess it's clear the direction from which I am trying to reason

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.