@RunsInEDT
private boolean waitForComponentToBeReady(@Nonnull Component c, long timeout) {
if (isReadyForInput(c)) {
return true;
}
TimeoutWatch watch = startWatchWithTimeoutOf(timeout);
while (!isReadyForInput(c)) {
if (c instanceof JPopupMenu) {
// wiggle the mouse over the parent menu item to ensure the sub-menu shows
Pair<Component, Point> invokerAndCenterOfInvoker = invokerAndCenterOfInvoker((JPopupMenu) c);
Component invoker = invokerAndCenterOfInvoker.first;
if (invoker instanceof JMenu) {
jitter(invoker, invokerAndCenterOfInvoker.second);
}
}
if (watch.isTimeOut()) {
return false;
}
pause();
}
return true;