// Wait the given number of milliseconds for the component to be showing and ready.
@RunsInEDT
private boolean waitForComponentToBeReady(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.i;
if (invoker instanceof JMenu) jitter(invoker, invokerAndCenterOfInvoker.ii);
}
if (watch.isTimeOut()) return false;
pause();
}
return true;
}