Search code examples
javatrayiconline-breaks

Java TrayIcon.displayMessage() and line-breaks


I'm writing a Java app with a SystemTray icon, and I'd like to put line-breaks into the TrayIcon's "display message", but the normal html trick doesn't seem to work (like it does inside JLabels).

In the example below, the trayIcon variable below is of type "java.awt.TrayIcon".

trayIcon.displayMessage("Title", "<p>Blah</p> \r\n Blah <br> blah ... blah", TrayIcon.MessageType.INFO);

Java ignores the \r\n, but displays the html tags.

Any ideas?

If not, I'll use a JFrame or something.

UPDATE: it seems to be a platform-specific issue, and I should have specified my OS in the question: I need this to work on Windows and Linux.

Nishan showed that a \n works on Windows, and I confirmed with a Vista box I now have next to me. It looks like I'll need to make something custom with a JFrame or a messagebox

Cheers guys


Solution

  • Appending \n worked for me :

    "<HtMl><p>Blah</p> \n Blah <br> blah ... blah"