下面列出了怎么用java.awt.IllegalComponentStateException的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public void setMainWindow(JFrame window) {
super.setMainWindow(window);
try {
if (!GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().isWindowTranslucencySupported(TRANSLUCENT)) return;
} catch (IllegalComponentStateException e) {
return;
}
window.setOpacity(0.80f);
SimpleClock clock = new SimpleClock();
window.setGlassPane(clock);
clock.setVisible(true);
}
public void notifyListeners() {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("notifyListeners");
}
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone. This is because during the course
// of responding to a display change, it may be appropriate for a
// DisplayChangedListener to add or remove itself from a SunDisplayChanger.
// If the set itself were iterated over, rather than a clone, it is
// trivial to get a ConcurrentModificationException by having a
// DisplayChangedListener remove itself from its list.
// Because all display change handling is done on the event thread,
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it. -bchristi 7/10/2001
Set<DisplayChangedListener> cloneSet;
synchronized(listeners) {
cloneSet = new HashSet<DisplayChangedListener>(listeners.keySet());
}
Iterator<DisplayChangedListener> itr = cloneSet.iterator();
while (itr.hasNext()) {
DisplayChangedListener current = itr.next();
try {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("displayChanged for listener: " + current);
}
current.displayChanged();
} catch (IllegalComponentStateException e) {
// This DisplayChangeListener is no longer valid. Most
// likely, a top-level window was dispose()d, but its
// Java objects have not yet been garbage collected. In any
// case, we no longer need to track this listener, though we
// do need to remove it from the original list, not the clone.
listeners.remove(current);
}
}
}
public void notifyPaletteChanged() {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("notifyPaletteChanged");
}
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone. This is because during the course
// of responding to a display change, it may be appropriate for a
// DisplayChangedListener to add or remove itself from a SunDisplayChanger.
// If the set itself were iterated over, rather than a clone, it is
// trivial to get a ConcurrentModificationException by having a
// DisplayChangedListener remove itself from its list.
// Because all display change handling is done on the event thread,
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it. -bchristi 7/10/2001
Set<DisplayChangedListener> cloneSet;
synchronized (listeners) {
cloneSet = new HashSet<DisplayChangedListener>(listeners.keySet());
}
Iterator<DisplayChangedListener> itr = cloneSet.iterator();
while (itr.hasNext()) {
DisplayChangedListener current = itr.next();
try {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("paletteChanged for listener: " + current);
}
current.paletteChanged();
} catch (IllegalComponentStateException e) {
// This DisplayChangeListener is no longer valid. Most
// likely, a top-level window was dispose()d, but its
// Java objects have not yet been garbage collected. In any
// case, we no longer need to track this listener, though we
// do need to remove it from the original list, not the clone.
listeners.remove(current);
}
}
}
public static void waitTillShownEx(final Component comp) throws InterruptedException {
while (true) {
try {
Thread.sleep(100);
comp.getLocationOnScreen();
break;
} catch (IllegalComponentStateException e) {}
}
}
public void notifyListeners() {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("notifyListeners");
}
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone. This is because during the course
// of responding to a display change, it may be appropriate for a
// DisplayChangedListener to add or remove itself from a SunDisplayChanger.
// If the set itself were iterated over, rather than a clone, it is
// trivial to get a ConcurrentModificationException by having a
// DisplayChangedListener remove itself from its list.
// Because all display change handling is done on the event thread,
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it. -bchristi 7/10/2001
Set<DisplayChangedListener> cloneSet;
synchronized(listeners) {
cloneSet = new HashSet<DisplayChangedListener>(listeners.keySet());
}
Iterator<DisplayChangedListener> itr = cloneSet.iterator();
while (itr.hasNext()) {
DisplayChangedListener current = itr.next();
try {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("displayChanged for listener: " + current);
}
current.displayChanged();
} catch (IllegalComponentStateException e) {
// This DisplayChangeListener is no longer valid. Most
// likely, a top-level window was dispose()d, but its
// Java objects have not yet been garbage collected. In any
// case, we no longer need to track this listener, though we
// do need to remove it from the original list, not the clone.
listeners.remove(current);
}
}
}
public void notifyPaletteChanged() {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("notifyPaletteChanged");
}
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone. This is because during the course
// of responding to a display change, it may be appropriate for a
// DisplayChangedListener to add or remove itself from a SunDisplayChanger.
// If the set itself were iterated over, rather than a clone, it is
// trivial to get a ConcurrentModificationException by having a
// DisplayChangedListener remove itself from its list.
// Because all display change handling is done on the event thread,
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it. -bchristi 7/10/2001
Set<DisplayChangedListener> cloneSet;
synchronized (listeners) {
cloneSet = new HashSet<DisplayChangedListener>(listeners.keySet());
}
Iterator<DisplayChangedListener> itr = cloneSet.iterator();
while (itr.hasNext()) {
DisplayChangedListener current = itr.next();
try {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("paletteChanged for listener: " + current);
}
current.paletteChanged();
} catch (IllegalComponentStateException e) {
// This DisplayChangeListener is no longer valid. Most
// likely, a top-level window was dispose()d, but its
// Java objects have not yet been garbage collected. In any
// case, we no longer need to track this listener, though we
// do need to remove it from the original list, not the clone.
listeners.remove(current);
}
}
}
public static void waitTillShownEx(final Component comp) throws InterruptedException {
while (true) {
try {
Thread.sleep(100);
comp.getLocationOnScreen();
break;
} catch (IllegalComponentStateException e) {}
}
}
public void notifyListeners() {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("notifyListeners");
}
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone. This is because during the course
// of responding to a display change, it may be appropriate for a
// DisplayChangedListener to add or remove itself from a SunDisplayChanger.
// If the set itself were iterated over, rather than a clone, it is
// trivial to get a ConcurrentModificationException by having a
// DisplayChangedListener remove itself from its list.
// Because all display change handling is done on the event thread,
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it. -bchristi 7/10/2001
Set<DisplayChangedListener> cloneSet;
synchronized(listeners) {
cloneSet = new HashSet<DisplayChangedListener>(listeners.keySet());
}
Iterator<DisplayChangedListener> itr = cloneSet.iterator();
while (itr.hasNext()) {
DisplayChangedListener current = itr.next();
try {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("displayChanged for listener: " + current);
}
current.displayChanged();
} catch (IllegalComponentStateException e) {
// This DisplayChangeListener is no longer valid. Most
// likely, a top-level window was dispose()d, but its
// Java objects have not yet been garbage collected. In any
// case, we no longer need to track this listener, though we
// do need to remove it from the original list, not the clone.
listeners.remove(current);
}
}
}
public void notifyPaletteChanged() {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("notifyPaletteChanged");
}
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone. This is because during the course
// of responding to a display change, it may be appropriate for a
// DisplayChangedListener to add or remove itself from a SunDisplayChanger.
// If the set itself were iterated over, rather than a clone, it is
// trivial to get a ConcurrentModificationException by having a
// DisplayChangedListener remove itself from its list.
// Because all display change handling is done on the event thread,
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it. -bchristi 7/10/2001
Set<DisplayChangedListener> cloneSet;
synchronized (listeners) {
cloneSet = new HashSet<DisplayChangedListener>(listeners.keySet());
}
Iterator<DisplayChangedListener> itr = cloneSet.iterator();
while (itr.hasNext()) {
DisplayChangedListener current = itr.next();
try {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("paletteChanged for listener: " + current);
}
current.paletteChanged();
} catch (IllegalComponentStateException e) {
// This DisplayChangeListener is no longer valid. Most
// likely, a top-level window was dispose()d, but its
// Java objects have not yet been garbage collected. In any
// case, we no longer need to track this listener, though we
// do need to remove it from the original list, not the clone.
listeners.remove(current);
}
}
}
public static void waitTillShownEx(final Component comp) throws InterruptedException {
while (true) {
try {
Thread.sleep(100);
comp.getLocationOnScreen();
break;
} catch (IllegalComponentStateException e) {}
}
}
@Deprecated
@Override
public Rectangle modelToView(int pos) throws BadLocationException {
// Hack-fix for #9 - Enchantment Cracker sometimes crashes if you go from second tab to first tab
// We have to hack-fix because it's a Java bug (JDK-8179665)
try {
getLocationOnScreen();
} catch (IllegalComponentStateException e) {
throw new BadLocationException(null, 0);
}
return super.modelToView(pos);
}
protected void floatAt(Point position, Point origin) {
if (lizziePane.isFloatable()) {
try {
Point offset = dragWindow.getOffset();
if (offset == null) {
offset = position;
dragWindow.setOffset(offset);
}
Point global = new Point(origin.x + position.x, origin.y + position.y);
setFloatingLocation(global.x - offset.x, global.y - offset.y);
if (dockingSource != null) {
Point dockingPosition = dockingSource.getLocationOnScreen();
Point comparisonPoint =
new Point(global.x - dockingPosition.x, global.y - dockingPosition.y);
if (canDock(dockingSource, comparisonPoint)) {
setFloating(false, comparisonPoint);
} else {
setFloating(true, null);
}
} else {
setFloating(true, null);
}
dragWindow.setOffset(null);
} catch (IllegalComponentStateException e) {
}
}
}
public void toWindow(Point position, Dimension size) {
if (lizziePane.isFloatable()) {
try {
originSize = size;
if (dragWindow == null) dragWindow = createDragWindow(lizziePane);
if (dockingSource == null) dockingSource = lizziePane.getParent();
constraintBeforeFloating = calculateConstraint();
setFloatingLocation(position.x, position.y);
setFloating(true, null);
} catch (IllegalComponentStateException e) {
}
}
}
public void notifyListeners() {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("notifyListeners");
}
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone. This is because during the course
// of responding to a display change, it may be appropriate for a
// DisplayChangedListener to add or remove itself from a SunDisplayChanger.
// If the set itself were iterated over, rather than a clone, it is
// trivial to get a ConcurrentModificationException by having a
// DisplayChangedListener remove itself from its list.
// Because all display change handling is done on the event thread,
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it. -bchristi 7/10/2001
Set<DisplayChangedListener> cloneSet;
synchronized(listeners) {
cloneSet = new HashSet<DisplayChangedListener>(listeners.keySet());
}
Iterator<DisplayChangedListener> itr = cloneSet.iterator();
while (itr.hasNext()) {
DisplayChangedListener current = itr.next();
try {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("displayChanged for listener: " + current);
}
current.displayChanged();
} catch (IllegalComponentStateException e) {
// This DisplayChangeListener is no longer valid. Most
// likely, a top-level window was dispose()d, but its
// Java objects have not yet been garbage collected. In any
// case, we no longer need to track this listener, though we
// do need to remove it from the original list, not the clone.
listeners.remove(current);
}
}
}
public void notifyPaletteChanged() {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("notifyPaletteChanged");
}
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone. This is because during the course
// of responding to a display change, it may be appropriate for a
// DisplayChangedListener to add or remove itself from a SunDisplayChanger.
// If the set itself were iterated over, rather than a clone, it is
// trivial to get a ConcurrentModificationException by having a
// DisplayChangedListener remove itself from its list.
// Because all display change handling is done on the event thread,
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it. -bchristi 7/10/2001
Set<DisplayChangedListener> cloneSet;
synchronized (listeners) {
cloneSet = new HashSet<DisplayChangedListener>(listeners.keySet());
}
Iterator<DisplayChangedListener> itr = cloneSet.iterator();
while (itr.hasNext()) {
DisplayChangedListener current = itr.next();
try {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("paletteChanged for listener: " + current);
}
current.paletteChanged();
} catch (IllegalComponentStateException e) {
// This DisplayChangeListener is no longer valid. Most
// likely, a top-level window was dispose()d, but its
// Java objects have not yet been garbage collected. In any
// case, we no longer need to track this listener, though we
// do need to remove it from the original list, not the clone.
listeners.remove(current);
}
}
}
public static void waitTillShownEx(final Component comp) throws InterruptedException {
while (true) {
try {
Thread.sleep(100);
comp.getLocationOnScreen();
break;
} catch (IllegalComponentStateException e) {}
}
}
public void notifyListeners() {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("notifyListeners");
}
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone. This is because during the course
// of responding to a display change, it may be appropriate for a
// DisplayChangedListener to add or remove itself from a SunDisplayChanger.
// If the set itself were iterated over, rather than a clone, it is
// trivial to get a ConcurrentModificationException by having a
// DisplayChangedListener remove itself from its list.
// Because all display change handling is done on the event thread,
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it. -bchristi 7/10/2001
Set<DisplayChangedListener> cloneSet;
synchronized(listeners) {
cloneSet = new HashSet<DisplayChangedListener>(listeners.keySet());
}
Iterator<DisplayChangedListener> itr = cloneSet.iterator();
while (itr.hasNext()) {
DisplayChangedListener current = itr.next();
try {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("displayChanged for listener: " + current);
}
current.displayChanged();
} catch (IllegalComponentStateException e) {
// This DisplayChangeListener is no longer valid. Most
// likely, a top-level window was dispose()d, but its
// Java objects have not yet been garbage collected. In any
// case, we no longer need to track this listener, though we
// do need to remove it from the original list, not the clone.
listeners.remove(current);
}
}
}
public void notifyPaletteChanged() {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("notifyPaletteChanged");
}
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone. This is because during the course
// of responding to a display change, it may be appropriate for a
// DisplayChangedListener to add or remove itself from a SunDisplayChanger.
// If the set itself were iterated over, rather than a clone, it is
// trivial to get a ConcurrentModificationException by having a
// DisplayChangedListener remove itself from its list.
// Because all display change handling is done on the event thread,
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it. -bchristi 7/10/2001
Set<DisplayChangedListener> cloneSet;
synchronized (listeners) {
cloneSet = new HashSet<DisplayChangedListener>(listeners.keySet());
}
Iterator<DisplayChangedListener> itr = cloneSet.iterator();
while (itr.hasNext()) {
DisplayChangedListener current = itr.next();
try {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("paletteChanged for listener: " + current);
}
current.paletteChanged();
} catch (IllegalComponentStateException e) {
// This DisplayChangeListener is no longer valid. Most
// likely, a top-level window was dispose()d, but its
// Java objects have not yet been garbage collected. In any
// case, we no longer need to track this listener, though we
// do need to remove it from the original list, not the clone.
listeners.remove(current);
}
}
}
public static void waitTillShownEx(final Component comp) throws InterruptedException {
while (true) {
try {
Thread.sleep(100);
comp.getLocationOnScreen();
break;
} catch (IllegalComponentStateException e) {}
}
}
public void notifyListeners() {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("notifyListeners");
}
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone. This is because during the course
// of responding to a display change, it may be appropriate for a
// DisplayChangedListener to add or remove itself from a SunDisplayChanger.
// If the set itself were iterated over, rather than a clone, it is
// trivial to get a ConcurrentModificationException by having a
// DisplayChangedListener remove itself from its list.
// Because all display change handling is done on the event thread,
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it. -bchristi 7/10/2001
Set<DisplayChangedListener> cloneSet;
synchronized(listeners) {
cloneSet = new HashSet<DisplayChangedListener>(listeners.keySet());
}
Iterator<DisplayChangedListener> itr = cloneSet.iterator();
while (itr.hasNext()) {
DisplayChangedListener current = itr.next();
try {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("displayChanged for listener: " + current);
}
current.displayChanged();
} catch (IllegalComponentStateException e) {
// This DisplayChangeListener is no longer valid. Most
// likely, a top-level window was dispose()d, but its
// Java objects have not yet been garbage collected. In any
// case, we no longer need to track this listener, though we
// do need to remove it from the original list, not the clone.
listeners.remove(current);
}
}
}
public static void waitTillShownEx(final Component comp) throws InterruptedException {
while (true) {
try {
Thread.sleep(100);
comp.getLocationOnScreen();
break;
} catch (IllegalComponentStateException e) {}
}
}
public void notifyListeners() {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("notifyListeners");
}
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone. This is because during the course
// of responding to a display change, it may be appropriate for a
// DisplayChangedListener to add or remove itself from a SunDisplayChanger.
// If the set itself were iterated over, rather than a clone, it is
// trivial to get a ConcurrentModificationException by having a
// DisplayChangedListener remove itself from its list.
// Because all display change handling is done on the event thread,
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it. -bchristi 7/10/2001
Set<DisplayChangedListener> cloneSet;
synchronized(listeners) {
cloneSet = new HashSet<DisplayChangedListener>(listeners.keySet());
}
Iterator<DisplayChangedListener> itr = cloneSet.iterator();
while (itr.hasNext()) {
DisplayChangedListener current = itr.next();
try {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("displayChanged for listener: " + current);
}
current.displayChanged();
} catch (IllegalComponentStateException e) {
// This DisplayChangeListener is no longer valid. Most
// likely, a top-level window was dispose()d, but its
// Java objects have not yet been garbage collected. In any
// case, we no longer need to track this listener, though we
// do need to remove it from the original list, not the clone.
listeners.remove(current);
}
}
}
public static void waitTillShown(final Component comp) throws InterruptedException {
while (true) {
try {
Thread.sleep(100);
comp.getLocationOnScreen();
break;
} catch (IllegalComponentStateException e) {}
}
}
public static void waitTillShownEx(final Component comp) throws InterruptedException {
while (true) {
try {
Thread.sleep(100);
comp.getLocationOnScreen();
break;
} catch (IllegalComponentStateException e) {}
}
}
private static boolean pressOK(Component comp) {
JInternalFrame internalFrame
= findModalInternalFrame(comp, QUESTION);
if (internalFrame == null) {
return false;
}
JButton button = (JButton) findButton(internalFrame);
if (button == null) {
return false;
}
try {
Robot robot = new Robot();
Point location = button.getLocationOnScreen();
Rectangle bounds = button.getBounds();
int centerX = (int) (location.getX() + bounds.getWidth() / 2);
int centerY = (int) (location.getY() + bounds.getHeight() / 2);
robot.mouseMove(centerX, centerY);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
} catch (IllegalComponentStateException ignore) {
return false;
} catch (AWTException e) {
throw new RuntimeException(e);
}
return true;
}
public void notifyListeners() {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("notifyListeners");
}
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone. This is because during the course
// of responding to a display change, it may be appropriate for a
// DisplayChangedListener to add or remove itself from a SunDisplayChanger.
// If the set itself were iterated over, rather than a clone, it is
// trivial to get a ConcurrentModificationException by having a
// DisplayChangedListener remove itself from its list.
// Because all display change handling is done on the event thread,
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it. -bchristi 7/10/2001
Set<DisplayChangedListener> cloneSet;
synchronized(listeners) {
cloneSet = new HashSet<DisplayChangedListener>(listeners.keySet());
}
Iterator<DisplayChangedListener> itr = cloneSet.iterator();
while (itr.hasNext()) {
DisplayChangedListener current = itr.next();
try {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("displayChanged for listener: " + current);
}
current.displayChanged();
} catch (IllegalComponentStateException e) {
// This DisplayChangeListener is no longer valid. Most
// likely, a top-level window was dispose()d, but its
// Java objects have not yet been garbage collected. In any
// case, we no longer need to track this listener, though we
// do need to remove it from the original list, not the clone.
listeners.remove(current);
}
}
}
public void notifyPaletteChanged() {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("notifyPaletteChanged");
}
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone. This is because during the course
// of responding to a display change, it may be appropriate for a
// DisplayChangedListener to add or remove itself from a SunDisplayChanger.
// If the set itself were iterated over, rather than a clone, it is
// trivial to get a ConcurrentModificationException by having a
// DisplayChangedListener remove itself from its list.
// Because all display change handling is done on the event thread,
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it. -bchristi 7/10/2001
Set<DisplayChangedListener> cloneSet;
synchronized (listeners) {
cloneSet = new HashSet<DisplayChangedListener>(listeners.keySet());
}
Iterator<DisplayChangedListener> itr = cloneSet.iterator();
while (itr.hasNext()) {
DisplayChangedListener current = itr.next();
try {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("paletteChanged for listener: " + current);
}
current.paletteChanged();
} catch (IllegalComponentStateException e) {
// This DisplayChangeListener is no longer valid. Most
// likely, a top-level window was dispose()d, but its
// Java objects have not yet been garbage collected. In any
// case, we no longer need to track this listener, though we
// do need to remove it from the original list, not the clone.
listeners.remove(current);
}
}
}
public static void waitTillShownEx(final Component comp) throws InterruptedException {
while (true) {
try {
Thread.sleep(100);
comp.getLocationOnScreen();
break;
} catch (IllegalComponentStateException e) {}
}
}
public void savePreferences() {
AppPreferences.TICK_FREQUENCY.set(Double.valueOf(proj.getSimulator().getTickFrequency()));
AppPreferences.LAYOUT_SHOW_GRID.setBoolean(layoutZoomModel.getShowGrid());
AppPreferences.LAYOUT_ZOOM.set(Double.valueOf(layoutZoomModel.getZoomFactor()));
if (appearance != null) {
ZoomModel aZoom = appearance.getZoomModel();
AppPreferences.APPEARANCE_SHOW_GRID.setBoolean(aZoom.getShowGrid());
AppPreferences.APPEARANCE_ZOOM.set(Double.valueOf(aZoom.getZoomFactor()));
}
int state = getExtendedState() & ~java.awt.Frame.ICONIFIED;
AppPreferences.WINDOW_STATE.set(Integer.valueOf(state));
Dimension dim = getSize();
AppPreferences.WINDOW_WIDTH.set(Integer.valueOf(dim.width));
AppPreferences.WINDOW_HEIGHT.set(Integer.valueOf(dim.height));
Point loc;
try {
loc = getLocationOnScreen();
} catch (IllegalComponentStateException e) {
loc = Projects.getLocation(this);
}
if (loc != null) {
AppPreferences.WINDOW_LOCATION.set(loc.x + "," + loc.y);
}
AppPreferences.WINDOW_LEFT_SPLIT.set(Double.valueOf(leftRegion.getFraction()));
AppPreferences.WINDOW_MAIN_SPLIT.set(Double.valueOf(mainRegion.getFraction()));
AppPreferences.DIALOG_DIRECTORY.set(JFileChoosers.getCurrentDirectory());
}
public void notifyListeners() {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("notifyListeners");
}
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone. This is because during the course
// of responding to a display change, it may be appropriate for a
// DisplayChangedListener to add or remove itself from a SunDisplayChanger.
// If the set itself were iterated over, rather than a clone, it is
// trivial to get a ConcurrentModificationException by having a
// DisplayChangedListener remove itself from its list.
// Because all display change handling is done on the event thread,
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it. -bchristi 7/10/2001
Set<DisplayChangedListener> cloneSet;
synchronized(listeners) {
cloneSet = new HashSet<DisplayChangedListener>(listeners.keySet());
}
Iterator<DisplayChangedListener> itr = cloneSet.iterator();
while (itr.hasNext()) {
DisplayChangedListener current = itr.next();
try {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("displayChanged for listener: " + current);
}
current.displayChanged();
} catch (IllegalComponentStateException e) {
// This DisplayChangeListener is no longer valid. Most
// likely, a top-level window was dispose()d, but its
// Java objects have not yet been garbage collected. In any
// case, we no longer need to track this listener, though we
// do need to remove it from the original list, not the clone.
listeners.remove(current);
}
}
}