5 import java.awt.event.ActionListener;
7 import javax.swing.JButton;
8 import javax.swing.SwingConstants;
11 * useful functions for building Swing GUIs
15 public final class JvSwingUtils
18 * wrap a bare html safe string to around 60 characters per line using a <table width=350><tr><td></td> field
22 public static String wrapTooltip(String ttext)
24 if (ttext.length()<60)
28 return "<table width=350 border=0><tr><td>"+ttext+"</td></tr></table>";
31 public static JButton makeButton(String label, String tooltip,
32 ActionListener action)
34 JButton button = new JButton();
35 button.setText(label);
36 // TODO: get the base font metrics for the Jalview gui from somewhere
37 button.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
38 button.setForeground(Color.black);
39 button.setHorizontalAlignment(SwingConstants.CENTER);
40 button.setToolTipText(tooltip);
41 button.addActionListener(action);