I'm trying to print a text in a tooltip, and in the end, put an icon, however I'm not getting it, I tried doing with html.
The problem is that the image comes "broken", does not appear.
Whatwouldbetherightwaytodothis?
importjava.awt.Dimension;importjavax.swing.JComponent;importjavax.swing.JFrame;importjavax.swing.JPanel;importjavax.swing.JTextField;publicclassToolTipextendsJFrame{privateJTextFieldjTextField=newJTextField();publicToolTip(){add(tela());setSize(300,300);setVisible(true);setDefaultCloseOperation(EXIT_ON_CLOSE);}privateJComponenttela(){JPanelpainel=newJPanel();painel.add(jTextField);jTextField.setPreferredSize(newDimension(150,20));jTextField.setToolTipText("Nome do campo: " + personalizaToolTip());
return painel;
}
private String personalizaToolTip() {
//JLabel label = new JLabel();
//label.setIcon(new ImageIcon(getClass().getResource("/imagens/testeIcon.png")));
String texto = "<html><body> o campo esta desabilitado.. <img src=\"/imagens/testeIcon.png\"/> </body></html>";
return texto;
}
public static void main(String[] args) {
ToolTip tp = new ToolTip();
}
}