List of usage examples for javax.swing.text JTextComponent setToolTipText
@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.") public void setToolTipText(String text)
From source file:op.tools.SYSTools.java
public static BigDecimal checkBigDecimal(javax.swing.event.CaretEvent evt, boolean nees2BePositive) { BigDecimal bd = null;//w ww .ja va2 s. co m JTextComponent txt = (JTextComponent) evt.getSource(); Action toolTipAction = txt.getActionMap().get("hideTip"); if (toolTipAction != null) { ActionEvent hideTip = new ActionEvent(txt, ActionEvent.ACTION_PERFORMED, ""); toolTipAction.actionPerformed(hideTip); } try { OPDE.debug(txt.getText()); OPDE.debug(assimilateDecimalSeparators(txt.getText())); bd = parseDecimal(txt.getText()); // bd = BigDecimal.valueOf(Double.parseDouble(assimilateDecimalSeparators(txt.getText()))); OPDE.debug(bd); if (nees2BePositive && bd.compareTo(BigDecimal.ZERO) <= 0) { txt.setToolTipText("<html><font color=\"red\"><b>" + SYSTools.xx("misc.msg.invalidnumber") + "</b></font></html>"); toolTipAction = txt.getActionMap().get("postTip"); bd = BigDecimal.ONE; } else { txt.setToolTipText(""); } } catch (NumberFormatException ex) { if (nees2BePositive) { bd = BigDecimal.ONE; } else { bd = BigDecimal.ZERO; } txt.setToolTipText( "<html><font color=\"red\"><b>" + SYSTools.xx("misc.msg.invalidnumber") + "</b></font></html>"); toolTipAction = txt.getActionMap().get("postTip"); if (toolTipAction != null) { ActionEvent postTip = new ActionEvent(txt, ActionEvent.ACTION_PERFORMED, ""); toolTipAction.actionPerformed(postTip); } } return bd; }