0

i am trying to make an App, with javax.accessibility. I have a Frame with a Panel and at this Panel is a Button. I made an accessibility class, included it to the accessibility.properties and made this class implements GUIInitializedListener, MouseListener

So for a Test i did this

public void mouseClicked(MouseEvent e) {
    Point mousePos = EventQueueMonitor.getCurrentMousePosition();
    Accessible accComp = EventQueueMonitor.getAccessibleAt(mousePos);
    String accName = accComp.getAccessibleContext().getAccessibleName();
    System.out.println(accName);
 }

what i wanted is to become Accessible name and show it at Console. but I allways getting mousePos=null. I dont understand what i am doing wrong. Can anybody help me?

Jay Walker
  • 4,654
  • 5
  • 47
  • 53
  • have you tried `e.getPoint();` to get the mouse position? – Jay Walker Jun 12 '13 at 14:32
  • Yes, if i use e.getPoint() then i get a position, but then i become a NULL at Accessible accComp = EventQueueMonitor.getAccessibleAt(mousePos); so i do not understand why. I found an example here: http://www.java2s.com/Code/Java/Swing-JFC/AGUItoshowaccessibleinformationcomingfromthecomponentsinan.htm //Find the component currently under the mouse. Point currentPosition = EventQueueMonitor.getCurrentMousePosition(); Accessible comp = EventQueueMonitor.getAccessibleAt(currentPosition); – Maksim Kerbel Jun 12 '13 at 14:40

1 Answers1

0

So i found an answer.

Component c=(Component)e.getSource();
   Point mousePos =e.getLocationOnScreen();
    Accessible a;
    a = SwingUtilities.getAccessibleAt(c, mousePos);