JDK-6580959 : Tooltip in system tray not wrapped into multiple lines if "\n" is given as part of tooltip text
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6u2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux,solaris_2.5.1
  • CPU: x86,sparc
  • Submitted: 2007-07-16
  • Updated: 2011-01-19
  • Resolved: 2007-07-17
Related Reports
Duplicate :  
Description
OPERATING SYSTEM(S):
--------------------
Linux AMD64

FULL JDK VERSION(S):
-------------------
java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_02-b05, mixed mode)

DESCRIPTION:
------------
PROBLEM DESCRIPTION:

In Linux, when the tooltip has some text which has \n character in it then it ignores it and displays all the text in a single line.

Please note: The same text *does* appear on different lines on the Windows Platform.

TESTCASE DESCRIPTION
---------------------
import java.awt.AWTException;
import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Sample {
	public static void main(String[] args) {
		PopupMenu pm = new PopupMenu();
		MenuItem exit = new MenuItem("Exit");
		pm.add(exit);
		exit.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}			
		});
		SystemTray st = SystemTray.getSystemTray();
		String multiLined = "First Line\nSecond Line\nThird Line\n";
		TrayIcon ti = new TrayIcon(java.awt.Toolkit.getDefaultToolkit()
				.getImage("flower.jpg"), multiLined, pm);
		ti.setImageAutoSize(true);
		try {
			st.add(ti);
		} catch (AWTException e) {
			e.printStackTrace();
		}
	}
}

STEPS TO REPRODUCE
--------------------
1) compile the above program
2) run java -cp . Sample
3) Put the mouse pointer over the tray icon, you will see the tool tip is not split into multiple lines. This bevahiour is different from the windows build, where it shows as multiple lines.

Comments
EVALUATION I haven't found any place in TrayIcon specification about handling special characters like \n, so this change request may be easily closed as not a defect. Moreover, with the upcoming JTrayIcon class (Swing-based tray icons support) this problem will go away automatically. Still, I'm leaving this CR open to check if it requires much coding to implement and, if not, to implement it.
17-07-2007

WORK AROUND None
16-07-2007