6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
Summary: unnedded code has been removed. Added getter for XWindow.defaultFont to initialize it lazily.
Reviewed-by: dav
--- a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java Thu Mar 13 17:04:54 2008 +0300
+++ b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java Thu Mar 13 17:08:15 2008 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,17 +31,13 @@
import java.awt.Component;
import java.awt.Container;
import java.awt.Cursor;
-import java.awt.DefaultKeyboardFocusManager;
import java.awt.Dimension;
-import java.awt.Event;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;
import java.awt.KeyboardFocusManager;
-import java.awt.MenuBar;
-import java.awt.Point;
import java.awt.Rectangle;
import java.awt.SystemColor;
import java.awt.Toolkit;
@@ -60,12 +56,9 @@
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.VolatileImage;
-import java.awt.peer.CanvasPeer;
import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer;
import java.awt.peer.LightweightPeer;
-import java.awt.peer.PanelPeer;
-import java.awt.peer.WindowPeer;
import java.lang.reflect.*;
import java.security.*;
import java.util.Collection;
@@ -821,7 +814,7 @@
public void setFont(Font f) {
synchronized (getStateLock()) {
if (f == null) {
- f = defaultFont;
+ f = XWindow.getDefaultFont();
}
font = f;
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XMenuItemPeer.java Thu Mar 13 17:04:54 2008 +0300
+++ b/jdk/src/solaris/classes/sun/awt/X11/XMenuItemPeer.java Thu Mar 13 17:08:15 2008 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -218,7 +218,7 @@
Font getTargetFont() {
if (target == null) {
- return XWindow.defaultFont;
+ return XWindow.getDefaultFont();
}
try {
return (Font)m_getFont.invoke(target, new Object[0]);
@@ -227,7 +227,7 @@
} catch (InvocationTargetException e) {
e.printStackTrace();
}
- return XWindow.defaultFont;
+ return XWindow.getDefaultFont();
}
String getTargetLabel() {
--- a/jdk/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java Thu Mar 13 17:04:54 2008 +0300
+++ b/jdk/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java Thu Mar 13 17:08:15 2008 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -187,7 +187,7 @@
//Fix for 6267144: PIT: Popup menu label is not shown, XToolkit
Font getTargetFont() {
if (popupMenuTarget == null) {
- return XWindow.defaultFont;
+ return XWindow.getDefaultFont();
}
try {
return (Font)m_getFont.invoke(popupMenuTarget, new Object[0]);
@@ -196,7 +196,7 @@
} catch (InvocationTargetException e) {
e.printStackTrace();
}
- return XWindow.defaultFont;
+ return XWindow.getDefaultFont();
}
String getTargetLabel() {
--- a/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java Thu Mar 13 17:04:54 2008 +0300
+++ b/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java Thu Mar 13 17:08:15 2008 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,11 +31,8 @@
import sun.awt.*;
import java.awt.image.*;
import java.text.BreakIterator;
-import java.util.Vector;
-import java.lang.reflect.Field;
import java.util.logging.Logger;
import java.util.logging.Level;
-import java.util.AbstractQueue;
import java.util.concurrent.ArrayBlockingQueue;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -629,7 +626,7 @@
final static int TOOLTIP_MAX_LENGTH = 64;
final static int TOOLTIP_MOUSE_CURSOR_INDENT = 5;
final static Color TOOLTIP_BACKGROUND_COLOR = new Color(255, 255, 220);
- final static Font TOOLTIP_TEXT_FONT = XWindow.defaultFont;
+ final static Font TOOLTIP_TEXT_FONT = XWindow.getDefaultFont();
Tooltip(XTrayIconPeer xtiPeer, Frame parent) {
super(parent, Color.black);
--- a/jdk/src/solaris/classes/sun/awt/X11/XWindow.java Thu Mar 13 17:04:54 2008 +0300
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWindow.java Thu Mar 13 17:08:15 2008 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -92,8 +92,16 @@
SurfaceData surfaceData;
XRepaintArea paintArea;
+
// fallback default font object
- final static Font defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
+ private static Font defaultFont;
+
+ static synchronized Font getDefaultFont() {
+ if (null == defaultFont) {
+ defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
+ }
+ return defaultFont;
+ }
/*
* Keeps all buttons which were pressed at the time of the last mouse
@@ -333,7 +341,7 @@
}
Font font = afont;
if (font == null) {
- font = defaultFont;
+ font = XWindow.getDefaultFont();
}
return new SunGraphics2D(surfData, fgColor, bgColor, font);
}
@@ -902,13 +910,11 @@
super.handleConfigureNotifyEvent(xev);
insLog.log(Level.FINER, "Configure, {0}, event disabled: {1}",
- new Object[] {xev, isEventDisabled(xev)});
+ new Object[] {xev.get_xconfigure(), isEventDisabled(xev)});
if (isEventDisabled(xev)) {
return;
}
- long eventWindow = xev.get_xany().get_window();
-
// if ( Check if it's a resize, a move, or a stacking order change )
// {
Rectangle bounds = getBounds();
@@ -982,7 +988,6 @@
// called directly from this package, unlike handleKeyRelease.
// un-final it if you need to override it in a subclass.
final void handleKeyPress(XKeyEvent ev) {
- int keycode = java.awt.event.KeyEvent.VK_UNDEFINED;
long keysym[] = new long[2];
char unicodeKey = 0;
keysym[0] = NoSymbol;
@@ -1066,7 +1071,6 @@
}
// un-private it if you need to call it from elsewhere
private void handleKeyRelease(XKeyEvent ev) {
- int keycode = java.awt.event.KeyEvent.VK_UNDEFINED;
long keysym[] = new long[2];
char unicodeKey = 0;
keysym[0] = NoSymbol;
--- a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java Thu Mar 13 17:04:54 2008 +0300
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java Thu Mar 13 17:08:15 2008 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -112,9 +112,6 @@
PARENT_WINDOW, Long.valueOf(0)}));
}
- // fallback default font object
- static Font defaultFont;
-
/*
* This constant defines icon size recommended for using.
* Apparently, we should use XGetIconSizes which should
@@ -162,10 +159,7 @@
Font f = target.getFont();
if (f == null) {
- if (defaultFont == null) {
- defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
- }
- f = defaultFont;
+ f = XWindow.getDefaultFont();
target.setFont(f);
// we should not call setFont because it will call a repaint
// which the peer may not be ready to do yet.