6 Replies Latest reply on Apr 25, 2011 12:15 PM by 857111

    Need help with EventQueueMonitor

      I have a task to write an application on Java2 SE, which will manage the Accessible object of another Java window.
      To do this, I put the Java Accessible Bridge version 2.0. JVM 1.6.0_24
      In combination with Java Accessible Bridge is a few examples and they work fine. In particular Monkey -
      gets the accessible object tree of all open java-windows, whether it's an applet, frame, or dialog.
      To get top-level Windows I use getTopLevelWindows method of EventQueueMonitor class.
      The problem is that this method only returns the current application window. If the application is console type,_
      the method returns an empty array._ While looking into the source of Monkey application, I have not seen any shaman,
      after which this method worked fine. In google there are a lot of examples of its use, but they are similar and
      do not lead to the desired result. And on this issue, nothing found.

      I'm a newbie in Java and perhaps missed something.
      In what may be the problem?

      package topwindows;

      import com.sun.java.accessibility.util.EventQueueMonitor;
      import java.awt.Window;

      public class Main {

      public static void main(String[] args) {
      Window[] wnd = EventQueueMonitor.getTopLevelWindows();     // returns zero-length array
      for (int i= 0; i < wnd.length; i++) {
      System.out.println(i + ") " + wnd.toString());
        • 1. Re: Need help with EventQueueMonitor
          Window[] w = Window.getOwnerlessWindows();
          • 2. Re: Need help with EventQueueMonitor
            Console applications do not have Java owned windows. Nor is there anything for Java to support with regard to accessibility for console programs. Your screen reader or other program needs to work with the console (or shell) program which is typically not a Java program (for example cmd.exe on Windows).
            • 3. Re: Need help with EventQueueMonitor
              mKorbel wrote:
              Window[] w = Window.getOwnerlessWindows();
              It did not help. I tried every function of that list, with and without creating a window before calls them:
              Frame[]  frames = Frame.getFrames();
              System.out.println("frames.length = " + frames.length);
              Window[] OwnerlessWndsF = Frame.getOwnerlessWindows();
              System.out.println("OwnerlessWndsF.length = " + OwnerlessWndsF.length);
              Window[] WndsF = Frame.getWindows();
              System.out.println("WndsF.length = " + WndsF.length);
              Window[] OwnerlessWndsD = Dialog.getOwnerlessWindows();
              System.out.println("OwnerlessWndsD.length = " + OwnerlessWndsD.length);
              Window[] WndsD = Dialog.getWindows();
              System.out.println("WndsD.length = " + WndsD.length);
              Window[] OwnerlessWndsW = Window.getOwnerlessWindows();
              System.out.println("OwnerlessWndsW.length = " + OwnerlessWndsW.length);
              Window[] WndsW = Window.getWindows();
              System.out.println("WndsW.length = " + WndsW.length);
              Output without creating window, but with running java-applet, that can be detected with Monkey:
              frames.length = 0
              OwnerlessWndsF.length = 0
              WndsF.length = 0
              OwnerlessWndsD.length = 0
              WndsD.length = 0
              OwnerlessWndsW.length = 0
              WndsW.length = 0
              And output with creating window and running java-applet:
              frames.length = 0
              OwnerlessWndsF.length = 1
              WndsF.length = 1
              OwnerlessWndsD.length = 1
              WndsD.length = 1
              OwnerlessWndsW.length = 1
              WndsW.length = 1
              Only my window have been detected...

              Edited by: user13805108 on 22.04.2011 3:34
              • 4. Re: Need help with EventQueueMonitor
                I tried to call this functions in Java applications with dialog interface. They work there similar like in console that creates window for example like that
                Window W = new Window(null);
                W.setSize(new Dimension(100, 200));
                But I need to get the list of all top-level windows, that belong to current JVM.
                This what I read in specification of getTopLevelWindows() function:
                public static java.awt.Window[] getTopLevelWindows()
                    Return the list of top level Windows in use in the Java Virtual Machine.
                Why it does not work just this way?

                Edited by: user13805108 on 22.04.2011 5:53
                • 5. Re: Need help with EventQueueMonitor
                  Didn't you read my reply? A console program doesn't have a window (almost by definition). A console/shell which can start console programs could be run in a window but this is not a window that create by the console program.

                  • 6. Re: Need help with EventQueueMonitor
                    I wrote that I tried to call this functions in Java applications with dialog interface. I mean - "Java Desktop Application" created in Netbeans. As far as I know that is not a console application.
                    If I'm wrong, then tell me please how to create an application in which EventQueueMonitor.getTopLevetWindows (or an analog of the function) will work properly