How to Resize a Text Tool Tip in JAVA swing

Viewed 274

I am working on a small project in which I want let the user know some information in entering data using tool tips, but the text tool tip size is too small, not the best view of that, so i was wondering if someone can help me out with it.

1 Answers

If you just want to resize your tooltip, you can probably call setPreferredSize(Dimension preferredSize). You can set the dimension like so:

Dimension d = myToolTip.getPreferredSize();
// Or:
Dimension d2 = new Dimension(20, 30);
myToolTip.setPreferredSize(d2);

EDIT: If you want to adjust the font of the text of the tooltip you can do so like this:

UIManager.put("ToolTip.font", new Font("Arial", Font.BOLD, 14));

See here for the javadoc, here for an example, here for another SO question, and here for JToolTip customization.

Related