r317 - in trunk/src: main/java/org/nuiton/widget/tooltip test/java/org/nuiton/widget/toolTip
Author: sletellier Date: 2010-12-13 19:09:11 +0100 (Mon, 13 Dec 2010) New Revision: 317 Url: http://nuiton.org/repositories/revision/nuiton-widgets/317 Log: Clean code if focusable toolTip Modified: trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.java trunk/src/test/java/org/nuiton/widget/toolTip/FocusableToolTipTest.java Modified: trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.java =================================================================== --- trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.java 2010-12-02 11:47:45 UTC (rev 316) +++ trunk/src/main/java/org/nuiton/widget/tooltip/FocusableTip.java 2010-12-13 18:09:11 UTC (rev 317) @@ -24,6 +24,7 @@ */ package org.nuiton.widget.tooltip; +import org.apache.commons.lang.StringUtils; import java.awt.Component; import java.awt.ComponentOrientation; import java.awt.Dimension; @@ -295,7 +296,7 @@ public void toolTipRequested(MouseEvent e, String text) { - if (text==null || text.length()==0) { + if (StringUtils.isEmpty(text)) { possiblyDisposeOfTipWindow(); lastText = text; return; Modified: trunk/src/test/java/org/nuiton/widget/toolTip/FocusableToolTipTest.java =================================================================== --- trunk/src/test/java/org/nuiton/widget/toolTip/FocusableToolTipTest.java 2010-12-02 11:47:45 UTC (rev 316) +++ trunk/src/test/java/org/nuiton/widget/toolTip/FocusableToolTipTest.java 2010-12-13 18:09:11 UTC (rev 317) @@ -1,3 +1,27 @@ +/* + * #%L + * Graphical Widget + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2010 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ package org.nuiton.widget.toolTip; import javax.swing.JFrame; @@ -63,6 +87,26 @@ complexeToolTipLabel.setToolTipText(FocusableTip.DUMMY_TOOL_TIP); frame.getContentPane().add(complexeToolTipLabel, BorderLayout.CENTER); + JLabel emptyToolTipLabel = new JLabel("Empty tool tip text") { + protected FocusableTip focusableTip; + + @Override + public String getToolTipText(MouseEvent event) { + String toolTipText = super.getToolTipText(event); + + // display it into persistant tooltip + if (focusableTip == null) { + focusableTip = new FocusableTip(this, true); + focusableTip.setSize(600, 400); + } + focusableTip.toolTipRequested(event, toolTipText); + + return null; + } + }; + emptyToolTipLabel.setToolTipText(null); + frame.getContentPane().add(emptyToolTipLabel, BorderLayout.SOUTH); + frame.setVisible(true); frame.pack(); }
participants (1)
-
sletellier@users.nuiton.org