import java.util.Objects;
import javax.swing.AbstractButton;
+import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.SwingConstants;
+import javax.swing.border.Border;
+import javax.swing.border.TitledBorder;
/**
* useful functions for building Swing GUIs
* style class specifying word-wrap and break-word
*
* @param enclose
- * if true, add <html> wrapper tags
+ * if true, add <html> wrapper tags (currently false for only
+ * two references -- both in Jws2Discoverer --
* @param ttext
*
* @return
{
return enclose ? "<html>" + ttext + "</html>" : ttext;
}
-
- return (enclose ? "<html>" : "")
- + "<style> p.ttip {width: 350; text-align: justify; word-wrap: break-word;}</style><p class=\"ttip\">"
- + ttext + "</p>" + ((enclose ? "</html>" : ""));
+ // BH 2018,2019
+ return (enclose
+ ? "<html><div style=\"width:350px;white-space:pre-wrap;padding:2px;overflow-wrap:break-word;\">"
+ + ttext
+ + "</div></html>"
+ : ttext);
}
return combo;
}
+ /**
+ * Adds a titled border to the component in the default font and position (top
+ * left), optionally witht italic text
+ *
+ * @param comp
+ * @param title
+ * @param italic
+ */
+ public static TitledBorder createTitledBorder(JComponent comp,
+ String title, boolean italic)
+ {
+ Font font = comp.getFont();
+ if (italic)
+ {
+ font = new Font(font.getName(), Font.ITALIC, font.getSize());
+ }
+ Border border = BorderFactory.createTitledBorder("");
+ TitledBorder titledBorder = BorderFactory.createTitledBorder(border,
+ title, TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION,
+ font);
+ comp.setBorder(titledBorder);
+
+ return titledBorder;
+ }
+
}