View Javadoc
1   package com.github.celldynamics.quimp.utils;
2   
3   import javax.swing.JComponent;
4   
5   /**
6    * Contain UI related tools.
7    * 
8    * @author p.baniukiewicz
9    *
10   */
11  public class UiTools {
12  
13    /**
14     * Tootltip delay for this window in ms.
15     */
16    public static final int TOOLTIPDELAY = 3000;
17    /**
18     * Length of tool tip text.
19     */
20    public static int toolTipLength = 40;
21  
22    /**
23     * Set tooltip to component with line breaking.
24     * 
25     * @param c component
26     * @param toolTip tooltip text
27     */
28    public static void setToolTip(JComponent c, String toolTip) {
29      if (toolTip != null && !toolTip.isEmpty()) {
30        c.setToolTipText(getToolTipString(toolTip));
31      }
32    }
33  
34    /**
35     * Get tooltip string wrapped.
36     * 
37     * @param toolTip String to wrap
38     * @return wrapped string
39     */
40    public static String getToolTipString(String toolTip) {
41      return "<html>" + QuimpToolsCollection.stringWrap(toolTip, toolTipLength, "<br>") + "</html>";
42    }
43  
44  }