Point p = dialog.getButton().getLocationOnScreen();
SwingUtilities.convertPointFromScreen(p, dialog);
EventQueue systemEventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
MouseEvent theEvent = new MouseEvent(dialog, MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), modifiers, p.x, p.y, 1,
false);
systemEventQueue.postEvent(theEvent);
AWTSync.sync();
}
private void type(int keyCode, int modifiers) {
KeyEvent event = new KeyEvent(dialog, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), modifiers, keyCode, (char) 0);