1 16 17 package org.mc4j.console.swing; 18 19 import java.util.HashSet ; 20 import java.util.Set ; 21 22 import javax.swing.SwingUtilities ; 23 24 import org.openide.windows.IOProvider; 25 26 30 public class SwingUtility { 31 32 static Set alertedSet = new HashSet (); 33 34 public static void eventThreadAlert() { 35 if (SwingUtilities.isEventDispatchThread()) { 36 StackTraceElement [] elements = new Exception ().getStackTrace(); 37 for (int i = elements.length-1; i >= 0; i--) { 38 StackTraceElement element = elements[i]; 39 if (element.getClassName().startsWith("org.mc4j")) { 40 41 if (alertedSet.isEmpty()) { 42 IOProvider.getDefault().getIO("MC4J Errors",false).getOut().println( 43 "This panel lists places within MC4J where calls are being made " + 44 "to a server from within the AWT Event Thread. These calls are " + 45 "not safe because long duration calls may cause the application to " + 46 "be unresponsive."); 47 } 48 if (!alertedSet.contains(element)) { 49 alertedSet.add(element); 50 IOProvider.getDefault().getIO("MC4J Errors",false).getOut().println( 51 "Inappropriate call from Awt-EventThread at " + 52 element.getClassName() + "." + 53 element.getMethodName() + "(" + 54 element.getFileName() + ":" + 55 element.getLineNumber() + ")"); 56 break; 57 } 58 } 59 } 60 } 61 } 62 } 63 | Popular Tags |