Given a JTextField
(or any JComponent
for that matter), how would one go about forcing that component\'s designated tooltip to appear, without any
The only way (besides creating your own Tooltip window) I've found is to emmulate the CTRL+F1 keystroke on focus:
new FocusAdapter()
{
@Override
public void focusGained(FocusEvent e)
{
try
{
KeyEvent ke = new KeyEvent(e.getComponent(), KeyEvent.KEY_PRESSED,
System.currentTimeMillis(), InputEvent.CTRL_MASK,
KeyEvent.VK_F1, KeyEvent.CHAR_UNDEFINED);
e.getComponent().dispatchEvent(ke);
}
catch (Throwable e1)
{e1.printStackTrace();}
}
}
Unfortunately, the tooltip will disappear as soon as you move your mouse (outside of the component) or after a delay (see ToolTipManager.setDismissDelay
).