From: tcofoegbu Date: Tue, 18 Aug 2015 10:45:11 +0000 (+0100) Subject: JAL-1833 modified tooltip to force wraping of long texts without spaces X-Git-Tag: Release_2_10_0~537 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2e2e69270705be9d26a6f9b44de3cedcef2b9042;p=jalview.git JAL-1833 modified tooltip to force wraping of long texts without spaces --- diff --git a/src/jalview/gui/JvSwingUtils.java b/src/jalview/gui/JvSwingUtils.java index b6f85b3..a9d0e75 100644 --- a/src/jalview/gui/JvSwingUtils.java +++ b/src/jalview/gui/JvSwingUtils.java @@ -20,12 +20,15 @@ */ package jalview.gui; +import jalview.util.MessageManager; + import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.GridLayout; import java.awt.Rectangle; import java.awt.event.ActionListener; +import java.util.Objects; import javax.swing.AbstractButton; import javax.swing.JButton; @@ -37,8 +40,6 @@ import javax.swing.JPanel; import javax.swing.JScrollBar; import javax.swing.SwingConstants; -import jalview.util.MessageManager; - /** * useful functions for building Swing GUIs * @@ -59,6 +60,7 @@ public final class JvSwingUtils */ public static String wrapTooltip(boolean enclose, String ttext) { + Objects.requireNonNull(ttext, "Tootip text to format must not be null!"); ttext = ttext.trim(); boolean maxLenghtExceeded = false; @@ -85,9 +87,9 @@ public final class JvSwingUtils } else { - return (enclose ? "
" - : "") - + ttext + ((enclose ? "
" : "")); + return enclose ? "

" + + ttext + "

" + : ttext; } } @@ -148,12 +150,8 @@ public final class JvSwingUtils JPanel laypanel = new JPanel(new GridLayout(1, 2)); JPanel labPanel = new JPanel(new BorderLayout()); JPanel valPanel = new JPanel(); - // laypanel.setSize(panel.getPreferredSize()); - // laypanel.setLayout(null); labPanel.setBounds(new Rectangle(7, 7, 158, 23)); valPanel.setBounds(new Rectangle(172, 7, 270, 23)); - // labPanel.setLayout(new GridLayout(1,1)); - // valPanel.setLayout(new GridLayout(1,1)); labPanel.add(label, BorderLayout.WEST); valPanel.add(valBox); laypanel.add(labPanel);