public ApplicationContext.ResourceCacheDictionary getResourceCache() { return ApplicationContext.getResourceCache(); }
/** * Queues a task to execute after all pending events have been processed and * returns without waiting for the task to complete. * * @param callback * The task to execute. */ public static QueuedCallback queueCallback(Runnable callback) { return queueCallback(callback, false); }
public void schedule(long delay, Runnable callback) { scheduleCallback(callback, delay); }
/** * Schedules a task for repeated execution. The task will be executed on the * UI thread and will begin executing immediately. * * @param callback * The task to execute. * * @param period * The interval at which the task will be repeated. */ public static ScheduledCallback scheduleRecurringCallback(Runnable callback, long period) { return scheduleRecurringCallback(callback, 0, period); }
/** * Schedules a task for one-time execution. The task will be executed on * the UI thread. * * @param callback * The task to execute. * * @param delay * The length of time to wait before executing the task (in milliseconds). */ public static ScheduledCallback scheduleCallback(Runnable callback, long delay) { ScheduledCallback scheduledCallback = new ScheduledCallback(callback); // TODO This is a workaround for a potential OS X bug; revisit try { try { timer.schedule(scheduledCallback, delay); } catch (IllegalStateException exception) { createTimer(); timer.schedule(scheduledCallback, delay); } } catch (Throwable throwable) { System.err.println("Unable to schedule callback: " + throwable); } return scheduledCallback; }
@Override public void propertyChange(PropertyChangeEvent event) { initializeFontRenderContext(); ApplicationContext.invalidateDisplays(); } });
@Override public void run() { // Remove the display from the display list displays.remove(HostApplet.this.displayHost.getDisplay()); // Remove this applet from the host applets list and stop the timer hostApplets.remove(HostApplet.this); if (hostApplets.getLength() == 0) { destroyTimer(); } } }
ApplicationContext.applyStylesheet(stylesheet);
public static void handleUncaughtException(Exception exception) { int n = 0; for (Application application : applications) { if (application instanceof Application.UncaughtExceptionHandler) { Application.UncaughtExceptionHandler uncaughtExceptionHandler = (Application.UncaughtExceptionHandler)application; uncaughtExceptionHandler.uncaughtExceptionThrown(exception); n++; } } if (n == 0) { defaultUncaughtExceptionHandler(exception); } }
/** * Schedules a task for repeated execution. The task will be executed on the * UI thread and will begin executing immediately. * * @param callback * The task to execute. * * @param period * The interval at which the task will be repeated (in milliseconds). */ public static ScheduledCallback scheduleRecurringCallback(Runnable callback, long period) { return scheduleRecurringCallback(callback, 0, period); }
/** * Schedules a task for one-time execution. The task will be executed on * the UI thread. * * @param callback * The task to execute. * * @param delay * The length of time to wait before executing the task. */ public static ScheduledCallback scheduleCallback(Runnable callback, long delay) { ScheduledCallback scheduledCallback = new ScheduledCallback(callback); // TODO This is a workaround for a potential OS X bug; revisit try { try { timer.schedule(scheduledCallback, delay); } catch (IllegalStateException exception) { createTimer(); timer.schedule(scheduledCallback, delay); } } catch (Throwable throwable) { System.err.println("Unable to schedule callback: " + throwable); } return scheduledCallback; }
@Override public void propertyChange(PropertyChangeEvent event) { initializeFontRenderContext(); ApplicationContext.invalidateDisplays(); } });
@Override public void run() { // Remove the display from the display list displays.remove(displayHost.getDisplay()); // Remove this applet from the host applets list and stop the timer hostApplets.remove(HostApplet.this); if (hostApplets.getLength() == 0) { destroyTimer(); } } }
ApplicationContext.applyStylesheet(stylesheet);
/** * Queues a task to execute after all pending events have been processed and * returns without waiting for the task to complete. * * @param callback * The task to execute. */ public static QueuedCallback queueCallback(Runnable callback) { return queueCallback(callback, false); }
public void scheduleRecurring(long delay, long period, Runnable callback) { scheduleRecurringCallback(callback, delay, period); }
public static Image loadFromCache(URL location) { if (location == null) { throw new IllegalArgumentException("location is null."); } Image image = (Image)ApplicationContext.getResourceCache().get(location); if (image == null) { try { image = Image.load(location); ApplicationContext.getResourceCache().put(location, image); } catch (TaskExecutionException exception) { throw new IllegalArgumentException(exception); } } return image; }
protected boolean mouseMove(int x, int y) { boolean consumed = false; if (isEnabled()) { mouseLocation = new Point(x, y); if (triggerTooltipCallback != null) { triggerTooltipCallback.cancel(); triggerTooltipCallback = null; } triggerTooltipCallback = ApplicationContext.scheduleCallback(new Runnable() { @Override public void run() { Point mouseLocation = getMouseLocation(); componentTooltipListeners.tooltipTriggered(Component.this, mouseLocation.x, mouseLocation.y); } }, tooltipDelay); consumed = componentMouseListeners.mouseMove(this, x, y); } return consumed; }
/** * Schedules a task for repeated execution. The task will be executed on the * UI thread. * * @param callback * The task to execute. * * @param delay * The length of time to wait before the first execution of the task (milliseconds). * * @param period * The interval at which the task will be repeated (also in milliseconds). */ public static ScheduledCallback scheduleRecurringCallback(Runnable callback, long delay, long period) { ScheduledCallback scheduledCallback = new ScheduledCallback(callback); // TODO This is a workaround for a potential OS X bug; revisit try { try { timer.schedule(scheduledCallback, delay, period); } catch (IllegalStateException exception) { createTimer(); timer.schedule(scheduledCallback, delay, period); } } catch (Throwable throwable) { System.err.println("Unable to schedule callback: " + throwable); } return scheduledCallback; }
public void queue(boolean wait, Runnable callback) { queueCallback(callback, wait); }