1 57 58 package swingwtx.swing; 59 60 import swingwt.awt.Component; 61 import swingwt.awt.Container; 62 import swingwtx.accessibility.Accessible; 63 64 public abstract class SwingUtilities implements SwingConstants { 65 66 public static void invokeAndWait(Runnable run) { 67 invokeSync(run); 68 } 69 70 public static void invokeLater(Runnable run) { 71 invokeAsync(run); 72 } 73 74 77 public static void invokeAsync(Runnable run) { 78 SwingWTUtils.checkEventDispatcher(); 79 SwingWTUtils.getDisplay().asyncExec(run); 80 } 81 82 88 public static void invokeSync(Runnable run) { 89 SwingWTUtils.checkEventDispatcher(); 90 if (Thread.currentThread().equals( SwingWTUtils.getDisplay().getThread() )) 91 run.run(); 92 else 93 SwingWTUtils.getDisplay().syncExec(run); 94 } 95 96 99 public static void invokeIn(Runnable run, int milliseconds) { 100 SwingWTUtils.checkEventDispatcher(); 101 SwingWTUtils.getDisplay().timerExec(milliseconds, run); 102 } 103 104 public static void updateComponentTreeUI(Component c) { 105 if (c instanceof Container) ((Container) c).invalidate(); 106 c.repaint(); 107 } 108 109 113 public static Container getAncestorOfClass(Class c, Component comp) { 114 if(comp == null || c == null) 115 return null; 116 Container parent = comp.getParent(); 117 while(parent != null && !(c.isInstance(parent))) 118 parent = parent.getParent(); 119 return parent; 120 } 121 122 public static int getAccessibleChildrenCount(Component component) { return 0; } 124 public static Accessible getAccessibleChild(Component component, int i) { 125 return component.getAccessibleContext().getAccessibleChild(i); 126 } 127 128 } 129 | Popular Tags |