Author: echatellier Date: 2010-06-24 10:14:49 +0200 (Thu, 24 Jun 2010) New Revision: 267 Url: http://nuiton.org/repositories/revision/nuiton-widgets/267 Log: Add tip size customization. Modified: trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.java trunk/src/main/java/org/nuiton/widget/tooltip/TipWindow.java Modified: trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.java =================================================================== --- trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.java 2010-06-19 18:57:14 UTC (rev 266) +++ trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.java 2010-06-24 08:14:49 UTC (rev 267) @@ -64,6 +64,12 @@ private HyperlinkListener hyperlinkListener; private String lastText; + /** Width with default value. */ + protected int width = 320; + + /** Height with default value. */ + protected int height = 250; + /** * The screen bounds in which the mouse has to stay for the currently * displayed tip to stay visible. @@ -86,6 +92,16 @@ tipVisibleBounds = new Rectangle(); } + /** + * Change tip size. + * + * @param width width + * @param height height + */ + public void setSize(int width, int height) { + this.width = width; + this.height = height; + } /** * Compute the bounds in which the user can move the mouse without the @@ -126,7 +142,7 @@ return; } - tipWindow.fixSize(); + tipWindow.fixSize(width, height); ComponentOrientation o = attachedComponent.getComponentOrientation(); Point p = e.getPoint(); Modified: trunk/src/main/java/org/nuiton/widget/tooltip/TipWindow.java =================================================================== --- trunk/src/main/java/org/nuiton/widget/tooltip/TipWindow.java 2010-06-19 18:57:14 UTC (rev 266) +++ trunk/src/main/java/org/nuiton/widget/tooltip/TipWindow.java 2010-06-24 08:14:49 UTC (rev 267) @@ -179,8 +179,11 @@ * when rendering HTML until after layout already done. See * http://forums.sun.com/thread.jspa?forumID=57&threadID=574810 for a * discussion. + * + * @param width min width + * @param height min height */ - void fixSize() { + void fixSize(int width, int height) { Dimension d = textArea.getPreferredSize(); Rectangle r = null; @@ -191,8 +194,8 @@ // Ensure the text area doesn't start out too tall or wide. d = textArea.getPreferredSize(); - d.width = Math.min(d.width+25, 320); - d.height = Math.min(d.height, 150); + d.width = Math.min(d.width+25, width); + d.height = Math.min(d.height, height); textArea.setPreferredSize(d);