1 /* 2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* @test 25 @bug 8072769 26 @summary System tray icon title freezes java 27 @author Semyon Sadetsky 28 */ 29 30 import javax.swing.*; 31 import java.awt.*; 32 import java.util.Arrays; 33 34 public class bug8072769 { 35 36 public static void main(String[] args) throws Exception { 37 38 if (!SystemTray.isSupported()) { 39 System.out.println( 40 "SystemTray not supported on the platform under test. " + 41 "Marking the test passed"); 42 } else { 43 UIManager.setLookAndFeel( 44 "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); 45 UIManager.put("swing.boldMetal", Boolean.FALSE); 46 47 SwingUtilities.invokeAndWait(new Runnable() { 48 public void run() { 49 if (!SystemTray.isSupported()) { 50 System.out.println("SystemTray is not supported"); 51 return; 52 } 53 final SystemTray tray = SystemTray.getSystemTray(); 54 final TrayIcon trayIcon = new TrayIcon(icon.getImage()); 55 try { 56 tray.add(trayIcon); 57 } catch (AWTException e) { 58 throw new RuntimeException( 59 "TrayIcon could not be added."); 60 } 61 trayIcon.displayMessage(createString(64, 'A'), 62 createString(256, 'C'), TrayIcon.MessageType.ERROR); 63 64 trayIcon.setToolTip(createString(128, 'B')); 65 } 66 }); 67 } 68 69 System.out.println("ok"); 70 } 71 72 private static String createString(int len, char letter) { 73 char[] chars = new char[len]; 74 Arrays.fill(chars, letter); 75 chars[len - 2] = '='; 76 chars[len - 1] = '>'; 77 return new String(chars); 78 } 79 80 private static ImageIcon icon = new ImageIcon( 81 new byte[]{71, 73, 70, 56, 57, 97, 32, 0, 35, 0, -43, 0, 0, -1, -1, 82 -1, -19, -101, 9, -18, -95, 24, -14, -76, 71, -4, -19, -46, 83 -3, -13, -31, -17, -88, 40, -12, -63, 102, -10, -51, -124, 84 -16, -82, 55, -11, -57, 117, -2, -7, -15, -7, -32, -77, -9, 85 -45, -108, -5, -26, -62, -13, -70, 86, -8, -39, -94, 83, 86 -126, -95, -8, -38, -93, -6, -26, -63, -9, -45, -109, -4, 87 -14, -32, -15, -76, 70, -12, -58, 116, -17, -89, 39, 77, 88 121, -106, -3, -8, -17, 104, -111, -84, 126, -95, -72, 93, 89 -119, -90, -14, -70, 85, -13, -64, 101, -16, -83, 55, -109, 90 -80, -60, -7, -33, -78, -100, -84, -85, 94, -127, -104, -32, 91 -99, 39, 127, -120, -114, 83, 113, -124, -12, -9, -7, -16, 92 -16, -16, -115, 108, 45, 57, 89, 110, -50, -41, -35, 104, 93 -111, -83, 41, 65, 80, 72, 113, -116, 115, -103, -78, 88, 94 106, 112, -82, -78, -82, -45, -38, -40, -5, -20, -48, -65, 95 -48, -36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, -7, 4, 0, 0, 0, 97 0, 0, 44, 0, 0, 0, 0, 32, 0, 35, 0, 0, 6, -1, 64, -128, 112, 98 72, 4, 16, 0, 14, -57, 2, 1, 96, 30, -117, -48, 40, -78, 99 -55, 96, 28, 28, -125, -62, 0, 96, 48, 74, -91, -116, 102, 100 3, 97, 64, 4, 20, -25, -128, 68, -80, 16, 24, 11, 95, 98, 101 -29, -64, 72, 11, 2, 120, -68, 96, -64, 39, 116, -29, 0, 12, 102 13, 5, 1, 3, 121, -121, -120, 9, 2, 7, 5, 15, 82, 11, 11, 103 92, 15, 6, -120, -107, -121, 7, 2, 18, 0, 112, 80, 3, 8, 104 104, -106, -95, 122, 88, 97, 68, 5, 11, 4, -95, 32, 8, 16, 105 19, 16, 8, 22, -106, -114, 79, 66, 5, 2, 15, 9, -120, 22, 106 19, 81, 21, 31, -120, 7, 6, 10, 67, 71, 4, 119, -121, 20, 107 -128, 16, -57, 120, 7, -101, -111, -58, 9, -108, 121, -55, 108 -128, 0, 16, 121, 123, -117, 67, 5, -71, 121, 30, -42, 67, 109 23, -121, 13, 66, 14, 6, 3, -34, 120, 21, -31, 66, 26, -39, 110 3, 6, -50, 11, -96, 120, 31, -19, 67, 30, 121, 9, 14, 0, 13, 111 124, -121, 68, -32, 19, 98, 6, 15, 58, 71, 18, 12, -27, 97, 112 55, 80, 68, 54, 5, 5, 24, 40, 80, 23, 96, -96, -112, 9, -39, 113 30, 52, -112, 72, -47, 34, 0, 10, 25, -53, 37, 60, -60, 16, 114 -33, 56, 61, 16, -1, 41, -60, 83, 13, 31, -122, 60, 7, 1, 115 -48, 59, -124, 65, 3, 62, -116, 48, -5, 57, 72, -112, -18, 116 -48, 5, -103, 124, 32, -32, 37, 112, -74, -119, 98, 0, 8, 117 -31, 64, -110, 35, 38, 64, 26, 34, -92, 113, 42, 48, -45, 118 70, -76, 24, -77, 60, 80, -91, -60, -70, -12, 76, -120, 49, 119 92, -120, 4, -40, -116, -126, 51, 79, -80, 97, -36, 80, 89, 120 -6, 25, -91, 96, -98, 89, -99, 62, 33, -62, 32, -59, -83, 0, 121 82, 80, 32, 1, -72, 53, 13, -113, -42, 102, -103, 54, -127, 122 25, 84, 40, 15, -115, 40, 37, 20, 49, 34, 26, 103, 78, 29, 123 52, 42, 88, 16, 65, 17, -94, -49, 31, 107, 97, 16, -116, 49, 124 32, 35, -61, 6, 14, 33, 56, 68, -120, -80, -96, 11, 1, 78, 125 -31, -6, 33, 96, 48, -93, -61, -122, 21, 46, 50, -116, -10, 126 -30, -47, -117, -125, 24, 29, 94, -100, -112, 61, -94, 54, 127 -108, 20, 38, 90, -112, -128, 81, -61, 90, 16, 0, 59}, 128 "try icon"); 129 130 }