This commit is contained in:
J. Duke 2017-07-05 16:47:21 +02:00
commit 6c81e33a5c
227 changed files with 11287 additions and 5311 deletions

View File

@ -21,3 +21,4 @@ ab523b49de1fc73fefe6855ce1e0349bdbd7af29 jdk7-b39
a395e3aac4744cc9033fcd819fad1239a45add52 jdk7-b44
99846f001ca214015578d593802d26e27246a802 jdk7-b45
e8a2a4d187773a62f3309b0fa265c13425bc2258 jdk7-b46
d7744e86dedc21a8ecf6bdb73eb191b8eaf5b0da jdk7-b47

View File

@ -21,3 +21,4 @@ ccd6a16502e0650d91d85c4b86be05cbcd461a87 jdk7-b42
9803dac7254041b30ca65e3852d4c566b9757c3b jdk7-b44
68814aa5b44b1f16931a97e7cd4028c70eb9586b jdk7-b45
1691dbfc08f8ee3f4e23a1ff30cdff920718696c jdk7-b46
167ad0164301f318b069a947e1c9c07ed667748a jdk7-b47

View File

@ -21,3 +21,4 @@ fc6a5ae3fef5ebacfa896dbb3ae37715e388e282 jdk7-b43
809e899c638bd9b21836abf9d09ab2a30ff3900b jdk7-b44
945bf754069766e76873c53102fae48abf04cf5b jdk7-b45
16bb38eeda35b46268eefa4c1f829eb086e0ca46 jdk7-b46
fcb923bad68e2b10380a030ea83a723f4dc3d4d6 jdk7-b47

View File

@ -21,3 +21,4 @@ e9f750f0a3a00413a7b77028b2ecdabb7129ae32 jdk7-b38
b203df0741af3eb08687bc5eb798bac87363758d jdk7-b44
0f113667880d335cfa2c35721b1b45144fb757f5 jdk7-b45
b2271877894af809b7703767fe8d4e38591a02a2 jdk7-b46
d711ad1954b294957737ea386cfd4d3c05028a36 jdk7-b47

View File

@ -21,3 +21,4 @@ cc5f810b5af8a3a83b0df5a29d9e24d7a0ff8086 jdk7-b38
d8eb2738db6b148911177d9bcfe888109b7f2f71 jdk7-b44
527b426497a259d0605d069e3930e838948531a6 jdk7-b45
4b03e27a44090d1f646af28dc58f9ead827e24c7 jdk7-b46
b4ac413b1f129eeef0acab3f31081c1b7dfe3b27 jdk7-b47

View File

@ -153,7 +153,6 @@ FILES_cpp = \
awt_Menu.cpp \
awt_MenuBar.cpp \
awt_MenuItem.cpp \
awt_MMStub.cpp \
awt_MouseEvent.cpp \
awt_Object.cpp \
awt_Palette.cpp \
@ -171,7 +170,6 @@ FILES_cpp = \
awt_TextComponent.cpp \
awt_TextField.cpp \
awt_Toolkit.cpp \
awt_Unicode.cpp \
awt_Window.cpp \
awt_Win32GraphicsEnv.cpp \
awt_Win32GraphicsDevice.cpp \
@ -202,6 +200,4 @@ FILES_cpp = \
ThemeReader.cpp \
ComCtl32Util.cpp \
initIDs.cpp \
awt_dlls.cpp \
UnicowsLoader.cpp \
MouseInfo.cpp

View File

@ -47,7 +47,7 @@ OTHER_CFLAGS += -D__MEDIALIB_OLD_NAMES -D__USE_J2D_NAMES
# sun/awt/resources handled by java/awt/Makefile
# sun/java2d/pisces handled by sun/pisces/Makefile
#
AUTO_FILES_JAVA_DIRS = sun/awt sun/java2d
AUTO_FILES_JAVA_DIRS = sun/awt sun/java2d com/sun/awt
AUTO_JAVA_PRUNE = resources pisces
ifeq ($(PLATFORM), windows)
@ -247,8 +247,14 @@ endif # PLATFORM
ifeq ($(PLATFORM), windows)
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv WINDOWS
OTHER_LDLIBS = kernel32.lib user32.lib gdi32.lib winspool.lib \
imm32.lib ole32.lib uuid.lib $(JVMLIB) \
shell32.lib
imm32.lib ole32.lib uuid.lib shell32.lib \
comdlg32.lib winmm.lib comctl32.lib delayimp.lib \
$(JVMLIB) \
/DELAYLOAD:user32.dll /DELAYLOAD:gdi32.dll \
/DELAYLOAD:shell32.dll /DELAYLOAD:winmm.dll \
/DELAYLOAD:winspool.drv /DELAYLOAD:imm32.dll \
/DELAYLOAD:ole32.dll /DELAYLOAD:comdlg32.dll \
/DELAYLOAD:comctl32.dll
clean:: awt.clean

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
$(OBJDIR)/jawt.obj:: $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_AWTEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Component.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Dimension.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Event.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Font.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_PlatformFont.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WToolkit.h ../../../src/share/javavm/export/jawt.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jawt_md.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/UnicowsLoader.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_DrawingSurface.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_MMStub.h ../../../src/windows/native/sun/windows/awt_Multimon.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Unicode.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/stdhdrs.h
$(OBJDIR)/jawt.obj:: $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_AWTEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Component.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Dimension.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Event.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Font.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_PlatformFont.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WToolkit.h ../../../src/share/javavm/export/jawt.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jawt_md.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_DrawingSurface.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/stdhdrs.h

View File

@ -67,7 +67,7 @@ ifneq ($(PLATFORM), windows)
OTHER_LDLIBS += -L$(OPENWIN_LIB) -lX11 -lXext $(LIBM) -lpthread
else # PLATFORM
CFLAGS += -DWITH_WIN32
OTHER_LDLIBS += kernel32.lib user32.lib gdi32.lib
OTHER_LDLIBS += kernel32.lib user32.lib gdi32.lib delayimp.lib /DELAYLOAD:user32.dll
#$(JVMLIB) $(OBJDIR)/../../jpeg/$(OBJDIRNAME)/jpeg$(SUFFIX).lib
endif # PLATFORM
@ -85,13 +85,6 @@ vpath %.c $(PLATFORM_SRC)/native/$(PKGDIR)/splashscreen
CPPFLAGS += -I$(PLATFORM_SRC)/native/$(PKGDIR)/splashscreen -I$(SHARE_SRC)/native/$(PKGDIR)/splashscreen
CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/image/jpeg -I$(SHARE_SRC)/native/java/util/zip/zlib-1.1.3
ifeq ($(PLATFORM), linux)
ifeq ($(ARCH_DATA_MODEL), 64)
# 64-bit gcc has problems compiling MMX instructions.
# Google it for more details. Possibly the newer versions of
# the PNG-library and/or the new compiler will not need this
# option in the future.
CPPFLAGS += -DPNG_NO_MMX_CODE
endif
endif
# Shun the less than portable MMX assembly code in pnggccrd.c,
# and use alternative implementations in C.
CPPFLAGS += -DPNG_NO_MMX_CODE

View File

@ -151,6 +151,7 @@ SUNWprivate_1.1 {
Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl;
Java_sun_awt_X11_XRobotPeer_mouseWheelImpl;
Java_sun_awt_X11_XRobotPeer_setup;
Java_sun_awt_X11_XRobotPeer_getNumberOfButtonsImpl;
Java_java_awt_Component_initIDs;
Java_java_awt_Container_initIDs;
Java_java_awt_Button_initIDs;
@ -288,6 +289,7 @@ SUNWprivate_1.1 {
Java_sun_awt_X11_XlibWrapper_XGetIconSizes;
Java_sun_awt_X11_XlibWrapper_XKeycodeToKeysym;
Java_sun_awt_X11_XlibWrapper_XKeysymToKeycode;
Java_sun_awt_X11_XlibWrapper_XQueryKeymap;
Java_sun_awt_X11_XlibWrapper_XGetModifierMapping;
Java_sun_awt_X11_XlibWrapper_XFreeModifiermap;
Java_sun_awt_X11_XlibWrapper_XChangeActivePointerGrab;

View File

@ -1718,6 +1718,7 @@ javax/swing/plaf/basic/BasicToolBarSeparatorUI
sun/awt/color/CMM
java/applet/Applet
java/awt/Panel
com/sun/awt/AWTUtilities
javax/swing/KeyboardManager$ComponentKeyStrokePair
sun/awt/EmbeddedFrame
sun/awt/im/InputMethodContext

View File

@ -961,6 +961,7 @@ sun/awt/SunToolkit$3
javax/swing/SystemEventQueueUtilities$ComponentWorkRequest
java/applet/Applet
java/awt/Panel
com/sun/awt/AWTUtilities
sun/awt/X11/XExposeEvent
java/util/jar/Manifest
java/io/ByteArrayInputStream

View File

@ -1621,6 +1621,7 @@ javax/swing/plaf/basic/BasicToolBarSeparatorUI
sun/font/FontDesignMetrics$MetricsKey
java/applet/Applet
java/awt/Panel
com/sun/awt/AWTUtilities
javax/swing/KeyboardManager$ComponentKeyStrokePair
sun/awt/im/InputMethodContext
java/awt/im/spi/InputMethodContext

View File

@ -0,0 +1,104 @@
/*
* Copyright 2009 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package com.sun.awt;
import java.awt.*;
import sun.awt.AWTAccessor;
/**
* A collection of utility methods for AWT.
*
* The functionality provided by the static methods of the class includes:
* <ul>
* <li>Setting a 'mixing-cutout' shape for a component.
* </ul>
* <p>
* <b>WARNING</b>: This class is an implementation detail and only meant
* for limited use outside of the core platform. This API may change
* drastically between update release, and it may even be
* removed or be moved in some other package(s)/class(es).
*/
public final class AWTUtilities {
/**
* The AWTUtilities class should not be instantiated
*/
private AWTUtilities() {
}
/**
* Sets a 'mixing-cutout' shape for the given component.
*
* By default a lightweight component is treated as an opaque rectangle for
* the purposes of the Heavyweight/Lightweight Components Mixing feature.
* This method enables developers to set an arbitrary shape to be cut out
* from heavyweight components positioned underneath the lightweight
* component in the z-order.
* <p>
* The {@code shape} argument may have the following values:
* <ul>
* <li>{@code null} - reverts the default cutout shape (the rectangle equal
* to the component's {@code getBounds()})
* <li><i>empty-shape</i> - does not cut out anything from heavyweight
* components. This makes the given lightweight component effectively
* transparent. Note that descendants of the lightweight component still
* affect the shapes of heavyweight components. An example of an
* <i>empty-shape</i> is {@code new Rectangle()}.
* <li><i>non-empty-shape</i> - the given shape will be cut out from
* heavyweight components.
* </ul>
* <p>
* The most common example when the 'mixing-cutout' shape is needed is a
* glass pane component. The {@link JRootPane#setGlassPane()} method
* automatically sets the <i>empty-shape</i> as the 'mixing-cutout' shape
* for the given glass pane component. If a developer needs some other
* 'mixing-cutout' shape for the glass pane (which is rare), this must be
* changed manually after installing the glass pane to the root pane.
* <p>
* Note that the 'mixing-cutout' shape neither affects painting, nor the
* mouse events handling for the given component. It is used exclusively
* for the purposes of the Heavyweight/Lightweight Components Mixing
* feature.
*
* @param component the component that needs non-default
* 'mixing-cutout' shape
* @param shape the new 'mixing-cutout' shape
* @throws NullPointerException if the component argument is {@code null}
*/
public static void setComponentMixingCutoutShape(Component component,
Shape shape)
{
if (component == null) {
throw new NullPointerException(
"The component argument should not be null.");
}
AWTAccessor.getComponentAccessor().setMixingCutoutShape(component,
shape);
}
}

View File

@ -228,7 +228,7 @@ public class Choice extends Component implements ItemSelectable, Accessible {
pItems.insertElementAt(item, index);
ChoicePeer peer = (ChoicePeer)this.peer;
if (peer != null) {
peer.addItem(item, index);
peer.add(item, index);
}
// no selection or selection shifted up
if (selectedIndex < 0 || selectedIndex >= index) {

View File

@ -65,8 +65,10 @@ import java.applet.Applet;
import sun.security.action.GetPropertyAction;
import sun.awt.AppContext;
import sun.awt.AWTAccessor;
import sun.awt.ConstrainableGraphics;
import sun.awt.SubRegionShowable;
import sun.awt.SunToolkit;
import sun.awt.WindowClosingListener;
import sun.awt.CausedFocusEvent;
import sun.awt.EmbeddedFrame;
@ -758,22 +760,26 @@ public abstract class Component implements ImageObserver, MenuContainer,
* The shape set with the applyCompoundShape() method. It uncludes the result
* of the HW/LW mixing related shape computation. It may also include
* the user-specified shape of the component.
* The 'null' value means the component has normal shape (or has no shape at all)
* and applyCompoundShape() will skip the following shape identical to normal.
*/
private transient Region compoundShape = null;
/*
* Represents the shape of this lightweight component to be cut out from
* heavyweight components should they intersect. Possible values:
* 1. null - consider the shape rectangular
* 2. EMPTY_REGION - nothing gets cut out (children still get cut out)
* 3. non-empty - this shape gets cut out.
*/
private transient Region mixingCutoutRegion = null;
/*
* Indicates whether addNotify() is complete
* (i.e. the peer is created).
*/
private transient boolean isAddNotifyComplete = false;
private static final PropertyChangeListener opaquePropertyChangeListener =
new PropertyChangeListener() {
public void propertyChange(java.beans.PropertyChangeEvent evt) {
((Component)evt.getSource()).mixOnOpaqueChanging();
}
};
/**
* Should only be used in subclass getBounds to check that part of bounds
* is actualy changing
@ -793,6 +799,39 @@ public abstract class Component implements ImageObserver, MenuContainer,
}
}
static {
AWTAccessor.setComponentAccessor(new AWTAccessor.ComponentAccessor() {
public void setMixingCutoutShape(Component comp, Shape shape) {
Region region = shape == null ? null :
Region.getInstance(shape, null);
synchronized (comp.getTreeLock()) {
boolean needShowing = false;
boolean needHiding = false;
if (!comp.isNonOpaqueForMixing()) {
needHiding = true;
}
comp.mixingCutoutRegion = region;
if (!comp.isNonOpaqueForMixing()) {
needShowing = true;
}
if (comp.isMixingNeeded()) {
if (needHiding) {
comp.mixOnHiding(comp.isLightweight());
}
if (needShowing) {
comp.mixOnShowing();
}
}
}
}
});
}
/**
* Constructs a new component. Class <code>Component</code> can be
* extended directly to create a lightweight component that does not
@ -1306,7 +1345,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
enabled = true;
ComponentPeer peer = this.peer;
if (peer != null) {
peer.enable();
peer.setEnabled(true);
if (visible) {
updateCursorImmediately();
}
@ -1355,7 +1394,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
}
ComponentPeer peer = this.peer;
if (peer != null) {
peer.disable();
peer.setEnabled(false);
if (visible) {
updateCursorImmediately();
}
@ -1447,7 +1486,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
mixOnShowing();
ComponentPeer peer = this.peer;
if (peer != null) {
peer.show();
peer.setVisible(true);
createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED,
this, parent,
HierarchyEvent.SHOWING_CHANGED,
@ -1517,7 +1556,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
}
ComponentPeer peer = this.peer;
if (peer != null) {
peer.hide();
peer.setVisible(false);
createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED,
this, parent,
HierarchyEvent.SHOWING_CHANGED,
@ -2414,7 +2453,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
if (dim == null || !(isPreferredSizeSet() || isValid())) {
synchronized (getTreeLock()) {
prefSize = (peer != null) ?
peer.preferredSize() :
peer.getPreferredSize() :
getMinimumSize();
dim = prefSize;
}
@ -2484,7 +2523,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
if (dim == null || !(isMinimumSizeSet() || isValid())) {
synchronized (getTreeLock()) {
minSize = (peer != null) ?
peer.minimumSize() :
peer.getMinimumSize() :
size();
dim = minSize;
}
@ -3171,7 +3210,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
private Insets getInsets_NoClientCode() {
ComponentPeer peer = this.peer;
if (peer instanceof ContainerPeer) {
return (Insets)((ContainerPeer)peer).insets().clone();
return (Insets)((ContainerPeer)peer).getInsets().clone();
}
return new Insets(0, 0, 0, 0);
}
@ -6643,7 +6682,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
}
if (!isAddNotifyComplete) {
addPropertyChangeListener("opaque", opaquePropertyChangeListener);
mixOnShowing();
}
@ -6722,7 +6760,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
// Hide peer first to stop system events such as cursor moves.
if (visible) {
p.hide();
p.setVisible(false);
}
peer = null; // Stop peer updates.
@ -6735,9 +6773,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
p.dispose();
mixOnHiding(isLightweight);
removePropertyChangeListener("opaque", opaquePropertyChangeListener);
isAddNotifyComplete = false;
// Nullifying compoundShape means that the component has normal shape
// (or has no shape at all).
this.compoundShape = null;
}
if (hierarchyListener != null ||
@ -9401,10 +9441,9 @@ public abstract class Component implements ImageObserver, MenuContainer,
* Null-layout of the container or absence of the container mean
* the bounds of the component are final and can be trusted.
*/
private boolean areBoundsValid() {
final boolean areBoundsValid() {
Container cont = getContainer();
return cont == null || cont.isValid()
|| cont.getLayout() == null;
return cont == null || cont.isValid() || cont.getLayout() == null;
}
/**
@ -9413,6 +9452,14 @@ public abstract class Component implements ImageObserver, MenuContainer,
*/
void applyCompoundShape(Region shape) {
checkTreeLock();
if (!areBoundsValid()) {
if (mixingLog.isLoggable(Level.FINE)) {
mixingLog.fine("this = " + this + "; areBoundsValid = " + areBoundsValid());
}
return;
}
if (!isLightweight()) {
ComponentPeer peer = getPeer();
if (peer != null) {
@ -9422,22 +9469,31 @@ public abstract class Component implements ImageObserver, MenuContainer,
// with some incorrect Region object with loX being
// greater than the hiX for instance.
if (shape.isEmpty()) {
shape = Region.getInstanceXYWH(0, 0, 0, 0);
shape = Region.EMPTY_REGION;
}
// Note: the shape is not really copied/cloned. We create
// the Region object ourselves, so there's no any possibility
// to modify the object outside of the mixing code.
this.compoundShape = shape;
if (areBoundsValid()) {
// Nullifying compoundShape means that the component has normal shape
// (or has no shape at all).
if (shape.equals(getNormalShape())) {
if (this.compoundShape == null) {
return;
}
this.compoundShape = null;
peer.applyShape(null);
} else {
if (shape.equals(getAppliedShape())) {
return;
}
this.compoundShape = shape;
Point compAbsolute = getLocationOnWindow();
if (mixingLog.isLoggable(Level.FINER)) {
mixingLog.fine("this = " + this +
"; compAbsolute=" + compAbsolute + "; shape=" + shape);
"; compAbsolute=" + compAbsolute + "; shape=" + shape);
}
peer.applyShape(shape.getTranslatedRegion(-compAbsolute.x, -compAbsolute.y));
}
}
@ -9460,7 +9516,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
Point curLocation = getLocation();
for (Container parent = getContainer();
parent != null;
parent != null && !(parent instanceof Window);
parent = parent.getContainer())
{
curLocation.x += parent.getX();
@ -9486,7 +9542,28 @@ public abstract class Component implements ImageObserver, MenuContainer,
);
}
private int getSiblingIndexAbove() {
/**
* Returns the "opaque shape" of the component.
*
* The opaque shape of a lightweight components is the actual shape that
* needs to be cut off of the heavyweight components in order to mix this
* lightweight component correctly with them.
*
* The method is overriden in the java.awt.Container to handle non-opaque
* containers containing opaque children.
*
* See 6637655 for details.
*/
Region getOpaqueShape() {
checkTreeLock();
if (mixingCutoutRegion != null) {
return mixingCutoutRegion;
} else {
return getNormalShape();
}
}
final int getSiblingIndexAbove() {
checkTreeLock();
Container parent = getContainer();
if (parent == null) {
@ -9498,7 +9575,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
return nextAbove < 0 ? -1 : nextAbove;
}
private int getSiblingIndexBelow() {
final int getSiblingIndexBelow() {
checkTreeLock();
Container parent = getContainer();
if (parent == null) {
@ -9510,6 +9587,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
return nextBelow >= parent.getComponentCount() ? -1 : nextBelow;
}
final boolean isNonOpaqueForMixing() {
return mixingCutoutRegion != null &&
mixingCutoutRegion.isEmpty();
}
private Region calculateCurrentShape() {
checkTreeLock();
Region s = getNormalShape();
@ -9532,8 +9614,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
* implementation of the Container class.
*/
Component c = cont.getComponent(index);
if (c.isLightweight() && c.isShowing() && c.isOpaque()) {
s = s.getDifference(c.getNormalShape());
if (c.isLightweight() && c.isShowing()) {
s = s.getDifference(c.getOpaqueShape());
}
}
@ -9558,6 +9640,9 @@ public abstract class Component implements ImageObserver, MenuContainer,
void applyCurrentShape() {
checkTreeLock();
if (!areBoundsValid()) {
if (mixingLog.isLoggable(Level.FINE)) {
mixingLog.fine("this = " + this + "; areBoundsValid = " + areBoundsValid());
}
return; // Because applyCompoundShape() ignores such components anyway
}
if (mixingLog.isLoggable(Level.FINE)) {
@ -9576,16 +9661,54 @@ public abstract class Component implements ImageObserver, MenuContainer,
applyCompoundShape(getAppliedShape().getDifference(s));
}
private final void applyCurrentShapeBelowMe() {
checkTreeLock();
Container parent = getContainer();
if (parent != null && parent.isShowing()) {
// First, reapply shapes of my siblings
parent.recursiveApplyCurrentShape(getSiblingIndexBelow());
// Second, if my container is non-opaque, reapply shapes of siblings of my container
Container parent2 = parent.getContainer();
while (!parent.isOpaque() && parent2 != null) {
parent2.recursiveApplyCurrentShape(parent.getSiblingIndexBelow());
parent = parent2;
parent2 = parent.getContainer();
}
}
}
final void subtractAndApplyShapeBelowMe() {
checkTreeLock();
Container parent = getContainer();
if (parent != null && isShowing()) {
Region opaqueShape = getOpaqueShape();
// First, cut my siblings
parent.recursiveSubtractAndApplyShape(opaqueShape, getSiblingIndexBelow());
// Second, if my container is non-opaque, cut siblings of my container
Container parent2 = parent.getContainer();
while (!parent.isOpaque() && parent2 != null) {
parent2.recursiveSubtractAndApplyShape(opaqueShape, parent.getSiblingIndexBelow());
parent = parent2;
parent2 = parent.getContainer();
}
}
}
void mixOnShowing() {
synchronized (getTreeLock()) {
if (mixingLog.isLoggable(Level.FINE)) {
mixingLog.fine("this = " + this);
}
if (!isMixingNeeded()) {
return;
}
if (isLightweight()) {
Container parent = getContainer();
if (parent != null && isShowing() && isOpaque()) {
parent.recursiveSubtractAndApplyShape(getNormalShape(), getSiblingIndexBelow());
}
subtractAndApplyShapeBelowMe();
} else {
applyCurrentShape();
}
@ -9599,12 +9722,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
if (mixingLog.isLoggable(Level.FINE)) {
mixingLog.fine("this = " + this + "; isLightweight = " + isLightweight);
}
if (!isMixingNeeded()) {
return;
}
if (isLightweight) {
Container parent = getContainer();
if (parent != null) {
parent.recursiveApplyCurrentShape(getSiblingIndexBelow());
}
} //XXX: else applyNormalShape() ???
applyCurrentShapeBelowMe();
}
}
}
@ -9613,11 +9736,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
if (mixingLog.isLoggable(Level.FINE)) {
mixingLog.fine("this = " + this);
}
if (!isMixingNeeded()) {
return;
}
if (isLightweight()) {
Container parent = getContainer();
if (parent != null) {
parent.recursiveApplyCurrentShape(parent.getComponentZOrder(this));
}
applyCurrentShapeBelowMe();
} else {
applyCurrentShape();
}
@ -9633,11 +9756,13 @@ public abstract class Component implements ImageObserver, MenuContainer,
mixingLog.fine("this = " + this +
"; oldZorder=" + oldZorder + "; newZorder=" + newZorder + "; parent=" + parent);
}
if (!isMixingNeeded()) {
return;
}
if (isLightweight()) {
if (becameHigher) {
if (parent != null && isShowing() && isOpaque()) {
parent.recursiveSubtractAndApplyShape(getNormalShape(), getSiblingIndexBelow(), oldZorder);
if (parent != null && isShowing()) {
parent.recursiveSubtractAndApplyShape(getOpaqueShape(), getSiblingIndexBelow(), oldZorder);
}
} else {
if (parent != null) {
@ -9653,8 +9778,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
for (int index = oldZorder; index < newZorder; index++) {
Component c = parent.getComponent(index);
if (c.isLightweight() && c.isShowing() && c.isOpaque()) {
shape = shape.getDifference(c.getNormalShape());
if (c.isLightweight() && c.isShowing()) {
shape = shape.getDifference(c.getOpaqueShape());
}
}
applyCompoundShape(shape);
@ -9664,21 +9789,42 @@ public abstract class Component implements ImageObserver, MenuContainer,
}
}
void mixOnOpaqueChanging() {
if (mixingLog.isLoggable(Level.FINE)) {
mixingLog.fine("this = " + this);
}
if (isOpaque()) {
mixOnShowing();
} else {
mixOnHiding(isLightweight());
}
}
void mixOnValidating() {
// This method gets overriden in the Container. Obviously, a plain
// non-container components don't need to handle validation.
}
final boolean isMixingNeeded() {
if (SunToolkit.getSunAwtDisableMixing()) {
if (mixingLog.isLoggable(Level.FINEST)) {
mixingLog.finest("this = " + this + "; Mixing disabled via sun.awt.disableMixing");
}
return false;
}
if (!areBoundsValid()) {
if (mixingLog.isLoggable(Level.FINE)) {
mixingLog.fine("this = " + this + "; areBoundsValid = " + areBoundsValid());
}
return false;
}
Window window = getContainingWindow();
if (window != null) {
if (!window.hasHeavyweightDescendants() || !window.hasLightweightDescendants()) {
if (mixingLog.isLoggable(Level.FINE)) {
mixingLog.fine("containing window = " + window +
"; has h/w descendants = " + window.hasHeavyweightDescendants() +
"; has l/w descendants = " + window.hasLightweightDescendants());
}
return false;
}
} else {
if (mixingLog.isLoggable(Level.FINE)) {
mixingLog.finest("this = " + this + "; containing window is null");
}
return false;
}
return true;
}
// ****************** END OF MIXING CODE ********************************
}

View File

@ -343,7 +343,7 @@ public class Container extends Component {
ComponentPeer peer = this.peer;
if (peer instanceof ContainerPeer) {
ContainerPeer cpeer = (ContainerPeer)peer;
return (Insets)cpeer.insets().clone();
return (Insets)cpeer.getInsets().clone();
}
return new Insets(0, 0, 0, 0);
}
@ -569,7 +569,7 @@ public class Container extends Component {
* @return true if there is at least one heavyweight children in a container, false otherwise
* @since 1.5
*/
private boolean hasHeavyweightDescendants() {
final boolean hasHeavyweightDescendants() {
checkTreeLock();
return numOfHWComponents > 0;
}
@ -580,7 +580,7 @@ public class Container extends Component {
* @return true if there is at least one lightweight children in a container, false otherwise
* @since 1.7
*/
private boolean hasLightweightDescendants() {
final boolean hasLightweightDescendants() {
checkTreeLock();
return numOfLWComponents > 0;
}
@ -3861,6 +3861,28 @@ public class Container extends Component {
return -1;
}
/*
* This method is overriden to handle opaque children in non-opaque
* containers.
*/
@Override
final Region getOpaqueShape() {
checkTreeLock();
if (isLightweight() && isNonOpaqueForMixing()
&& hasLightweightDescendants())
{
Region s = Region.EMPTY_REGION;
for (int index = 0; index < getComponentCount(); index++) {
Component c = getComponent(index);
if (c.isLightweight() && c.isShowing()) {
s = s.getUnion(c.getOpaqueShape());
}
}
return s.getIntersection(getNormalShape());
}
return super.getOpaqueShape();
}
final void recursiveSubtractAndApplyShape(Region shape) {
recursiveSubtractAndApplyShape(shape, getTopmostComponentIndex(), getBottommostComponentIndex());
}
@ -3878,6 +3900,15 @@ public class Container extends Component {
if (fromZorder == -1) {
return;
}
if (shape.isEmpty()) {
return;
}
// An invalid container with not-null layout should be ignored
// by the mixing code, the container will be validated later
// and the mixing code will be executed later.
if (getLayout() != null && !isValid()) {
return;
}
for (int index = fromZorder; index <= toZorder; index++) {
Component comp = getComponent(index);
if (!comp.isLightweight()) {
@ -3906,10 +3937,19 @@ public class Container extends Component {
if (fromZorder == -1) {
return;
}
// An invalid container with not-null layout should be ignored
// by the mixing code, the container will be validated later
// and the mixing code will be executed later.
if (getLayout() != null && !isValid()) {
return;
}
for (int index = fromZorder; index <= toZorder; index++) {
Component comp = getComponent(index);
if (!comp.isLightweight()) {
comp.applyCurrentShape();
if (comp instanceof Container && ((Container)comp).getLayout() == null) {
((Container)comp).recursiveApplyCurrentShape();
}
} else if (comp instanceof Container &&
((Container)comp).hasHeavyweightDescendants()) {
((Container)comp).recursiveApplyCurrentShape();
@ -3931,7 +3971,7 @@ public class Container extends Component {
if (comp.isVisible()) {
ComponentPeer peer = comp.getPeer();
if (peer != null) {
peer.show();
peer.setVisible(true);
}
}
}
@ -3952,7 +3992,7 @@ public class Container extends Component {
if (comp.isVisible()) {
ComponentPeer peer = comp.getPeer();
if (peer != null) {
peer.hide();
peer.setVisible(false);
}
}
}
@ -4000,6 +4040,10 @@ public class Container extends Component {
mixingLog.fine("this = " + this);
}
if (!isMixingNeeded()) {
return;
}
boolean isLightweight = isLightweight();
if (isLightweight && isRecursivelyVisibleUpToHeavyweightContainer()) {
@ -4034,6 +4078,9 @@ public class Container extends Component {
if (mixingLog.isLoggable(Level.FINE)) {
mixingLog.fine("this = " + this);
}
boolean isMixingNeeded = isMixingNeeded();
if (isLightweight() && hasHeavyweightDescendants()) {
final Point origin = new Point(getX(), getY());
for (Container cont = getContainer();
@ -4044,7 +4091,18 @@ public class Container extends Component {
}
recursiveRelocateHeavyweightChildren(origin);
if (!isMixingNeeded) {
return;
}
recursiveApplyCurrentShape();
}
if (!isMixingNeeded) {
return;
}
super.mixOnReshaping();
}
}
@ -4057,6 +4115,10 @@ public class Container extends Component {
"; oldZ=" + oldZorder + "; newZ=" + newZorder);
}
if (!isMixingNeeded()) {
return;
}
boolean becameHigher = newZorder < oldZorder;
if (becameHigher && isLightweight() && hasHeavyweightDescendants()) {
@ -4073,10 +4135,18 @@ public class Container extends Component {
mixingLog.fine("this = " + this);
}
if (!isMixingNeeded()) {
return;
}
if (hasHeavyweightDescendants()) {
recursiveApplyCurrentShape();
}
if (isLightweight() && isNonOpaqueForMixing()) {
subtractAndApplyShapeBelowMe();
}
super.mixOnValidating();
}
}

View File

@ -941,7 +941,7 @@ public class Dialog extends Window {
// does not invoke the super.show(). So wried... :(
mixOnShowing();
peer.show(); // now guaranteed never to block
peer.setVisible(true); // now guaranteed never to block
if (isModalBlocked()) {
modalBlocker.toFront();
}

View File

@ -300,119 +300,19 @@ class EventDispatchThread extends Thread {
}
// Can get and throw only unchecked exceptions
catch (RuntimeException e) {
processException(e, modalFiltersCount > 0);
processException(e);
} catch (Error e) {
processException(e, modalFiltersCount > 0);
processException(e);
}
return true;
}
private void processException(Throwable e, boolean isModal) {
private void processException(Throwable e) {
if (eventLog.isLoggable(Level.FINE)) {
eventLog.log(Level.FINE, "Processing exception: " + e +
", isModal = " + isModal);
eventLog.log(Level.FINE, "Processing exception: " + e);
}
if (!handleException(e)) {
// See bug ID 4499199.
// If we are in a modal dialog, we cannot throw
// an exception for the ThreadGroup to handle (as added
// in RFE 4063022). If we did, the message pump of
// the modal dialog would be interrupted.
// We instead choose to handle the exception ourselves.
// It may be useful to add either a runtime flag or API
// later if someone would like to instead dispose the
// dialog and allow the thread group to handle it.
if (isModal) {
System.err.println(
"Exception occurred during event dispatching:");
e.printStackTrace();
} else if (e instanceof RuntimeException) {
throw (RuntimeException)e;
} else if (e instanceof Error) {
throw (Error)e;
}
}
}
private static final String handlerPropName = "sun.awt.exception.handler";
private static String handlerClassName = null;
private static String NO_HANDLER = new String();
/**
* Handles an exception thrown in the event-dispatch thread.
*
* <p> If the system property "sun.awt.exception.handler" is defined, then
* when this method is invoked it will attempt to do the following:
*
* <ol>
* <li> Load the class named by the value of that property, using the
* current thread's context class loader,
* <li> Instantiate that class using its zero-argument constructor,
* <li> Find the resulting handler object's <tt>public void handle</tt>
* method, which should take a single argument of type
* <tt>Throwable</tt>, and
* <li> Invoke the handler's <tt>handle</tt> method, passing it the
* <tt>thrown</tt> argument that was passed to this method.
* </ol>
*
* If any of the first three steps fail then this method will return
* <tt>false</tt> and all following invocations of this method will return
* <tt>false</tt> immediately. An exception thrown by the handler object's
* <tt>handle</tt> will be caught, and will cause this method to return
* <tt>false</tt>. If the handler's <tt>handle</tt> method is successfully
* invoked, then this method will return <tt>true</tt>. This method will
* never throw any sort of exception.
*
* <p> <i>Note:</i> This method is a temporary hack to work around the
* absence of a real API that provides the ability to replace the
* event-dispatch thread. The magic "sun.awt.exception.handler" property
* <i>will be removed</i> in a future release.
*
* @param thrown The Throwable that was thrown in the event-dispatch
* thread
*
* @return <tt>false</tt> if any of the above steps failed, otherwise
* <tt>true</tt>
*/
private boolean handleException(Throwable thrown) {
try {
if (handlerClassName == NO_HANDLER) {
return false; /* Already tried, and failed */
}
/* Look up the class name */
if (handlerClassName == null) {
handlerClassName = ((String) AccessController.doPrivileged(
new GetPropertyAction(handlerPropName)));
if (handlerClassName == null) {
handlerClassName = NO_HANDLER; /* Do not try this again */
return false;
}
}
/* Load the class, instantiate it, and find its handle method */
Method m;
Object h;
try {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Class c = Class.forName(handlerClassName, true, cl);
m = c.getMethod("handle", new Class[] { Throwable.class });
h = c.newInstance();
} catch (Throwable x) {
handlerClassName = NO_HANDLER; /* Do not try this again */
return false;
}
/* Finally, invoke the handler */
m.invoke(h, new Object[] { thrown });
} catch (Throwable x) {
return false;
}
return true;
getUncaughtExceptionHandler().uncaughtException(this, e);
// don't rethrow the exception to avoid EDT recreation
}
boolean isDispatching(EventQueue eq) {

View File

@ -378,7 +378,7 @@ public class List extends Component implements ItemSelectable, Accessible {
ListPeer peer = (ListPeer)this.peer;
if (peer != null) {
peer.addItem(item, index);
peer.add(item, index);
}
}
@ -413,7 +413,7 @@ public class List extends Component implements ItemSelectable, Accessible {
public synchronized void clear() {
ListPeer peer = (ListPeer)this.peer;
if (peer != null) {
peer.clear();
peer.removeAll();
}
items = new Vector();
selected = new int[0];
@ -718,7 +718,7 @@ public class List extends Component implements ItemSelectable, Accessible {
multipleMode = b;
ListPeer peer = (ListPeer)this.peer;
if (peer != null) {
peer.setMultipleSelections(b);
peer.setMultipleMode(b);
}
}
}
@ -768,7 +768,7 @@ public class List extends Component implements ItemSelectable, Accessible {
synchronized (getTreeLock()) {
ListPeer peer = (ListPeer)this.peer;
return (peer != null) ?
peer.preferredSize(rows) :
peer.getPreferredSize(rows) :
super.preferredSize();
}
}
@ -818,7 +818,7 @@ public class List extends Component implements ItemSelectable, Accessible {
synchronized (getTreeLock()) {
ListPeer peer = (ListPeer)this.peer;
return (peer != null) ?
peer.minimumSize(rows) :
peer.getMinimumSize(rows) :
super.minimumSize();
}
}

View File

@ -268,7 +268,7 @@ public class MenuItem extends MenuComponent implements Accessible {
enabled = true;
MenuItemPeer peer = (MenuItemPeer)this.peer;
if (peer != null) {
peer.enable();
peer.setEnabled(true);
}
}
@ -294,7 +294,7 @@ public class MenuItem extends MenuComponent implements Accessible {
enabled = false;
MenuItemPeer peer = (MenuItemPeer)this.peer;
if (peer != null) {
peer.disable();
peer.setEnabled(false);
}
}

View File

@ -70,10 +70,7 @@ public class Robot {
private RobotPeer peer;
private boolean isAutoWaitForIdle = false;
private int autoDelay = 0;
private static final int LEGAL_BUTTON_MASK =
InputEvent.BUTTON1_MASK|
InputEvent.BUTTON2_MASK|
InputEvent.BUTTON3_MASK;
private static int LEGAL_BUTTON_MASK;
// location of robot's GC, used in mouseMove(), getPixelColor() and captureScreenImage()
private Point gdLoc;
@ -98,6 +95,19 @@ public class Robot {
}
init(GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice());
int tmpMask = 0;
if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
for (int i = 0; i < peer.getNumberOfButtons(); i++){
tmpMask |= InputEvent.getMaskForButton(i+1);
}
}
tmpMask |= InputEvent.BUTTON1_MASK|
InputEvent.BUTTON2_MASK|
InputEvent.BUTTON3_MASK|
InputEvent.BUTTON1_DOWN_MASK|
InputEvent.BUTTON2_DOWN_MASK|
InputEvent.BUTTON3_DOWN_MASK;
LEGAL_BUTTON_MASK = tmpMask;
}
/**
@ -187,18 +197,55 @@ public class Robot {
/**
* Presses one or more mouse buttons. The mouse buttons should
* be released using the <code>mouseRelease</code> method.
* be released using the {@link #mouseRelease(int)} method.
*
* @param buttons the Button mask; a combination of one or more
* of these flags:
* @param buttons the Button mask; a combination of one or more
* mouse button masks.
* <p>
* It is allowed to use only a combination of valid values as a {@code buttons} parameter.
* A valid combination consists of {@code InputEvent.BUTTON1_DOWN_MASK},
* {@code InputEvent.BUTTON2_DOWN_MASK}, {@code InputEvent.BUTTON3_DOWN_MASK}
* and values returned by the
* {@link InputEvent#getMaskForButton(int) InputEvent.getMaskForButton(button)} method.
*
* The valid combination also depends on a
* {@link Toolkit#areExtraMouseButtonsEnabled() Toolkit.areExtraMouseButtonsEnabled()} value as follows:
* <ul>
* <li><code>InputEvent.BUTTON1_MASK</code>
* <li><code>InputEvent.BUTTON2_MASK</code>
* <li><code>InputEvent.BUTTON3_MASK</code>
* <li> If support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* then it is allowed to use only the following standard button masks:
* {@code InputEvent.BUTTON1_DOWN_MASK}, {@code InputEvent.BUTTON2_DOWN_MASK},
* {@code InputEvent.BUTTON3_DOWN_MASK}.
* <li> If support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
* then it is allowed to use the standard button masks
* and masks for existing extended mouse buttons, if the mouse has more then three buttons.
* In that way, it is allowed to use the button masks corresponding to the buttons
* in the range from 1 to {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}.
* <br>
* It is recommended to use the {@link InputEvent#getMaskForButton(int) InputEvent.getMaskForButton(button)}
* method to obtain the mask for any mouse button by its number.
* </ul>
* @throws IllegalArgumentException if the button mask is not a
* valid combination
* <p>
* The following standard button masks are also accepted:
* <ul>
* <li>{@code InputEvent.BUTTON1_MASK}
* <li>{@code InputEvent.BUTTON2_MASK}
* <li>{@code InputEvent.BUTTON3_MASK}
* </ul>
* However, it is recommended to use {@code InputEvent.BUTTON1_DOWN_MASK},
* {@code InputEvent.BUTTON2_DOWN_MASK}, {@code InputEvent.BUTTON3_DOWN_MASK} instead.
* Either extended {@code _DOWN_MASK} or old {@code _MASK} values
* should be used, but both those models should not be mixed.
* @throws IllegalArgumentException if the {@code buttons} mask contains the mask for extra mouse button
* and support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* @throws IllegalArgumentException if the {@code buttons} mask contains the mask for extra mouse button
* that does not exist on the mouse and support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
* @see #mouseRelease(int)
* @see InputEvent#getMaskForButton(int)
* @see Toolkit#areExtraMouseButtonsEnabled()
* @see java.awt.MouseInfo#getNumberOfButtons()
* @see java.awt.event.MouseEvent
*/
public synchronized void mousePress(int buttons) {
checkButtonsArgument(buttons);
@ -209,16 +256,53 @@ public class Robot {
/**
* Releases one or more mouse buttons.
*
* @param buttons the Button mask; a combination of one or more
* of these flags:
* @param buttons the Button mask; a combination of one or more
* mouse button masks.
* <p>
* It is allowed to use only a combination of valid values as a {@code buttons} parameter.
* A valid combination consists of {@code InputEvent.BUTTON1_DOWN_MASK},
* {@code InputEvent.BUTTON2_DOWN_MASK}, {@code InputEvent.BUTTON3_DOWN_MASK}
* and values returned by the
* {@link InputEvent#getMaskForButton(int) InputEvent.getMaskForButton(button)} method.
*
* The valid combination also depends on a
* {@link Toolkit#areExtraMouseButtonsEnabled() Toolkit.areExtraMouseButtonsEnabled()} value as follows:
* <ul>
* <li><code>InputEvent.BUTTON1_MASK</code>
* <li><code>InputEvent.BUTTON2_MASK</code>
* <li><code>InputEvent.BUTTON3_MASK</code>
* <li> If the support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* then it is allowed to use only the following standard button masks:
* {@code InputEvent.BUTTON1_DOWN_MASK}, {@code InputEvent.BUTTON2_DOWN_MASK},
* {@code InputEvent.BUTTON3_DOWN_MASK}.
* <li> If the support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
* then it is allowed to use the standard button masks
* and masks for existing extended mouse buttons, if the mouse has more then three buttons.
* In that way, it is allowed to use the button masks corresponding to the buttons
* in the range from 1 to {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}.
* <br>
* It is recommended to use the {@link InputEvent#getMaskForButton(int) InputEvent.getMaskForButton(button)}
* method to obtain the mask for any mouse button by its number.
* </ul>
* <p>
* The following standard button masks are also accepted:
* <ul>
* <li>{@code InputEvent.BUTTON1_MASK}
* <li>{@code InputEvent.BUTTON2_MASK}
* <li>{@code InputEvent.BUTTON3_MASK}
* </ul>
* However, it is recommended to use {@code InputEvent.BUTTON1_DOWN_MASK},
* {@code InputEvent.BUTTON2_DOWN_MASK}, {@code InputEvent.BUTTON3_DOWN_MASK} instead.
* Either extended {@code _DOWN_MASK} or old {@code _MASK} values
* should be used, but both those models should not be mixed.
* @throws IllegalArgumentException if the {@code buttons} mask contains the mask for extra mouse button
* and support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* @throws IllegalArgumentException if the {@code buttons} mask contains the mask for extra mouse button
* that does not exist on the mouse and support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
* @see #mousePress(int)
* @throws IllegalArgumentException if the button mask is not a valid
* combination
* @see InputEvent#getMaskForButton(int)
* @see Toolkit#areExtraMouseButtonsEnabled()
* @see java.awt.MouseInfo#getNumberOfButtons()
* @see java.awt.event.MouseEvent
*/
public synchronized void mouseRelease(int buttons) {
checkButtonsArgument(buttons);

View File

@ -321,7 +321,7 @@ public class TextArea extends TextComponent {
public synchronized void insertText(String str, int pos) {
TextAreaPeer peer = (TextAreaPeer)this.peer;
if (peer != null) {
peer.insertText(str, pos);
peer.insert(str, pos);
} else {
text = text.substring(0, pos) + str + text.substring(pos);
}
@ -385,7 +385,7 @@ public class TextArea extends TextComponent {
public synchronized void replaceText(String str, int start, int end) {
TextAreaPeer peer = (TextAreaPeer)this.peer;
if (peer != null) {
peer.replaceText(str, start, end);
peer.replaceRange(str, start, end);
} else {
text = text.substring(0, start) + str + text.substring(end);
}
@ -500,7 +500,7 @@ public class TextArea extends TextComponent {
synchronized (getTreeLock()) {
TextAreaPeer peer = (TextAreaPeer)this.peer;
return (peer != null) ?
peer.preferredSize(rows, columns) :
peer.getPreferredSize(rows, columns) :
super.preferredSize();
}
}
@ -552,7 +552,7 @@ public class TextArea extends TextComponent {
synchronized (getTreeLock()) {
TextAreaPeer peer = (TextAreaPeer)this.peer;
return (peer != null) ?
peer.minimumSize(rows, columns) :
peer.getMinimumSize(rows, columns) :
super.minimumSize();
}
}

View File

@ -281,7 +281,7 @@ public class TextField extends TextComponent {
echoChar = c;
TextFieldPeer peer = (TextFieldPeer)this.peer;
if (peer != null) {
peer.setEchoCharacter(c);
peer.setEchoChar(c);
}
}
}
@ -376,7 +376,7 @@ public class TextField extends TextComponent {
synchronized (getTreeLock()) {
TextFieldPeer peer = (TextFieldPeer)this.peer;
return (peer != null) ?
peer.preferredSize(columns) :
peer.getPreferredSize(columns) :
super.preferredSize();
}
}
@ -424,7 +424,7 @@ public class TextField extends TextComponent {
synchronized (getTreeLock()) {
TextFieldPeer peer = (TextFieldPeer)this.peer;
return (peer != null) ?
peer.minimumSize(columns) :
peer.getMinimumSize(columns) :
super.minimumSize();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1995-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
@ -2550,4 +2550,37 @@ public abstract class Toolkit {
}
}
}
/**
* Reports whether events from extra mouse buttons are allowed to be processed and posted into
* {@code EventQueue}.
* <br>
* To change the returned value it is necessary to set the {@code sun.awt.enableExtraMouseButtons}
* property before the {@code Toolkit} class initialization. This setting could be done on the application
* startup by the following command:
* <pre>
* java -Dsun.awt.enableExtraMouseButtons=false Application
* </pre>
* Alternatively, the property could be set in the application by using the following code:
* <pre>
* System.setProperty("sun.awt.enableExtraMouseButtons", "true");
* </pre>
* before the {@code Toolkit} class initialization.
* If not set by the time of the {@code Toolkit} class initialization, this property will be
* initialized with {@code true}.
* Changing this value after the {@code Toolkit} class initialization will have no effect.
* <p>
* The current value could be queried by using the
* {@code System.getProperty("sun.awt.enableExtraMouseButtons")} method.
* @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true
* @return {@code true} if events from extra mouse buttons are allowed to be processed and posted;
* {@code false} otherwise
* @see System#getProperty(String propertyName)
* @see System#setProperty(String propertyName, String value)
* @see java.awt.EventQueue
* @since 1.7
*/
public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
return Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled();
}
}

View File

@ -53,6 +53,7 @@ import sun.awt.AppContext;
import sun.awt.CausedFocusEvent;
import sun.awt.SunToolkit;
import sun.awt.util.IdentityArrayList;
import sun.java2d.Disposer;
import sun.java2d.pipe.Region;
import sun.security.action.GetPropertyAction;
import sun.security.util.SecurityConstants;
@ -409,8 +410,6 @@ public class Window extends Container implements Accessible {
}
modalExclusionType = Dialog.ModalExclusionType.NO_EXCLUDE;
sun.java2d.Disposer.addRecord(anchor, new WindowDisposerRecord(appContext, this));
}
/**
@ -540,6 +539,10 @@ public class Window extends Container implements Accessible {
if (owner != null) {
owner.addOwnedWindow(weakThis);
}
// Fix for 6758673: this call is moved here from init(gc), because
// WindowDisposerRecord requires a proper value of parent field.
Disposer.addRecord(anchor, new WindowDisposerRecord(appContext, this));
}
/**

View File

@ -1,5 +1,5 @@
<!--
Copyright 2005-2006 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
@ -64,6 +64,11 @@ here, and their value types.
<td valign="TOP"><a href="../../util/Map.html">java.util.Map<a/></td>
<td valign="TOP">Font smoothing (text antialiasing) settings.<a/></td>
</tr>
<tr>
<td valign="TOP"><A href=#"sun.awt.enableExtraMouseButtons">sun.awt.enableExtraMouseButtons</A</td>
<td valign="TOP"><a href="../../lang/Boolean.html">java.lang.Boolean<a/></td>
<td valign="TOP">Controls if mouse events from extra buttons are to be generated or not<a/></td>
</tr>
</table>
<p>
<h2>Desktop Font Rendering Hints</h2>
@ -219,5 +224,50 @@ So to determine if there are per-device settings it is sufficient to
determine that there is a non-null return for any screen device using
the per-device property name.
</ul>
<h2>Mouse Functionality</h2>
<b>Desktop Property: <A name="sun.awt.enableExtraMouseButtons">"sun.awt.enableExtraMouseButtons"</A></b>
<p>
This property determines if events from extra mouse buttons (if they are exist and are
enabled by the underlying operating system) are allowed to be processed and posted into
{@code EventQueue}.
<br>
The value could be changed by passing "sun.awt.enableExtraMouseButtons"
property value into java before application starts. This could be done with the following command:
<pre>
java -Dsun.awt.enableExtraMouseButtons=false Application
</pre>
Once set on application startup, it is impossible to change this value after.
<br>
Current value could also be queried using getDesktopProperty("sun.awt.enableExtraMouseButtons")
method.
<br>
If the property is set to {@code true} then
<ul>
<li> it is still legal to create {@code MouseEvent} objects with
standard buttons and, if the mouse has more
then three buttons, it is also legal to use buttons from the range started
from 0 up to {@link java.awt.MouseInfo#getNumberOfButtons() getNumberOfButtons()}.
<li> it is legal to use standard button masks when using {@code Robot.mousePress()}
and {@code Robot.mouseRelease()} methods and, if the mouse has more then three buttons,
it is also legal to use masks for existing extended mouse buttons.
That way, if there are more then three buttons on the mouse then it is allowed to
use button masks corresponding to the buttons
in the range from 1 up to {@link java.awt.MouseInfo#getNumberOfButtons() getNumberOfButtons()}
</ul>
<br>
If the property is set to {@code false} then
<ul>
<li> it is legal to create {@code MouseEvent} objects with standard buttons
only: {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2} and
{@code BUTTON3}
<li> it is legal to use standard button masks only:
{@code InputEvent.BUTTON1_DOWN_MASK}, {@code InputEvent.BUTTON2_DOWN_MASK},
{@code InputEvent.BUTTON3_DOWN_MASK}
</ul>
This property should be used when there is no need in listening mouse events fired as a result of
activity with extra mouse button.
By default this property is set to {@code true}.
</body>
</html>

View File

@ -31,6 +31,7 @@ import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.Arrays;
/**
* The root event class for all component-level input events.
@ -153,13 +154,93 @@ public abstract class InputEvent extends ComponentEvent {
*/
public static final int ALT_GRAPH_DOWN_MASK = 1 << 13;
/**
* An array of extended modifiers for additional buttons.
* @see getButtonDownMasks
* @since 7.0
*/
private static final int [] BUTTON_DOWN_MASK = new int [] { BUTTON1_DOWN_MASK,
BUTTON2_DOWN_MASK,
BUTTON3_DOWN_MASK,
1<<14, //4th phisical button (this is not a wheel!)
1<<15, //(this is not a wheel!)
1<<16,
1<<17,
1<<18,
1<<19,
1<<20,
1<<21 };
/**
* A method to access an array of extended modifiers for additional buttons.
* @since 7.0
*/
private static int [] getButtonDownMasks(){
return Arrays.copyOf(BUTTON_DOWN_MASK, BUTTON_DOWN_MASK.length);
}
/**
* A method to obtain a mask for any existing mouse button.
* The returned mask may be used for different purposes. Following are some of them:
* <ul>
* <li> {@link java.awt.Robot#mousePress(int) mousePress(buttons)} and
* {@link java.awt.Robot#mouseRelease(int) mouseRelease(buttons)}
* <li> as a {@code modifiers} parameter when creating a new {@link MouseEvent} instance
* <li> to check {@link MouseEvent#getModifiersEx() modifiersEx} of existing {@code MouseEvent}
* </ul>
* @param button is a number to represent a button starting from 1.
* For example,
* <pre>
* int button = InputEvent.getMaskForButton(1);
* </pre>
* will have the same meaning as
* <pre>
* int button = InputEvent.getMaskForButton(MouseEvent.BUTTON1);
* </pre>
* because {@link MouseEvent#BUTTON1 MouseEvent.BUTTON1} equals to 1.
* If a mouse has three enabled buttons(see {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()})
* then the values from the left column passed into the method will return
* corresponding values from the right column:
* <PRE>
* <b>button </b> <b>returned mask</b>
* {@link MouseEvent#BUTTON1 BUTTON1} {@link MouseEvent#BUTTON1_DOWN_MASK BUTTON1_DOWN_MASK}
* {@link MouseEvent#BUTTON2 BUTTON2} {@link MouseEvent#BUTTON2_DOWN_MASK BUTTON2_DOWN_MASK}
* {@link MouseEvent#BUTTON3 BUTTON3} {@link MouseEvent#BUTTON3_DOWN_MASK BUTTON3_DOWN_MASK}
* </PRE>
* If a mouse has more than three enabled buttons then more values
* are admissible (4, 5, etc.). There is no assigned constants for these extended buttons.
* The button masks for the extra buttons returned by this method have no assigned names like the
* first three button masks.
* <p>
* This method has the following implementation restriction.
* It returns masks for a limited number of buttons only. The maximum number is
* implementation dependent and may vary.
* This limit is defined by the relevant number
* of buttons that may hypothetically exist on the mouse but it is greater than the
* {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}.
* <p>
* @throws IllegalArgumentException if {@code button} is less than zero or greater than the number
* of button masks reserved for buttons
* @since 7.0
* @see java.awt.MouseInfo#getNumberOfButtons()
* @see Toolkit#areExtraMouseButtonsEnabled()
* @see MouseEvent#getModifiers()
* @see MouseEvent#getModifiersEx()
*/
public static int getMaskForButton(int button) {
if (button <= 0 || button > BUTTON_DOWN_MASK.length) {
throw new IllegalArgumentException("button doesn\'t exist " + button);
}
return BUTTON_DOWN_MASK[button - 1];
}
// the constant below MUST be updated if any extra modifier
// bits are to be added!
// in fact, it is undesirable to add modifier bits
// to the same field as this may break applications
// see bug# 5066958
static final int FIRST_HIGH_BIT = 1 << 14;
static final int FIRST_HIGH_BIT = 1 << 22;
static final int JDK_1_3_MODIFIERS = SHIFT_DOWN_MASK - 1;
static final int HIGH_MODIFIERS = ~( FIRST_HIGH_BIT - 1 );
@ -382,7 +463,7 @@ public abstract class InputEvent extends ComponentEvent {
* cause the returning an empty string.
*
* @param modifiers a modifier mask describing the extended
* modifier keys and mouse buttons for the event
* modifier keys and mouse buttons for the event
* @return a text description of the combination of extended
* modifier keys and mouse buttons that were held down
* during the event.
@ -410,17 +491,14 @@ public abstract class InputEvent extends ComponentEvent {
buf.append(Toolkit.getProperty("AWT.altGraph", "Alt Graph"));
buf.append("+");
}
if ((modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) {
buf.append(Toolkit.getProperty("AWT.button1", "Button1"));
buf.append("+");
}
if ((modifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) {
buf.append(Toolkit.getProperty("AWT.button2", "Button2"));
buf.append("+");
}
if ((modifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) {
buf.append(Toolkit.getProperty("AWT.button3", "Button3"));
buf.append("+");
int buttonNumber = 1;
for (int mask : InputEvent.BUTTON_DOWN_MASK){
if ((modifiers & mask) != 0) {
buf.append(Toolkit.getProperty("AWT.button"+buttonNumber, "Button"+buttonNumber));
buf.append("+");
}
buttonNumber++;
}
if (buf.length() > 0) {
buf.setLength(buf.length()-1); // remove trailing '+'

View File

@ -32,6 +32,7 @@ import java.awt.Toolkit;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.awt.IllegalComponentStateException;
import java.awt.MouseInfo;
/**
* An event which indicates that a mouse action occurred in a component.
@ -135,7 +136,15 @@ import java.awt.IllegalComponentStateException;
* for <code>BUTTON2_MASK</code> arrives first,
* followed by the pair for <code>BUTTON1_MASK</code>.
* <p>
*
* Some extra mouse buttons are added to extend the standard set of buttons
* represented by the following constants:{@code BUTTON1}, {@code BUTTON2}, and {@code BUTTON3}.
* Extra buttons have no assigned {@code BUTTONx}
* constants as well as their button masks have no assigned {@code BUTTONx_DOWN_MASK}
* constants. Nevertheless, ordinal numbers starting from 4 may be
* used as button numbers (button ids). Values obtained by the
* {@link InputEvent#getMaskForButton(int) getMaskForButton(button)} method may be used
* as button masks.
* <p>
* <code>MOUSE_DRAGGED</code> events are delivered to the <code>Component</code>
* in which the mouse button was pressed until the mouse button is released
* (regardless of whether the mouse position is within the bounds of the
@ -324,13 +333,31 @@ public class MouseEvent extends InputEvent {
/**
* Indicates which, if any, of the mouse buttons has changed state.
*
* The only legal values are the following constants:
* <code>NOBUTTON</code>,
* <code>BUTTON1</code>,
* <code>BUTTON2</code> or
* <code>BUTTON3</code>.
* The valid values are ranged from 0 to the value returned by the
* {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()} method.
* This range already includes constants {@code NOBUTTON}, {@code BUTTON1},
* {@code BUTTON2}, and {@code BUTTON3}
* if these buttons are present. So it is allowed to use these constants too.
* For example, for a mouse with two buttons this field may contain the following values:
* <ul>
* <li> 0 ({@code NOBUTTON})
* <li> 1 ({@code BUTTON1})
* <li> 2 ({@code BUTTON2})
* </ul>
* If a mouse has 5 buttons, this field may contain the following values:
* <ul>
* <li> 0 ({@code NOBUTTON})
* <li> 1 ({@code BUTTON1})
* <li> 2 ({@code BUTTON2})
* <li> 3 ({@code BUTTON3})
* <li> 4
* <li> 5
* </ul>
* If support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled()} disabled by Java
* then the field may not contain the value larger than {@code BUTTON3}.
* @serial
* @see #getButton().
* @see #getButton()
* @see java.awt.Toolkit#areExtraMouseButtonsEnabled()
*/
int button;
@ -384,6 +411,15 @@ public class MouseEvent extends InputEvent {
return new Point(xAbs, yAbs);
}
/**
* A number of buttons available on the mouse at the {@code Toolkit} machinery startup.
*/
private static int cachedNumberOfButtons;
static {
cachedNumberOfButtons = MouseInfo.getNumberOfButtons();
}
/**
* Returns the absolute horizontal x position of the event.
* In a virtual device multi-screen environment in which the
@ -421,7 +457,8 @@ public class MouseEvent extends InputEvent {
/**
* Constructs a <code>MouseEvent</code> object with the
* specified source component,
* type, modifiers, coordinates, and click count.
* type, time, modifiers, coordinates, click count, popupTrigger flag,
* and button number.
* <p>
* Creating an invalid event (such
* as by using more than one of the old _MASKs, or modifier/button
@ -464,7 +501,33 @@ public class MouseEvent extends InputEvent {
* @param popupTrigger A boolean that equals {@code true} if this event
* is a trigger for a popup menu
* @param button An integer that indicates, which of the mouse buttons has
* changed its state
* changed its state.
* The following rules are applied to this parameter:
* <ul>
* <li>If support for the extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* then it is allowed to create {@code MouseEvent} objects only with the standard buttons:
* {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2}, and
* {@code BUTTON3}.
* <li> If support for the extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
* then it is allowed to create {@code MouseEvent} objects with
* the standard buttons.
* In case the support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java, then
* in addition to the standard buttons, {@code MouseEvent} objects can be created
* using buttons from the range starting from 4 to
* {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
* if the mouse has more than three buttons.
* </ul>
* @throws IllegalArgumentException if {@code button} is less then zero
* @throws IllegalArgumentException if <code>source</code> is null
* @throws IllegalArgumentException if {@code button} is greater then BUTTON3 and the support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* @throws IllegalArgumentException if {@code button} is greater then the
* {@link java.awt.MouseInfo#getNumberOfButtons() current number of buttons} and the support
* for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled}
* by Java
* @throws IllegalArgumentException if an invalid <code>button</code>
* value is passed in
* @throws IllegalArgumentException if <code>source</code> is null
@ -498,7 +561,7 @@ public class MouseEvent extends InputEvent {
/**
* Constructs a <code>MouseEvent</code> object with the
* specified source component,
* type, modifiers, coordinates, and click count.
* type, modifiers, coordinates, click count, and popupTrigger flag.
* An invocation of the form
* <tt>MouseEvent(source, id, when, modifiers, x, y, clickCount, popupTrigger)</tt>
* behaves in exactly the same way as the invocation
@ -551,10 +614,26 @@ public class MouseEvent extends InputEvent {
}
/* if the button is an extra button and it is released or clicked then in Xsystem its state
is not modified. Exclude this button number from ExtModifiers mask.*/
transient private boolean shouldExcludeButtonFromExtModifiers = false;
/**
* {@inheritDoc}
*/
public int getModifiersEx() {
int tmpModifiers = modifiers;
if (shouldExcludeButtonFromExtModifiers) {
tmpModifiers &= ~(InputEvent.getMaskForButton(getButton()));
}
return tmpModifiers & ~JDK_1_3_MODIFIERS;
}
/**
* Constructs a <code>MouseEvent</code> object with the
* specified source component,
* type, modifiers, coordinates, absolute coordinates, and click count.
* type, time, modifiers, coordinates, absolute coordinates, click count, popupTrigger flag,
* and button number.
* <p>
* Creating an invalid event (such
* as by using more than one of the old _MASKs, or modifier/button
@ -595,7 +674,33 @@ public class MouseEvent extends InputEvent {
* @param popupTrigger A boolean that equals {@code true} if this event
* is a trigger for a popup menu
* @param button An integer that indicates, which of the mouse buttons has
* changed its state
* changed its state.
* The following rules are applied to this parameter:
* <ul>
* <li>If support for the extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* then it is allowed to create {@code MouseEvent} objects only with the standard buttons:
* {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2}, and
* {@code BUTTON3}.
* <li> If support for the extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
* then it is allowed to create {@code MouseEvent} objects with
* the standard buttons.
* In case the support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java, then
* in addition to the standard buttons, {@code MouseEvent} objects can be created
* using buttons from the range starting from 4 to
* {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
* if the mouse has more than three buttons.
* </ul>
* @throws IllegalArgumentException if {@code button} is less then zero
* @throws IllegalArgumentException if <code>source</code> is null
* @throws IllegalArgumentException if {@code button} is greater then BUTTON3 and the support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* @throws IllegalArgumentException if {@code button} is greater then the
* {@link java.awt.MouseInfo#getNumberOfButtons() current number of buttons} and the support
* for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled}
* by Java
* @throws IllegalArgumentException if an invalid <code>button</code>
* value is passed in
* @throws IllegalArgumentException if <code>source</code> is null
@ -610,6 +715,10 @@ public class MouseEvent extends InputEvent {
* @see #getClickCount()
* @see #isPopupTrigger()
* @see #getButton()
* @see #button
* @see Toolkit#areExtraMouseButtonsEnabled()
* @see java.awt.MouseInfo#getNumberOfButtons()
* @see InputEvent#getMaskForButton(int)
* @since 1.6
*/
public MouseEvent(Component source, int id, long when, int modifiers,
@ -623,14 +732,41 @@ public class MouseEvent extends InputEvent {
this.yAbs = yAbs;
this.clickCount = clickCount;
this.popupTrigger = popupTrigger;
if (button < NOBUTTON || button >BUTTON3) {
throw new IllegalArgumentException("Invalid button value");
if (button < NOBUTTON){
throw new IllegalArgumentException("Invalid button value :" + button);
}
//TODO: initialize MouseInfo.cachedNumber on toolkit creation.
if (button > BUTTON3) {
if (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
throw new IllegalArgumentException("Extra mouse events are disabled " + button);
} else {
if (button > cachedNumberOfButtons) {
throw new IllegalArgumentException("Nonexistent button " + button);
}
}
// XToolkit: extra buttons are not reporting about their state correctly.
// Being pressed they report the state=0 both on the press and on the release.
// For 1-3 buttons the state value equals zero on press and non-zero on release.
// Other modifiers like Shift, ALT etc seem report well with extra buttons.
// The problem reveals as follows: one button is pressed and then another button is pressed and released.
// So, the getModifiersEx() would not be zero due to a first button and we will skip this modifier.
// This may have to be moved into the peer code instead if possible.
if (getModifiersEx() != 0) { //There is at least one more button in a pressed state.
if (id == MouseEvent.MOUSE_RELEASED || id == MouseEvent.MOUSE_CLICKED){
System.out.println("MEvent. CASE!");
shouldExcludeButtonFromExtModifiers = true;
}
}
}
this.button = button;
if ((getModifiers() != 0) && (getModifiersEx() == 0)) {
setNewModifiers();
} else if ((getModifiers() == 0) &&
(getModifiersEx() != 0 || button != NOBUTTON))
(getModifiersEx() != 0 || button != NOBUTTON) &&
(button <= BUTTON3))
{
setOldModifiers();
}
@ -701,13 +837,55 @@ public class MouseEvent extends InputEvent {
/**
* Returns which, if any, of the mouse buttons has changed state.
* The returned value is ranged
* from 0 to the {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
* value.
* The returned value includes at least the following constants:
* <ul>
* <li> {@code NOBUTTON}
* <li> {@code BUTTON1}
* <li> {@code BUTTON2}
* <li> {@code BUTTON3}
* </ul>
* It is allowed to use those constants to compare with the returned button number in the application.
* For example,
* <pre>
* if (anEvent.getButton() == MouseEvent.BUTTON1) {
* </pre>
* In particular, for a mouse with one, two, or three buttons this method may return the following values:
* <ul>
* <li> 0 ({@code NOBUTTON})
* <li> 1 ({@code BUTTON1})
* <li> 2 ({@code BUTTON2})
* <li> 3 ({@code BUTTON3})
* </ul>
* Button numbers greater then {@code BUTTON3} have no constant identifier. So if a mouse with five buttons is
* installed, this method may return the following values:
* <ul>
* <li> 0 ({@code NOBUTTON})
* <li> 1 ({@code BUTTON1})
* <li> 2 ({@code BUTTON2})
* <li> 3 ({@code BUTTON3})
* <li> 4
* <li> 5
* </ul>
* <p>
* Note: If support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* then the AWT event subsystem does not produce mouse events for the extended mouse
* buttons. So it is not expected that this method returns anything except {@code NOBUTTON}, {@code BUTTON1},
* {@code BUTTON2}, {@code BUTTON3}.
*
* @return one of the following constants:
* <code>NOBUTTON</code>,
* <code>BUTTON1</code>,
* <code>BUTTON2</code> or
* <code>BUTTON3</code>.
* @return one of the values from 0 to {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
* if support for the extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java.
* That range includes {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2}, {@code BUTTON3};
* <br>
* {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2} or {@code BUTTON3}
* if support for the extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* @since 1.4
* @see Toolkit#areExtraMouseButtonsEnabled()
* @see java.awt.MouseInfo#getNumberOfButtons()
* @see #MouseEvent(Component, int, long, int, int, int, int, int, int, boolean, int)
* @see InputEvent#getMaskForButton(int)
*/
public int getButton() {
return button;
@ -746,7 +924,7 @@ public class MouseEvent extends InputEvent {
* and will cause the returning an unspecified string.
* Zero parameter means that no modifiers were passed and will
* cause the returning an empty string.
*
* <p>
* @param modifiers A modifier mask describing the modifier keys and
* mouse buttons that were down during the event
* @return string string text description of the combination of modifier
@ -788,6 +966,24 @@ public class MouseEvent extends InputEvent {
buf.append(Toolkit.getProperty("AWT.button3", "Button3"));
buf.append("+");
}
int mask;
// TODO: add a toolkit field that holds a number of button on the mouse.
// As the method getMouseModifiersText() is static and obtain
// an integer as a parameter then we may not restrict this with the number
// of buttons installed on the mouse.
// It's a temporary solution. We need to somehow hold the number of buttons somewhere else.
for (int i = 1; i <= cachedNumberOfButtons; i++){
mask = InputEvent.getMaskForButton(i);
if ((modifiers & mask) != 0 &&
buf.indexOf(Toolkit.getProperty("AWT.button"+i, "Button"+i)) == -1) //1,2,3 buttons may already be there; so don't duplicate it.
{
buf.append(Toolkit.getProperty("AWT.button"+i, "Button"+i));
buf.append("+");
}
}
if (buf.length() > 0) {
buf.setLength(buf.length()-1); // remove trailing '+'
}
@ -836,14 +1032,18 @@ public class MouseEvent extends InputEvent {
str.append(",(").append(x).append(",").append(y).append(")");
str.append(",absolute(").append(xAbs).append(",").append(yAbs).append(")");
str.append(",button=").append(getButton());
if (id != MOUSE_DRAGGED && id != MOUSE_MOVED){
str.append(",button=").append(getButton());
}
if (getModifiers() != 0) {
str.append(",modifiers=").append(getMouseModifiersText(modifiers));
}
if (getModifiersEx() != 0) {
str.append(",extModifiers=").append(getModifiersExText(modifiers));
//Using plain "modifiers" here does show an excluded extended buttons in the string event representation.
//getModifiersEx() solves the problem.
str.append(",extModifiers=").append(getModifiersExText(getModifiersEx()));
}
str.append(",clickCount=").append(clickCount);

View File

@ -25,7 +25,11 @@
package java.awt.peer;
import java.awt.Button;
/**
* The peer interface for {@link Button}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -33,5 +37,14 @@ package java.awt.peer;
* instances.
*/
public interface ButtonPeer extends ComponentPeer {
/**
* Sets the label that is displayed on the button. Can be {@code null}
* when the button should not display a label.
*
* @param label the label string to set
*
* @see Button#setLabel
*/
void setLabel(String label);
}

View File

@ -24,7 +24,11 @@
*/
package java.awt.peer;
import java.awt.Canvas;
/**
* The peer interface for {@link Canvas}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers

View File

@ -24,7 +24,11 @@
*/
package java.awt.peer;
import java.awt.CheckboxMenuItem;
/**
* The peer interface for {@link CheckboxMenuItem}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -32,5 +36,14 @@ package java.awt.peer;
* instances.
*/
public interface CheckboxMenuItemPeer extends MenuItemPeer {
/**
* Sets the state of the checkbox to be checked ({@code true}) or
* unchecked ({@code false}).
*
* @param t the state to set on the checkbox
*
* @see CheckboxMenuItemPeer#setState(boolean)
*/
void setState(boolean t);
}

View File

@ -27,6 +27,8 @@ package java.awt.peer;
import java.awt.*;
/**
* The peer interface for {@link Checkbox}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -34,7 +36,36 @@ import java.awt.*;
* instances.
*/
public interface CheckboxPeer extends ComponentPeer {
/**
* Sets the state of the checkbox to be checked ({@code true}) or
* unchecked ({@code false}).
*
* @param t the state to set on the checkbox
*
* @see Checkbox#setState(boolean)
*/
void setState(boolean state);
/**
* Sets the checkbox group for this checkbox. Checkboxes in one checkbox
* group can only be selected exclusively (like radio buttons). A value
* of {@code null} removes this checkbox from any checkbox group.
*
* @param g the checkbox group to set, or {@code null} when this
* checkbox should not be placed in any group
*
* @see Checkbox#setCheckboxGroup(CheckboxGroup)
*/
void setCheckboxGroup(CheckboxGroup g);
/**
* Sets the label that should be displayed on the ckeckbox. A value of
* {@code null} means that no label should be displayed.
*
* @param label the label to be displayed on the checkbox, or
* {@code null} when no label should be displayed.
*/
void setLabel(String label);
}

View File

@ -24,7 +24,11 @@
*/
package java.awt.peer;
import java.awt.Choice;
/**
* The peer interface for {@link Choice}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -32,13 +36,41 @@ package java.awt.peer;
* instances.
*/
public interface ChoicePeer extends ComponentPeer {
/**
* Adds an item with the string {@code item} to the combo box list
* at index {@code index}.
*
* @param item the label to be added to the list
* @param index the index where to add the item
*
* @see Choice#add(String)
*/
void add(String item, int index);
/**
* Removes the item at index {@code index} from the combo box list.
*
* @param index the index where to remove the item
*
* @see Choice#remove(int)
*/
void remove(int index);
/**
* Removes all items from the combo box list.
*
* @see Choice#removeAll()
*/
void removeAll();
/**
* Selects the item at index {@code index}.
*
* @param index the index which should be selected
*
* @see Choice#select(int)
*/
void select(int index);
/*
* DEPRECATED: Replaced by add(String, int).
*/
void addItem(String item, int index);
}

View File

@ -37,6 +37,12 @@ import sun.java2d.pipe.Region;
/**
* The peer interface for {@link Component}. This is the top level peer
* interface for widgets and defines the bulk of methods for AWT component
* peers. Most component peers have to implement this interface (via one
* of the subinterfaces), except menu components, which implement
* {@link MenuComponentPeer}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -44,63 +50,474 @@ import sun.java2d.pipe.Region;
* instances.
*/
public interface ComponentPeer {
public static final int SET_LOCATION = 1,
SET_SIZE = 2,
SET_BOUNDS = 3,
SET_CLIENT_SIZE = 4,
RESET_OPERATION = 5,
NO_EMBEDDED_CHECK = (1 << 14),
DEFAULT_OPERATION = SET_BOUNDS;
boolean isObscured();
boolean canDetermineObscurity();
void setVisible(boolean b);
void setEnabled(boolean b);
void paint(Graphics g);
void repaint(long tm, int x, int y, int width, int height);
void print(Graphics g);
void setBounds(int x, int y, int width, int height, int op);
void handleEvent(AWTEvent e);
void coalescePaintEvent(PaintEvent e);
Point getLocationOnScreen();
Dimension getPreferredSize();
Dimension getMinimumSize();
ColorModel getColorModel();
Toolkit getToolkit();
Graphics getGraphics();
FontMetrics getFontMetrics(Font font);
void dispose();
void setForeground(Color c);
void setBackground(Color c);
void setFont(Font f);
void updateCursorImmediately();
boolean requestFocus(Component lightweightChild,
boolean temporary,
boolean focusedWindowChangeAllowed,
long time, CausedFocusEvent.Cause cause);
boolean isFocusable();
Image createImage(ImageProducer producer);
Image createImage(int width, int height);
VolatileImage createVolatileImage(int width, int height);
boolean prepareImage(Image img, int w, int h, ImageObserver o);
int checkImage(Image img, int w, int h, ImageObserver o);
/**
* Operation for {@link #setBounds(int, int, int, int, int)}, indicating
* a change in the component location only.
*
* @see #setBounds(int, int, int, int, int)
*/
public static final int SET_LOCATION = 1;
/**
* Operation for {@link #setBounds(int, int, int, int, int)}, indicating
* a change in the component size only.
*
* @see #setBounds(int, int, int, int, int)
*/
public static final int SET_SIZE = 2;
/**
* Operation for {@link #setBounds(int, int, int, int, int)}, indicating
* a change in the component size and location.
*
* @see #setBounds(int, int, int, int, int)
*/
public static final int SET_BOUNDS = 3;
/**
* Operation for {@link #setBounds(int, int, int, int, int)}, indicating
* a change in the component client size. This is used for setting
* the 'inside' size of windows, without the border insets.
*
* @see #setBounds(int, int, int, int, int)
*/
public static final int SET_CLIENT_SIZE = 4;
/**
* Resets the setBounds() operation to DEFAULT_OPERATION. This is not
* passed into {@link #setBounds(int, int, int, int, int)}.
*
* TODO: This is only used internally and should probably be moved outside
* the peer interface.
*
* @see Component#setBoundsOp
*/
public static final int RESET_OPERATION = 5;
/**
* A flag that is used to suppress checks for embedded frames.
*
* TODO: This is only used internally and should probably be moved outside
* the peer interface.
*/
public static final int NO_EMBEDDED_CHECK = (1 << 14);
/**
* The default operation, which is to set size and location.
*
* TODO: This is only used internally and should probably be moved outside
* the peer interface.
*
* @see Component#setBoundsOp
*/
public static final int DEFAULT_OPERATION = SET_BOUNDS;
/**
* Determines if a component has been obscured, i.e. by an overlapping
* window or similar. This is used by JViewport for optimizing performance.
* This doesn't have to be implemented, when
* {@link #canDetermineObscurity()} returns {@code false}.
*
* @return {@code true} when the component has been obscured,
* {@code false} otherwise
*
* @see #canDetermineObscurity()
* @see javax.swing.JViewport#needsRepaintAfterBlit
*/
boolean isObscured();
/**
* Returns {@code true} when the peer can determine if a component
* has been obscured, {@code false} false otherwise.
*
* @return {@code true} when the peer can determine if a component
* has been obscured, {@code false} false otherwise
*
* @see #isObscured()
* @see javax.swing.JViewport#needsRepaintAfterBlit
*/
boolean canDetermineObscurity();
/**
* Makes a component visible or invisible.
*
* @param v {@code true} to make a component visible,
* {@code false} to make it invisible
*
* @see Component#setVisible(boolean)
*/
void setVisible(boolean v);
/**
* Enables or disables a component. Disabled components are usually grayed
* out and cannot be activated.
*
* @param e {@code true} to enable the component, {@code false}
* to disable it
*
* @see Component#setEnabled(boolean)
*/
void setEnabled(boolean e);
/**
* Paints the component to the specified graphics context. This is called
* by {@link Component#paintAll(Graphics)} to paint the component.
*
* @param g the graphics context to paint to
*
* @see Component#paintAll(Graphics)
*/
void paint(Graphics g);
/**
* Prints the component to the specified graphics context. This is called
* by {@link Component#printAll(Graphics)} to print the component.
*
* @param g the graphics context to print to
*
* @see Component#printAll(Graphics)
*/
void print(Graphics g);
/**
* Sets the location or size or both of the component. The location is
* specified relative to the component's parent. The {@code op}
* parameter specifies which properties change. If it is
* {@link #SET_LOCATION}, then only the location changes (and the size
* parameters can be ignored). If {@code op} is {@link #SET_SIZE},
* then only the size changes (and the location can be ignored). If
* {@code op} is {@link #SET_BOUNDS}, then both change. There is a
* special value {@link #SET_CLIENT_SIZE}, which is used only for
* window-like components to set the size of the client (i.e. the 'inner'
* size, without the insets of the window borders).
*
* @param x the X location of the component
* @param y the Y location of the component
* @param width the width of the component
* @param height the height of the component
* @param op the operation flag
*
* @see #SET_BOUNDS
* @see #SET_LOCATION
* @see #SET_SIZE
* @see #SET_CLIENT_SIZE
*/
void setBounds(int x, int y, int width, int height, int op);
/**
* Called to let the component peer handle events.
*
* @param e the AWT event to handle
*
* @see Component#dispatchEvent(AWTEvent)
*/
void handleEvent(AWTEvent e);
/**
* Called to coalesce paint events.
*
* @param e the paint event to consider to coalesce
*
* @see EventQueue#coalescePaintEvent
*/
void coalescePaintEvent(PaintEvent e);
/**
* Determines the location of the component on the screen.
*
* @return the location of the component on the screen
*
* @see Component#getLocationOnScreen()
*/
Point getLocationOnScreen();
/**
* Determines the preferred size of the component.
*
* @return the preferred size of the component
*
* @see Component#getPreferredSize()
*/
Dimension getPreferredSize();
/**
* Determines the minimum size of the component.
*
* @return the minimum size of the component
*
* @see Component#getMinimumSize()
*/
Dimension getMinimumSize();
/**
* Returns the color model used by the component.
*
* @return the color model used by the component
*
* @see Component#getColorModel()
*/
ColorModel getColorModel();
/**
* Returns the toolkit that is responsible for the component.
*
* @return the toolkit that is responsible for the component
*
* @see Component#getToolkit()
*/
Toolkit getToolkit();
/**
* Returns a graphics object to paint on the component.
*
* @return a graphics object to paint on the component
*
* @see Component#getGraphics()
*/
// TODO: Maybe change this to force Graphics2D, since many things will
// break with plain Graphics nowadays.
Graphics getGraphics();
/**
* Returns a font metrics object to determine the metrics properties of
* the specified font.
*
* @param font the font to determine the metrics for
*
* @return a font metrics object to determine the metrics properties of
* the specified font
*
* @see Component#getFontMetrics(Font)
*/
FontMetrics getFontMetrics(Font font);
/**
* Disposes all resources held by the component peer. This is called
* when the component has been disconnected from the component hierarchy
* and is about to be garbage collected.
*
* @see Component#removeNotify()
*/
void dispose();
/**
* Sets the foreground color of this component.
*
* @param c the foreground color to set
*
* @see Component#setForeground(Color)
*/
void setForeground(Color c);
/**
* Sets the background color of this component.
*
* @param c the background color to set
*
* @see Component#setBackground(Color)
*/
void setBackground(Color c);
/**
* Sets the font of this component.
*
* @param f the font of this component
*
* @see Component#setFont(Font)
*/
void setFont(Font f);
/**
* Updates the cursor of the component.
*
* @see Component#updateCursorImmediately
*/
void updateCursorImmediately();
/**
* Requests focus on this component.
*
* @param lightweightChild the actual lightweight child that requests the
* focus
* @param temporary {@code true} if the focus change is temporary,
* {@code false} otherwise
* @param focusedWindowChangeAllowed {@code true} if changing the
* focus of the containing window is allowed or not
* @param time the time of the focus change request
* @param cause the cause of the focus change request
*
* @return {@code true} if the focus change is guaranteed to be
* granted, {@code false} otherwise
*/
boolean requestFocus(Component lightweightChild, boolean temporary,
boolean focusedWindowChangeAllowed, long time,
CausedFocusEvent.Cause cause);
/**
* Returns {@code true} when the component takes part in the focus
* traversal, {@code false} otherwise.
*
* @return {@code true} when the component takes part in the focus
* traversal, {@code false} otherwise
*/
boolean isFocusable();
/**
* Creates an image using the specified image producer.
*
* @param producer the image producer from which the image pixels will be
* produced
*
* @return the created image
*
* @see Component#createImage(ImageProducer)
*/
Image createImage(ImageProducer producer);
/**
* Creates an empty image with the specified width and height. This is
* generally used as a non-accelerated backbuffer for drawing onto the
* component (e.g. by Swing).
*
* @param width the width of the image
* @param height the height of the image
*
* @return the created image
*
* @see Component#createImage(int, int)
*/
// TODO: Maybe make that return a BufferedImage, because some stuff will
// break if a different kind of image is returned.
Image createImage(int width, int height);
/**
* Creates an empty volatile image with the specified width and height.
* This is generally used as an accelerated backbuffer for drawing onto
* the component (e.g. by Swing).
*
* @param width the width of the image
* @param height the height of the image
*
* @return the created volatile image
*
* @see Component#createVolatileImage(int, int)
*/
// TODO: Include capabilities here and fix Component#createVolatileImage
VolatileImage createVolatileImage(int width, int height);
/**
* Prepare the specified image for rendering on this component. This should
* start loading the image (if not already loaded) and create an
* appropriate screen representation.
*
* @param img the image to prepare
* @param w the width of the screen representation
* @param h the height of the screen representation
* @param o an image observer to observe the progress
*
* @return {@code true} if the image is already fully prepared,
* {@code false} otherwise
*
* @see Component#prepareImage(Image, int, int, ImageObserver)
*/
boolean prepareImage(Image img, int w, int h, ImageObserver o);
/**
* Determines the status of the construction of the screen representaion
* of the specified image.
*
* @param img the image to check
* @param w the target width
* @param h the target height
* @param o the image observer to notify
*
* @return the status as bitwise ORed ImageObserver flags
*
* @see Component#checkImage(Image, int, int, ImageObserver)
*/
int checkImage(Image img, int w, int h, ImageObserver o);
/**
* Returns the graphics configuration that corresponds to this component.
*
* @return the graphics configuration that corresponds to this component
*
* @see Component#getGraphicsConfiguration()
*/
GraphicsConfiguration getGraphicsConfiguration();
boolean handlesWheelScrolling();
void createBuffers(int numBuffers, BufferCapabilities caps) throws AWTException;
/**
* Determines if the component handles wheel scrolling itself. Otherwise
* it is delegated to the component's parent.
*
* @return {@code true} if the component handles wheel scrolling,
* {@code false} otherwise
*
* @see Component#dispatchEventImpl(AWTEvent)
*/
boolean handlesWheelScrolling();
/**
* Create {@code numBuffers} flipping buffers with the specified
* buffer capabilities.
*
* @param numBuffers the number of buffers to create
* @param caps the buffer capabilities
*
* @throws AWTException if flip buffering is not supported
*
* @see Component.FlipBufferStrategy#createBuffers
*/
void createBuffers(int numBuffers, BufferCapabilities caps)
throws AWTException;
/**
* Returns the back buffer as image.
*
* @return the back buffer as image
*
* @see Component.FlipBufferStrategy#getBackBuffer
*/
Image getBackBuffer();
/**
* Move the back buffer to the front buffer.
*
* @param x1 the area to be flipped, upper left X coordinate
* @param y1 the area to be flipped, upper left Y coordinate
* @param x2 the area to be flipped, lower right X coordinate
* @param y2 the area to be flipped, lower right Y coordinate
* @param flipAction the flip action to perform
*
* @see Component.FlipBufferStrategy#flip
*/
void flip(int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction);
/**
* Destroys all created buffers.
*
* @see Component.FlipBufferStrategy#destroyBuffers
*/
void destroyBuffers();
/**
* Reparents this peer to the new parent referenced by <code>newContainer</code> peer
* Implementation depends on toolkit and container.
* Reparents this peer to the new parent referenced by
* {@code newContainer} peer. Implementation depends on toolkit and
* container.
*
* @param newContainer peer of the new parent container
*
* @since 1.5
*/
void reparent(ContainerPeer newContainer);
/**
* Returns whether this peer supports reparenting to another parent withour destroying the peer
* Returns whether this peer supports reparenting to another parent without
* destroying the peer.
*
* @return true if appropriate reparent is supported, false otherwise
*
* @since 1.5
*/
boolean isReparentSupported();
@ -109,50 +526,17 @@ public interface ComponentPeer {
* Used by lightweight implementations to tell a ComponentPeer to layout
* its sub-elements. For instance, a lightweight Checkbox needs to layout
* the box, as well as the text label.
*
* @see Component#validate()
*/
void layout();
Rectangle getBounds();
void layout();
/**
* Applies the shape to the native component window.
* @since 1.7
*
* @see Component#applyCompoundShape
*/
void applyShape(Region shape);
/**
* DEPRECATED: Replaced by getPreferredSize().
*/
Dimension preferredSize();
/**
* DEPRECATED: Replaced by getMinimumSize().
*/
Dimension minimumSize();
/**
* DEPRECATED: Replaced by setVisible(boolean).
*/
void show();
/**
* DEPRECATED: Replaced by setVisible(boolean).
*/
void hide();
/**
* DEPRECATED: Replaced by setEnabled(boolean).
*/
void enable();
/**
* DEPRECATED: Replaced by setEnabled(boolean).
*/
void disable();
/**
* DEPRECATED: Replaced by setBounds(int, int, int, int).
*/
void reshape(int x, int y, int width, int height);
}

View File

@ -27,6 +27,9 @@ package java.awt.peer;
import java.awt.*;
/**
* The peer interface for {@link Container}. This is the parent interface
* for all container like widgets.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -34,30 +37,60 @@ import java.awt.*;
* instances.
*/
public interface ContainerPeer extends ComponentPeer {
Insets getInsets();
void beginValidate();
void endValidate();
void beginLayout();
void endLayout();
boolean isPaintPending();
/**
* Restacks native windows - children of this native window - according to Java container order
* Returns the insets of this container. Insets usually is the space that
* is occupied by things like borders.
*
* @return the insets of this container
*/
Insets getInsets();
/**
* Notifies the peer that validation of the component tree is about to
* begin.
*
* @see Container#validate()
*/
void beginValidate();
/**
* Notifies the peer that validation of the component tree is finished.
*
* @see Container#validate()
*/
void endValidate();
/**
* Notifies the peer that layout is about to begin. This is called
* before the container itself and its children are laid out.
*
* @see Container#validateTree()
*/
void beginLayout();
/**
* Notifies the peer that layout is finished. This is called after the
* container and its children have been laid out.
*
* @see Container#validateTree()
*/
void endLayout();
/**
* Restacks native windows - children of this native window - according to
* Java container order.
*
* @since 1.5
*/
void restack();
/**
* Indicates availabiltity of restacking operation in this container.
* Indicates availability of restacking operation in this container.
*
* @return Returns true if restack is supported, false otherwise
*
* @since 1.5
*/
boolean isRestackSupported();
/**
* DEPRECATED: Replaced by getInsets().
*/
Insets insets();
}

View File

@ -32,7 +32,7 @@ import java.net.URI;
import java.awt.Desktop.Action;
/**
* The <code>DesktopPeer</code> interface provides methods for the operation
* The {@code DesktopPeer} interface provides methods for the operation
* of open, edit, print, browse and mail with the given URL or file, by
* launching the associated application.
* <p>
@ -40,14 +40,15 @@ import java.awt.Desktop.Action;
*
*/
public interface DesktopPeer {
/**
* Returns whether the given action is supported on the current platform.
* @param action the action type to be tested if it's supported on the
* current platform.
* @return <code>true</code> if the given action is supported on
* the current platform; <code>false</code> otherwise.
* @return {@code true} if the given action is supported on
* the current platform; {@code false} otherwise.
*/
public boolean isSupported(Action action);
boolean isSupported(Action action);
/**
* Launches the associated application to open the given file. The
@ -58,7 +59,7 @@ public interface DesktopPeer {
* @throws IOException If the given file has no associated application,
* or the associated application fails to be launched.
*/
public void open(File file) throws IOException;
void open(File file) throws IOException;
/**
* Launches the associated editor and opens the given file for editing. The
@ -69,7 +70,7 @@ public interface DesktopPeer {
* @throws IOException If the given file has no associated editor, or
* the associated application fails to be launched.
*/
public void edit(File file) throws IOException;
void edit(File file) throws IOException;
/**
* Prints the given file with the native desktop printing facility, using
@ -79,7 +80,7 @@ public interface DesktopPeer {
* @throws IOException If the given file has no associated application
* that can be used to print it.
*/
public void print(File file) throws IOException;
void print(File file) throws IOException;
/**
* Launches the mail composing window of the user default mail client,
@ -93,7 +94,7 @@ public interface DesktopPeer {
* @throws IOException If the user default mail client is not found,
* or it fails to be launched.
*/
public void mail(URI mailtoURL) throws IOException;
void mail(URI mailtoURL) throws IOException;
/**
* Launches the user default browser to display the given URI.
@ -102,5 +103,5 @@ public interface DesktopPeer {
* @throws IOException If the user default browser is not found,
* or it fails to be launched.
*/
public void browse(URI url) throws IOException;
void browse(URI url) throws IOException;
}

View File

@ -28,6 +28,9 @@ package java.awt.peer;
import java.awt.*;
/**
* The peer interface for {@link Dialog}. This adds a couple of dialog specific
* features to the {@link WindowPeer} interface.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -35,7 +38,33 @@ import java.awt.*;
* instances.
*/
public interface DialogPeer extends WindowPeer {
/**
* Sets the title on the dialog window.
*
* @param title the title to set
*
* @see Dialog#setTitle(String)
*/
void setTitle(String title);
/**
* Sets if the dialog should be resizable or not.
*
* @param resizeable {@code true} when the dialog should be resizable,
* {@code false} if not
*
* @see Dialog#setResizable(boolean)
*/
void setResizable(boolean resizeable);
/**
* Block the specified windows. This is used for modal dialogs.
*
* @param windows the windows to block
*
* @see Dialog#modalShow()
* @see Dialog#blockWindows()
*/
void blockWindows(java.util.List<Window> windows);
}

View File

@ -25,9 +25,12 @@
package java.awt.peer;
import java.awt.FileDialog;
import java.io.FilenameFilter;
/**
* The peer interface for {@link FileDialog}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -35,7 +38,32 @@ import java.io.FilenameFilter;
* instances.
*/
public interface FileDialogPeer extends DialogPeer {
/**
* Sets the selected file for this file dialog.
*
* @param file the file to set as selected file, or {@code null} for
* no selected file
*
* @see FileDialog#setFile(String)
*/
void setFile(String file);
/**
* Sets the current directory for this file dialog.
*
* @param dir the directory to set
*
* @see FileDialog#setDirectory(String)
*/
void setDirectory(String dir);
/**
* Sets the filename filter for filtering the displayed files.
*
* @param filter the filter to set
*
* @see FileDialog#setFilenameFilter(FilenameFilter)
*/
void setFilenameFilter(FilenameFilter filter);
}

View File

@ -26,6 +26,9 @@
package java.awt.peer;
/**
* The peer interface for fonts. This is only a marker interface and not
* used by AWT itself.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers

View File

@ -27,7 +27,12 @@ package java.awt.peer;
import java.awt.*;
import sun.awt.EmbeddedFrame;
/**
* The peer interface for {@link Frame}. This adds a couple of frame specific
* methods to the {@link WindowPeer} interface.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -35,12 +40,89 @@ import java.awt.*;
* instances.
*/
public interface FramePeer extends WindowPeer {
/**
* Sets the title on the frame.
*
* @param title the title to set
*
* @see Frame#setTitle(String)
*/
void setTitle(String title);
/**
* Sets the menu bar for the frame.
*
* @param mb the menu bar to set
*
* @see Frame#setMenuBar(MenuBar)
*/
void setMenuBar(MenuBar mb);
/**
* Sets if the frame should be resizable or not.
*
* @param resizeable {@code true} when the frame should be resizable,
* {@code false} if not
*
* @see Frame#setResizable(boolean)
*/
void setResizable(boolean resizeable);
/**
* Changes the state of the frame.
*
* @param state the new state
*
* @see Frame#setExtendedState(int)
*/
void setState(int state);
int getState();
void setMaximizedBounds(Rectangle bounds); // XXX
/**
* Returns the current state of the frame.
*
* @return the current state of the frame
*
* @see Frame#getExtendedState()
*/
int getState();
/**
* Sets the bounds of the frame when it becomes maximized.
*
* @param bounds the maximized bounds of the frame
*
* @see Frame#setMaximizedBounds(Rectangle)
*/
void setMaximizedBounds(Rectangle bounds);
/**
* Sets the size and location for embedded frames. (On embedded frames,
* setLocation() and setBounds() always set the frame to (0,0) for
* backwards compatibility.
*
* @param x the X location
* @param y the Y location
* @param width the width of the frame
* @param height the height of the frame
*
* @see EmbeddedFrame#setBoundsPrivate(int, int, int, int)
*/
// TODO: This is only used in EmbeddedFrame, and should probably be moved
// into an EmbeddedFramePeer which would extend FramePeer
void setBoundsPrivate(int x, int y, int width, int height);
/**
* Returns the size and location for embedded frames. (On embedded frames,
* setLocation() and setBounds() always set the frame to (0,0) for
* backwards compatibility.
*
* @return the bounds of an embedded frame
*
* @see EmbeddedFrame#getBoundsPrivate()
*/
// TODO: This is only used in EmbeddedFrame, and should probably be moved
// into an EmbeddedFramePeer which would extend FramePeer
Rectangle getBoundsPrivate();
}

View File

@ -28,11 +28,45 @@ package java.awt.peer;
import java.awt.Component;
import java.awt.Window;
/**
* The native peer interface for {@link KeyboardFocusManager}.
*/
public interface KeyboardFocusManagerPeer {
/**
* Returns the currently focused window.
*
* @return the currently focused window
*
* @see KeyboardFocusManager#getNativeFocusedWindow()
*/
Window getCurrentFocusedWindow();
/**
* Sets the component that should become the focus owner.
*
* @param comp the component to become the focus owner
*
* @see KeyboardFocusManager#setNativeFocusOwner(Component)
*/
void setCurrentFocusOwner(Component comp);
/**
* Returns the component that currently owns the input focus.
*
* @return the component that currently owns the input focus
*
* @see KeyboardFocusManager#getNativeFocusOwner()
*/
Component getCurrentFocusOwner();
/**
* Clears the current global focus owner.
*
* @param activeWindow
*
* @see KeyboardFocusManager#clearGlobalFocusOwner()
*/
void clearGlobalFocusOwner(Window activeWindow);
}

View File

@ -24,7 +24,11 @@
*/
package java.awt.peer;
import java.awt.Label;
/**
* The peer interface for {@link Label}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -32,6 +36,25 @@ package java.awt.peer;
* instances.
*/
public interface LabelPeer extends ComponentPeer {
/**
* Sets the text to be displayed on the label.
*
* @param label the text to be displayed on the label
*
* @see Label#setText
*/
void setText(String label);
/**
* Sets the alignment of the label text.
*
* @param alignment the alignment of the label text
*
* @see Label#setAlignment(int)
* @see Label#CENTER
* @see Label#RIGHT
* @see Label#LEFT
*/
void setAlignment(int alignment);
}

View File

@ -25,8 +25,11 @@
package java.awt.peer;
import java.awt.Dimension;
import java.awt.List;
/**
* The peer interface for {@link List}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -34,39 +37,102 @@ import java.awt.Dimension;
* instances.
*/
public interface ListPeer extends ComponentPeer {
/**
* Returns the indices of the list items that are currently selected.
* The returned array is not required to be a copy, the callers of this
* method already make sure it is not modified.
*
* @return the indices of the list items that are currently selected
*
* @see List#getSelectedIndexes()
*/
int[] getSelectedIndexes();
/**
* Adds an item to the list at the specified index.
*
* @param item the item to add to the list
* @param index the index where to add the item into the list
*
* @see List#add(String, int)
*/
void add(String item, int index);
/**
* Deletes items from the list. All items from start to end should are
* deleted, including the item at the start and end indices.
*
* @param start the first item to be deleted
* @param end the last item to be deleted
*/
void delItems(int start, int end);
/**
* Removes all items from the list.
*
* @see List#removeAll()
*/
void removeAll();
/**
* Selects the item at the specified {@code index}.
*
* @param index the index of the item to select
*
* @see List#select(int)
*/
void select(int index);
/**
* De-selects the item at the specified {@code index}.
*
* @param index the index of the item to de-select
*
* @see List#deselect(int)
*/
void deselect(int index);
/**
* Makes sure that the item at the specified {@code index} is visible,
* by scrolling the list or similar.
*
* @param index the index of the item to make visible
*
* @see List#makeVisible(int)
*/
void makeVisible(int index);
void setMultipleMode(boolean b);
/**
* Toggles multiple selection mode on or off.
*
* @param m {@code true} for multiple selection mode,
* {@code false} for single selection mode
*
* @see List#setMultipleMode(boolean)
*/
void setMultipleMode(boolean m);
/**
* Returns the preferred size for a list with the specified number of rows.
*
* @param rows the number of rows
*
* @return the preferred size of the list
*
* @see List#getPreferredSize(int)
*/
Dimension getPreferredSize(int rows);
/**
* Returns the minimum size for a list with the specified number of rows.
*
* @param rows the number of rows
*
* @return the minimum size of the list
*
* @see List#getMinimumSize(int)
*/
Dimension getMinimumSize(int rows);
/**
* DEPRECATED: Replaced by add(String, int).
*/
void addItem(String item, int index);
/**
* DEPRECATED: Replaced by removeAll().
*/
void clear();
/**
* DEPRECATED: Replaced by setMultipleMode(boolean).
*/
void setMultipleSelections(boolean v);
/**
* DEPRECATED: Replaced by getPreferredSize(int).
*/
Dimension preferredSize(int v);
/**
* DEPRECATED: Replaced by getMinimumSize(int).
*/
Dimension minimumSize(int v);
}

View File

@ -25,8 +25,11 @@
package java.awt.peer;
import java.awt.Menu;
import java.awt.MenuBar;
/**
* The peer interface for {@link MenuBar}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -34,7 +37,31 @@ import java.awt.Menu;
* instances.
*/
public interface MenuBarPeer extends MenuComponentPeer {
/**
* Adds a menu to the menu bar.
*
* @param m the menu to add
*
* @see MenuBar#add(Menu)
*/
void addMenu(Menu m);
/**
* Deletes a menu from the menu bar.
*
* @param index the index of the menu to remove
*
* @see MenuBar#remove(int)
*/
void delMenu(int index);
/**
* Adds a help menu to the menu bar.
*
* @param m the help menu to add
*
* @see MenuBar#setHelpMenu(Menu)
*/
void addHelpMenu(Menu m);
}

View File

@ -25,8 +25,12 @@
package java.awt.peer;
import java.awt.Font;
import java.awt.MenuComponent;
/**
* The base interface for all kinds of menu components. This is used by
* {@link MenuComponent}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -34,6 +38,20 @@ import java.awt.Font;
* instances.
*/
public interface MenuComponentPeer {
/**
* Disposes the menu component.
*
* @see MenuComponent#removeNotify()
*/
void dispose();
/**
* Sets the font for the menu component.
*
* @param f the font to use for the menu component
*
* @see MenuComponent#setFont(Font)
*/
void setFont(Font f);
}

View File

@ -24,7 +24,11 @@
*/
package java.awt.peer;
import java.awt.MenuItem;
/**
* The peer interface for menu items. This is used by {@link MenuItem}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -32,16 +36,20 @@ package java.awt.peer;
* instances.
*/
public interface MenuItemPeer extends MenuComponentPeer {
/**
* Sets the label to be displayed in this menu item.
*
* @param label the label to be displayed
*/
void setLabel(String label);
void setEnabled(boolean b);
/**
* DEPRECATED: Replaced by setEnabled(boolean).
* Enables or disables the menu item.
*
* @param e {@code true} to enable the menu item, {@code false}
* to disable it
*/
void enable();
void setEnabled(boolean e);
/**
* DEPRECATED: Replaced by setEnabled(boolean).
*/
void disable();
}

View File

@ -24,9 +24,12 @@
*/
package java.awt.peer;
import java.awt.Menu;
import java.awt.MenuItem;
/**
* The peer interface for menus. This is used by {@link Menu}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -34,7 +37,29 @@ import java.awt.MenuItem;
* instances.
*/
public interface MenuPeer extends MenuItemPeer {
/**
* Adds a separator (e.g. a horizontal line or similar) to the menu.
*
* @see Menu#addSeparator()
*/
void addSeparator();
/**
* Adds the specified menu item to the menu.
*
* @param item the menu item to add
*
* @see Menu#add(MenuItem)
*/
void addItem(MenuItem item);
/**
* Removes the menu item at the specified index.
*
* @param index the index of the item to remove
*
* @see Menu#remove(int)
*/
void delItem(int index);
}

View File

@ -29,6 +29,9 @@ import java.awt.Window;
import java.awt.Point;
/**
* Peer interface for {@link MouseInfo}. This is used to get some additional
* information about the mouse.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers

View File

@ -25,6 +25,10 @@
package java.awt.peer;
/**
* The peer interface for {@link Panel}. This is a subinterface of
* ContainerPeer and does not declare any additional methods because a Panel
* is just that, a concrete Container.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers

View File

@ -25,8 +25,11 @@
package java.awt.peer;
import java.awt.Event;
import java.awt.PopupMenu;
/**
* The peer interface for {@link PopupMenu}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -34,5 +37,14 @@ import java.awt.Event;
* instances.
*/
public interface PopupMenuPeer extends MenuPeer {
/**
* Shows the popup menu.
*
* @param e a synthetic event describing the origin and location of the
* popup menu
*
* @see PopupMenu#show(java.awt.Component, int, int)
*/
void show(Event e);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1999-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
@ -39,17 +39,93 @@ import java.awt.*;
*/
public interface RobotPeer
{
public void mouseMove(int x, int y);
public void mousePress(int buttons);
public void mouseRelease(int buttons);
/**
* Moves the mouse pointer to the specified screen location.
*
* @param x the X location on screen
* @param y the Y location on screen
*
* @see Robot#mouseMove(int, int)
*/
void mouseMove(int x, int y);
public void mouseWheel(int wheelAmt);
/**
* Simulates a mouse press with the specified button(s).
*
* @param buttons the button mask
*
* @see Robot#mousePress(int)
*/
void mousePress(int buttons);
public void keyPress(int keycode);
public void keyRelease(int keycode);
/**
* Simulates a mouse release with the specified button(s).
*
* @param buttons the button mask
*
* @see Robot#mouseRelease(int)
*/
void mouseRelease(int buttons);
public int getRGBPixel(int x, int y);
public int [] getRGBPixels(Rectangle bounds);
/**
* Simulates mouse wheel action.
*
* @param wheelAmt number of notches to move the mouse wheel
*
* @see Robot#mouseWheel(int)
*/
void mouseWheel(int wheelAmt);
public void dispose();
/**
* Simulates a key press of the specified key.
*
* @param keycode the key code to press
*
* @see Robot#keyPress(int)
*/
void keyPress(int keycode);
/**
* Simulates a key release of the specified key.
*
* @param keycode the key code to release
*
* @see Robot#keyRelease(int)
*/
void keyRelease(int keycode);
/**
* Gets the RGB value of the specified pixel on screen.
*
* @param x the X screen coordinate
* @param y the Y screen coordinate
*
* @return the RGB value of the specified pixel on screen
*
* @see Robot#getPixelColor(int, int)
*/
int getRGBPixel(int x, int y);
/**
* Gets the RGB values of the specified screen area as an array.
*
* @param bounds the screen area to capture the RGB values from
*
* @return the RGB values of the specified screen area
*
* @see Robot#createScreenCapture(Rectangle)
*/
int[] getRGBPixels(Rectangle bounds);
/**
* Disposes the robot peer when it is not needed anymore.
*/
void dispose();
/**
* Returns the number of buttons that the robot simulates.
*
* @return the number of buttons that the robot simulates
*/
int getNumberOfButtons();
}

View File

@ -25,8 +25,12 @@
package java.awt.peer;
import java.awt.Adjustable;
import java.awt.ScrollPane;
import java.awt.ScrollPaneAdjustable;
/**
* The peer interface for {@link ScrollPane}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -34,10 +38,60 @@ import java.awt.Adjustable;
* instances.
*/
public interface ScrollPanePeer extends ContainerPeer {
/**
* Returns the height of the horizontal scroll bar.
*
* @return the height of the horizontal scroll bar
*
* @see ScrollPane#getHScrollbarHeight()
*/
int getHScrollbarHeight();
/**
* Returns the width of the vertical scroll bar.
*
* @return the width of the vertical scroll bar
*
* @see ScrollPane#getVScrollbarWidth()
*/
int getVScrollbarWidth();
/**
* Sets the scroll position of the child.
*
* @param x the X coordinate of the scroll position
* @param y the Y coordinate of the scroll position
*
* @see ScrollPane#setScrollPosition(int, int)
*/
void setScrollPosition(int x, int y);
/**
* Called when the child component changes its size.
*
* @param w the new width of the child component
* @param h the new height of the child component
*
* @see ScrollPane#layout()
*/
void childResized(int w, int h);
/**
* Sets the unit increment of one of the scroll pane's adjustables.
*
* @param adj the scroll pane adjustable object
* @param u the unit increment
*
* @see ScrollPaneAdjustable#setUnitIncrement(int)
*/
void setUnitIncrement(Adjustable adj, int u);
/**
* Sets the value for one of the scroll pane's adjustables.
*
* @param adj the scroll pane adjustable object
* @param v the value to set
*/
void setValue(Adjustable adj, int v);
}

View File

@ -24,7 +24,11 @@
*/
package java.awt.peer;
import java.awt.Scrollbar;
/**
* The peer interface for {@link Scrollbar}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -32,7 +36,34 @@ package java.awt.peer;
* instances.
*/
public interface ScrollbarPeer extends ComponentPeer {
/**
* Sets the parameters for the scrollbar.
*
* @param value the current value
* @param visible how much of the whole scale is visible
* @param minimum the minimum value
* @param maximum the maximum value
*
* @see Scrollbar#setValues(int, int, int, int)
*/
void setValues(int value, int visible, int minimum, int maximum);
/**
* Sets the line increment of the scrollbar.
*
* @param l the line increment
*
* @see Scrollbar#setLineIncrement(int)
*/
void setLineIncrement(int l);
/**
* Sets the page increment of the scrollbar.
*
* @param l the page increment
*
* @see Scrollbar#setPageIncrement(int)
*/
void setPageIncrement(int l);
}

View File

@ -26,7 +26,20 @@
package java.awt.peer;
import java.awt.Dimension;
import java.awt.SystemTray;
/**
* The peer interface for {@link SystemTray}. This doesn't need to be
* implemented if {@link SystemTray#isSupported()} returns false.
*/
public interface SystemTrayPeer {
/**
* Returns the size of the system tray icon.
*
* @return the size of the system tray icon
*
* @see SystemTray#getTrayIconSize()
*/
Dimension getTrayIconSize();
}

View File

@ -25,8 +25,11 @@
package java.awt.peer;
import java.awt.Dimension;
import java.awt.TextArea;
/**
* The peer interface for {@link TexTArea}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -34,28 +37,52 @@ import java.awt.Dimension;
* instances.
*/
public interface TextAreaPeer extends TextComponentPeer {
/**
* Inserts the specified text at the specified position in the document.
*
* @param text the text to insert
* @param pos the position to insert
*
* @see TextArea#insert(String, int)
*/
void insert(String text, int pos);
/**
* Replaces a range of text by the specified string
*
* @param text the replacement string
* @param start the begin of the range to replace
* @param end the end of the range to replace
*
* @see TextArea#replaceRange(String, int, int)
*/
void replaceRange(String text, int start, int end);
/**
* Returns the preferred size of a textarea with the specified number of
* columns and rows.
*
* @param rows the number of rows
* @param columns the number of columns
*
* @return the preferred size of a textarea
*
* @see TextArea#getPreferredSize(int, int)
*/
Dimension getPreferredSize(int rows, int columns);
/**
* Returns the minimum size of a textarea with the specified number of
* columns and rows.
*
* @param rows the number of rows
* @param columns the number of columns
*
* @return the minimum size of a textarea
*
* @see TextArea#getMinimumSize(int, int)
*/
Dimension getMinimumSize(int rows, int columns);
/**
* DEPRECATED: Replaced by insert(String, int).
*/
void insertText(String txt, int pos);
/**
* DEPRECATED: Replaced by ReplaceRange(String, int, int).
*/
void replaceText(String txt, int start, int end);
/**
* DEPRECATED: Replaced by getPreferredSize(int, int).
*/
Dimension preferredSize(int rows, int cols);
/**
* DEPRECATED: Replaced by getMinimumSize(int, int).
*/
Dimension minimumSize(int rows, int cols);
}

View File

@ -24,10 +24,12 @@
*/
package java.awt.peer;
import java.awt.Rectangle;
import java.awt.TextComponent;
import java.awt.im.InputMethodRequests;
/**
* The peer interface for {@link TextComponent}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -35,16 +37,85 @@ import java.awt.im.InputMethodRequests;
* instances.
*/
public interface TextComponentPeer extends ComponentPeer {
/**
* Sets if the text component should be editable or not.
*
* @param editable {@code true} for editable text components,
* {@code false} for non-editable text components
*
* @see TextComponent#setEditable(boolean)
*/
void setEditable(boolean editable);
/**
* Returns the current content of the text component.
*
* @return the current content of the text component
*
* @see TextComponent#getText()
*/
String getText();
/**
* Sets the content for the text component.
*
* @param l the content to set
*
* @see TextComponent#setText(String)
*/
void setText(String l);
/**
* Returns the start index of the current selection.
*
* @return the start index of the current selection
*
* @see TextComponent#getSelectionStart()
*/
int getSelectionStart();
/**
* Returns the end index of the current selection.
*
* @return the end index of the current selection
*
* @see TextComponent#getSelectionEnd()
*/
int getSelectionEnd();
/**
* Selects an area of the text component.
*
* @param selStart the start index of the new selection
* @param selEnd the end index of the new selection
*
* @see TextComponent#select(int, int)
*/
void select(int selStart, int selEnd);
/**
* Sets the caret position of the text component.
*
* @param pos the caret position to set
*
* @see TextComponent#setCaretPosition(int)
*/
void setCaretPosition(int pos);
/**
* Returns the current caret position.
*
* @return the current caret position
*
* @see TextComponent#getCaretPosition()
*/
int getCaretPosition();
int getIndexAtPoint(int x, int y);
Rectangle getCharacterBounds(int i);
long filterEvents(long mask);
/**
* Returns the input method requests.
*
* @return the input method requests
*/
InputMethodRequests getInputMethodRequests();
}

View File

@ -25,8 +25,11 @@
package java.awt.peer;
import java.awt.Dimension;
import java.awt.TextField;
/**
* The peer interface for {@link TextField}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -34,22 +37,38 @@ import java.awt.Dimension;
* instances.
*/
public interface TextFieldPeer extends TextComponentPeer {
/**
* Sets the echo character.
*
* @param echoChar the echo character to set
*
* @see TextField#getEchoChar()
*/
void setEchoChar(char echoChar);
/**
* Returns the preferred size of the text field with the specified number
* of columns.
*
* @param columns the number of columns
*
* @return the preferred size of the text field
*
* @see TextField#getPreferredSize(int)
*/
Dimension getPreferredSize(int columns);
/**
* Returns the minimum size of the text field with the specified number
* of columns.
*
* @param columns the number of columns
*
* @return the minimum size of the text field
*
* @see TextField#getMinimumSize(int)
*/
Dimension getMinimumSize(int columns);
/**
* DEPRECATED: Replaced by setEchoChar(char echoChar).
*/
void setEchoCharacter(char c);
/**
* DEPRECATED: Replaced by getPreferredSize(int).
*/
Dimension preferredSize(int cols);
/**
* DEPRECATED: Replaced by getMinimumSize(int).
*/
Dimension minimumSize(int cols);
}

View File

@ -25,10 +25,56 @@
package java.awt.peer;
import java.awt.SystemTray;
import java.awt.TrayIcon;
/**
* The peer interface for the {@link TrayIcon}. This doesn't need to be
* implemented if {@link SystemTray#isSupported()} returns false.
*/
public interface TrayIconPeer {
/**
* Disposes the tray icon and releases and resources held by it.
*
* @see TrayIcon#removeNotify()
*/
void dispose();
/**
* Sets the tool tip for the tray icon.
*
* @param tooltip the tooltip to set
*
* @see TrayIcon#setToolTip(String)
*/
void setToolTip(String tooltip);
/**
* Updates the icon image. This is supposed to display the current icon
* from the TrayIcon component in the actual tray icon.
*
* @see TrayIcon#setImage(java.awt.Image)
* @see TrayIcon#setImageAutoSize(boolean)
*/
void updateImage();
/**
* Displays a message at the tray icon.
*
* @param caption the message caption
* @param text the actual message text
* @param messageType the message type
*
* @see TrayIcon#displayMessage(String, String, java.awt.TrayIcon.MessageType)
*/
void displayMessage(String caption, String text, String messageType);
/**
* Shows the popup menu of this tray icon at the specified position.
*
* @param x the X location for the popup menu
* @param y the Y location for the popup menu
*/
void showPopupMenu(int x, int y);
}

View File

@ -28,6 +28,8 @@ package java.awt.peer;
import java.awt.*;
/**
* The peer interface for {@link Window}.
*
* The peer interfaces are intended only for use in porting
* the AWT. They are not intended for use by application
* developers, and developers should not implement peers
@ -35,12 +37,59 @@ import java.awt.*;
* instances.
*/
public interface WindowPeer extends ContainerPeer {
/**
* Makes this window the topmost window on the desktop.
*
* @see Window#toFront()
*/
void toFront();
/**
* Makes this window the bottommost window on the desktop.
*
* @see Window#toBack()
*/
void toBack();
/**
* Sets if the window should always stay on top of all other windows or
* not.
*
* @param alwaysOnTop if the window should always stay on top of all other
* windows or not
*
* @see Window#setAlwaysOnTop(boolean)
*/
void setAlwaysOnTop(boolean alwaysOnTop);
/**
* Updates the window's focusable state.
*
* @see Window#setFocusableWindowState(boolean)
*/
void updateFocusableWindowState();
boolean requestWindowFocus();
/**
* Sets if this window is blocked by a modal dialog or not.
*
* @param blocker the blocking modal dialog
* @param blocked {@code true} to block the window, {@code false}
* to unblock it
*/
void setModalBlocked(Dialog blocker, boolean blocked);
/**
* Updates the minimum size on the peer.
*
* @see Window#setMinimumSize(Dimension)
*/
void updateMinimumSize();
/**
* Updates the icons for the window.
*
* @see Window#setIconImages(java.util.List)
*/
void updateIconImages();
}

View File

@ -90,7 +90,7 @@ public abstract class InputStream implements Closeable {
*
* @param b the buffer into which the data is read.
* @return the total number of bytes read into the buffer, or
* <code>-1</code> is there is no more data because the end of
* <code>-1</code> if there is no more data because the end of
* the stream has been reached.
* @exception IOException If the first byte cannot be read for any reason
* other than the end of the file, if the input stream has been closed, or

View File

@ -1,5 +1,5 @@
/*
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003-2009 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
@ -34,6 +34,13 @@ import java.io.ObjectStreamException;
/**
* This is the common base class of all Java language enumeration types.
*
* More information about enums, including descriptions of the
* implicitly declared methods synthesized by the compiler, can be
* found in <i>The Java&trade; Language Specification, Third
* Edition</i>, <a
* href="http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.9">&sect;8.9</a>.
*
* @param <E> The enum type subclass
* @author Josh Bloch
* @author Neal Gafter
* @see Class#getEnumConstants()
@ -192,6 +199,15 @@ public abstract class Enum<E extends Enum<E>>
* to declare an enum constant in this type. (Extraneous whitespace
* characters are not permitted.)
*
* <p>Note that for a particular enum type {@code T}, the
* implicitly declared {@code public static T valueOf(String)}
* method on that enum may be used instead of this method to map
* from a name to the corresponding enum constant. All the
* constants of an enum type can be obtained by calling the
* implicit {@code public static T[] values()} method of that
* type.
*
* @param <T> The enum type whose constant is to be returned
* @param enumType the {@code Class} object of the enum type from which
* to return a constant
* @param name the name of the constant to return
@ -212,7 +228,7 @@ public abstract class Enum<E extends Enum<E>>
if (name == null)
throw new NullPointerException("Name is null");
throw new IllegalArgumentException(
"No enum const " + enumType +"." + name);
"No enum constant " + enumType.getCanonicalName() + "." + name);
}
/**
@ -225,10 +241,10 @@ public abstract class Enum<E extends Enum<E>>
*/
private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException {
throw new InvalidObjectException("can't deserialize enum");
throw new InvalidObjectException("can't deserialize enum");
}
private void readObjectNoData() throws ObjectStreamException {
throw new InvalidObjectException("can't deserialize enum");
throw new InvalidObjectException("can't deserialize enum");
}
}

View File

@ -26,8 +26,8 @@
package java.lang;
/**
* Class <code>Object</code> is the root of the class hierarchy.
* Every class has <code>Object</code> as a superclass. All objects,
* Class {@code Object} is the root of the class hierarchy.
* Every class has {@code Object} as a superclass. All objects,
* including arrays, implement the methods of this class.
*
* @author unascribed
@ -66,30 +66,30 @@ public class Object {
/**
* Returns a hash code value for the object. This method is
* supported for the benefit of hashtables such as those provided by
* <code>java.util.Hashtable</code>.
* supported for the benefit of hash tables such as those provided by
* {@link java.util.HashMap}.
* <p>
* The general contract of <code>hashCode</code> is:
* The general contract of {@code hashCode} is:
* <ul>
* <li>Whenever it is invoked on the same object more than once during
* an execution of a Java application, the <tt>hashCode</tt> method
* an execution of a Java application, the {@code hashCode} method
* must consistently return the same integer, provided no information
* used in <tt>equals</tt> comparisons on the object is modified.
* used in {@code equals} comparisons on the object is modified.
* This integer need not remain consistent from one execution of an
* application to another execution of the same application.
* <li>If two objects are equal according to the <tt>equals(Object)</tt>
* method, then calling the <code>hashCode</code> method on each of
* <li>If two objects are equal according to the {@code equals(Object)}
* method, then calling the {@code hashCode} method on each of
* the two objects must produce the same integer result.
* <li>It is <em>not</em> required that if two objects are unequal
* according to the {@link java.lang.Object#equals(java.lang.Object)}
* method, then calling the <tt>hashCode</tt> method on each of the
* method, then calling the {@code hashCode} method on each of the
* two objects must produce distinct integer results. However, the
* programmer should be aware that producing distinct integer results
* for unequal objects may improve the performance of hashtables.
* for unequal objects may improve the performance of hash tables.
* </ul>
* <p>
* As much as is reasonably practical, the hashCode method defined by
* class <tt>Object</tt> does return distinct integers for distinct
* class {@code Object} does return distinct integers for distinct
* objects. (This is typically implemented by converting the internal
* address of the object into an integer, but this implementation
* technique is not required by the
@ -97,55 +97,55 @@ public class Object {
*
* @return a hash code value for this object.
* @see java.lang.Object#equals(java.lang.Object)
* @see java.util.Hashtable
* @see java.lang.System#identityHashCode
*/
public native int hashCode();
/**
* Indicates whether some other object is "equal to" this one.
* <p>
* The <code>equals</code> method implements an equivalence relation
* The {@code equals} method implements an equivalence relation
* on non-null object references:
* <ul>
* <li>It is <i>reflexive</i>: for any non-null reference value
* <code>x</code>, <code>x.equals(x)</code> should return
* <code>true</code>.
* {@code x}, {@code x.equals(x)} should return
* {@code true}.
* <li>It is <i>symmetric</i>: for any non-null reference values
* <code>x</code> and <code>y</code>, <code>x.equals(y)</code>
* should return <code>true</code> if and only if
* <code>y.equals(x)</code> returns <code>true</code>.
* {@code x} and {@code y}, {@code x.equals(y)}
* should return {@code true} if and only if
* {@code y.equals(x)} returns {@code true}.
* <li>It is <i>transitive</i>: for any non-null reference values
* <code>x</code>, <code>y</code>, and <code>z</code>, if
* <code>x.equals(y)</code> returns <code>true</code> and
* <code>y.equals(z)</code> returns <code>true</code>, then
* <code>x.equals(z)</code> should return <code>true</code>.
* {@code x}, {@code y}, and {@code z}, if
* {@code x.equals(y)} returns {@code true} and
* {@code y.equals(z)} returns {@code true}, then
* {@code x.equals(z)} should return {@code true}.
* <li>It is <i>consistent</i>: for any non-null reference values
* <code>x</code> and <code>y</code>, multiple invocations of
* <tt>x.equals(y)</tt> consistently return <code>true</code>
* or consistently return <code>false</code>, provided no
* information used in <code>equals</code> comparisons on the
* {@code x} and {@code y}, multiple invocations of
* {@code x.equals(y)} consistently return {@code true}
* or consistently return {@code false}, provided no
* information used in {@code equals} comparisons on the
* objects is modified.
* <li>For any non-null reference value <code>x</code>,
* <code>x.equals(null)</code> should return <code>false</code>.
* <li>For any non-null reference value {@code x},
* {@code x.equals(null)} should return {@code false}.
* </ul>
* <p>
* The <tt>equals</tt> method for class <code>Object</code> implements
* The {@code equals} method for class {@code Object} implements
* the most discriminating possible equivalence relation on objects;
* that is, for any non-null reference values <code>x</code> and
* <code>y</code>, this method returns <code>true</code> if and only
* if <code>x</code> and <code>y</code> refer to the same object
* (<code>x == y</code> has the value <code>true</code>).
* that is, for any non-null reference values {@code x} and
* {@code y}, this method returns {@code true} if and only
* if {@code x} and {@code y} refer to the same object
* ({@code x == y} has the value {@code true}).
* <p>
* Note that it is generally necessary to override the <tt>hashCode</tt>
* Note that it is generally necessary to override the {@code hashCode}
* method whenever this method is overridden, so as to maintain the
* general contract for the <tt>hashCode</tt> method, which states
* general contract for the {@code hashCode} method, which states
* that equal objects must have equal hash codes.
*
* @param obj the reference object with which to compare.
* @return <code>true</code> if this object is the same as the obj
* argument; <code>false</code> otherwise.
* @return {@code true} if this object is the same as the obj
* argument; {@code false} otherwise.
* @see #hashCode()
* @see java.util.Hashtable
* @see java.util.HashMap
*/
public boolean equals(Object obj) {
return (this == obj);
@ -154,7 +154,7 @@ public class Object {
/**
* Creates and returns a copy of this object. The precise meaning
* of "copy" may depend on the class of the object. The general
* intent is that, for any object <tt>x</tt>, the expression:
* intent is that, for any object {@code x}, the expression:
* <blockquote>
* <pre>
* x.clone() != x</pre></blockquote>
@ -162,49 +162,49 @@ public class Object {
* <blockquote>
* <pre>
* x.clone().getClass() == x.getClass()</pre></blockquote>
* will be <tt>true</tt>, but these are not absolute requirements.
* will be {@code true}, but these are not absolute requirements.
* While it is typically the case that:
* <blockquote>
* <pre>
* x.clone().equals(x)</pre></blockquote>
* will be <tt>true</tt>, this is not an absolute requirement.
* will be {@code true}, this is not an absolute requirement.
* <p>
* By convention, the returned object should be obtained by calling
* <tt>super.clone</tt>. If a class and all of its superclasses (except
* <tt>Object</tt>) obey this convention, it will be the case that
* <tt>x.clone().getClass() == x.getClass()</tt>.
* {@code super.clone}. If a class and all of its superclasses (except
* {@code Object}) obey this convention, it will be the case that
* {@code x.clone().getClass() == x.getClass()}.
* <p>
* By convention, the object returned by this method should be independent
* of this object (which is being cloned). To achieve this independence,
* it may be necessary to modify one or more fields of the object returned
* by <tt>super.clone</tt> before returning it. Typically, this means
* by {@code super.clone} before returning it. Typically, this means
* copying any mutable objects that comprise the internal "deep structure"
* of the object being cloned and replacing the references to these
* objects with references to the copies. If a class contains only
* primitive fields or references to immutable objects, then it is usually
* the case that no fields in the object returned by <tt>super.clone</tt>
* the case that no fields in the object returned by {@code super.clone}
* need to be modified.
* <p>
* The method <tt>clone</tt> for class <tt>Object</tt> performs a
* The method {@code clone} for class {@code Object} performs a
* specific cloning operation. First, if the class of this object does
* not implement the interface <tt>Cloneable</tt>, then a
* <tt>CloneNotSupportedException</tt> is thrown. Note that all arrays
* are considered to implement the interface <tt>Cloneable</tt>.
* not implement the interface {@code Cloneable}, then a
* {@code CloneNotSupportedException} is thrown. Note that all arrays
* are considered to implement the interface {@code Cloneable}.
* Otherwise, this method creates a new instance of the class of this
* object and initializes all its fields with exactly the contents of
* the corresponding fields of this object, as if by assignment; the
* contents of the fields are not themselves cloned. Thus, this method
* performs a "shallow copy" of this object, not a "deep copy" operation.
* <p>
* The class <tt>Object</tt> does not itself implement the interface
* <tt>Cloneable</tt>, so calling the <tt>clone</tt> method on an object
* whose class is <tt>Object</tt> will result in throwing an
* The class {@code Object} does not itself implement the interface
* {@code Cloneable}, so calling the {@code clone} method on an object
* whose class is {@code Object} will result in throwing an
* exception at run time.
*
* @return a clone of this instance.
* @exception CloneNotSupportedException if the object's class does not
* support the <code>Cloneable</code> interface. Subclasses
* that override the <code>clone</code> method can also
* support the {@code Cloneable} interface. Subclasses
* that override the {@code clone} method can also
* throw this exception to indicate that an instance cannot
* be cloned.
* @see java.lang.Cloneable
@ -213,15 +213,15 @@ public class Object {
/**
* Returns a string representation of the object. In general, the
* <code>toString</code> method returns a string that
* {@code toString} method returns a string that
* "textually represents" this object. The result should
* be a concise but informative representation that is easy for a
* person to read.
* It is recommended that all subclasses override this method.
* <p>
* The <code>toString</code> method for class <code>Object</code>
* The {@code toString} method for class {@code Object}
* returns a string consisting of the name of the class of which the
* object is an instance, the at-sign character `<code>@</code>', and
* object is an instance, the at-sign character `{@code @}', and
* the unsigned hexadecimal representation of the hash code of the
* object. In other words, this method returns a string equal to the
* value of:
@ -241,7 +241,7 @@ public class Object {
* monitor. If any threads are waiting on this object, one of them
* is chosen to be awakened. The choice is arbitrary and occurs at
* the discretion of the implementation. A thread waits on an object's
* monitor by calling one of the <code>wait</code> methods.
* monitor by calling one of the {@code wait} methods.
* <p>
* The awakened thread will not be able to proceed until the current
* thread relinquishes the lock on this object. The awakened thread will
@ -255,9 +255,9 @@ public class Object {
* object's monitor in one of three ways:
* <ul>
* <li>By executing a synchronized instance method of that object.
* <li>By executing the body of a <code>synchronized</code> statement
* <li>By executing the body of a {@code synchronized} statement
* that synchronizes on the object.
* <li>For objects of type <code>Class,</code> by executing a
* <li>For objects of type {@code Class,} by executing a
* synchronized static method of that class.
* </ul>
* <p>
@ -273,7 +273,7 @@ public class Object {
/**
* Wakes up all threads that are waiting on this object's monitor. A
* thread waits on an object's monitor by calling one of the
* <code>wait</code> methods.
* {@code wait} methods.
* <p>
* The awakened threads will not be able to proceed until the current
* thread relinquishes the lock on this object. The awakened threads
@ -283,7 +283,7 @@ public class Object {
* being the next thread to lock this object.
* <p>
* This method should only be called by a thread that is the owner
* of this object's monitor. See the <code>notify</code> method for a
* of this object's monitor. See the {@code notify} method for a
* description of the ways in which a thread can become the owner of
* a monitor.
*
@ -308,15 +308,15 @@ public class Object {
* becomes disabled for thread scheduling purposes and lies dormant
* until one of four things happens:
* <ul>
* <li>Some other thread invokes the <tt>notify</tt> method for this
* <li>Some other thread invokes the {@code notify} method for this
* object and thread <var>T</var> happens to be arbitrarily chosen as
* the thread to be awakened.
* <li>Some other thread invokes the <tt>notifyAll</tt> method for this
* <li>Some other thread invokes the {@code notifyAll} method for this
* object.
* <li>Some other thread {@linkplain Thread#interrupt() interrupts}
* thread <var>T</var>.
* <li>The specified amount of real time has elapsed, more or less. If
* <tt>timeout</tt> is zero, however, then real time is not taken into
* {@code timeout} is zero, however, then real time is not taken into
* consideration and the thread simply waits until notified.
* </ul>
* The thread <var>T</var> is then removed from the wait set for this
@ -324,11 +324,11 @@ public class Object {
* usual manner with other threads for the right to synchronize on the
* object; once it has gained control of the object, all its
* synchronization claims on the object are restored to the status quo
* ante - that is, to the situation as of the time that the <tt>wait</tt>
* ante - that is, to the situation as of the time that the {@code wait}
* method was invoked. Thread <var>T</var> then returns from the
* invocation of the <tt>wait</tt> method. Thus, on return from the
* <tt>wait</tt> method, the synchronization state of the object and of
* thread <tt>T</tt> is exactly as it was when the <tt>wait</tt> method
* invocation of the {@code wait} method. Thus, on return from the
* {@code wait} method, the synchronization state of the object and of
* thread {@code T} is exactly as it was when the {@code wait} method
* was invoked.
* <p>
* A thread can also wake up without being notified, interrupted, or
@ -351,18 +351,18 @@ public class Object {
*
* <p>If the current thread is {@linkplain java.lang.Thread#interrupt()
* interrupted} by any thread before or while it is waiting, then an
* <tt>InterruptedException</tt> is thrown. This exception is not
* {@code InterruptedException} is thrown. This exception is not
* thrown until the lock status of this object has been restored as
* described above.
*
* <p>
* Note that the <tt>wait</tt> method, as it places the current thread
* Note that the {@code wait} method, as it places the current thread
* into the wait set for this object, unlocks only this object; any
* other objects on which the current thread may be synchronized remain
* locked while the thread waits.
* <p>
* This method should only be called by a thread that is the owner
* of this object's monitor. See the <code>notify</code> method for a
* of this object's monitor. See the {@code notify} method for a
* description of the ways in which a thread can become the owner of
* a monitor.
*
@ -388,7 +388,7 @@ public class Object {
* some other thread interrupts the current thread, or a certain
* amount of real time has elapsed.
* <p>
* This method is similar to the <code>wait</code> method of one
* This method is similar to the {@code wait} method of one
* argument, but it allows finer control over the amount of time to
* wait for a notification before giving up. The amount of real time,
* measured in nanoseconds, is given by:
@ -398,17 +398,17 @@ public class Object {
* <p>
* In all other respects, this method does the same thing as the
* method {@link #wait(long)} of one argument. In particular,
* <tt>wait(0, 0)</tt> means the same thing as <tt>wait(0)</tt>.
* {@code wait(0, 0)} means the same thing as {@code wait(0)}.
* <p>
* The current thread must own this object's monitor. The thread
* releases ownership of this monitor and waits until either of the
* following two conditions has occurred:
* <ul>
* <li>Another thread notifies threads waiting on this object's monitor
* to wake up either through a call to the <code>notify</code> method
* or the <code>notifyAll</code> method.
* <li>The timeout period, specified by <code>timeout</code>
* milliseconds plus <code>nanos</code> nanoseconds arguments, has
* to wake up either through a call to the {@code notify} method
* or the {@code notifyAll} method.
* <li>The timeout period, specified by {@code timeout}
* milliseconds plus {@code nanos} nanoseconds arguments, has
* elapsed.
* </ul>
* <p>
@ -425,7 +425,7 @@ public class Object {
* }
* </pre>
* This method should only be called by a thread that is the owner
* of this object's monitor. See the <code>notify</code> method for a
* of this object's monitor. See the {@code notify} method for a
* description of the ways in which a thread can become the owner of
* a monitor.
*
@ -465,13 +465,13 @@ public class Object {
* {@link java.lang.Object#notify()} method or the
* {@link java.lang.Object#notifyAll()} method for this object.
* In other words, this method behaves exactly as if it simply
* performs the call <tt>wait(0)</tt>.
* performs the call {@code wait(0)}.
* <p>
* The current thread must own this object's monitor. The thread
* releases ownership of this monitor and waits until another thread
* notifies threads waiting on this object's monitor to wake up
* either through a call to the <code>notify</code> method or the
* <code>notifyAll</code> method. The thread then waits until it can
* either through a call to the {@code notify} method or the
* {@code notifyAll} method. The thread then waits until it can
* re-obtain ownership of the monitor and resumes execution.
* <p>
* As in the one argument version, interrupts and spurious wakeups are
@ -484,7 +484,7 @@ public class Object {
* }
* </pre>
* This method should only be called by a thread that is the owner
* of this object's monitor. See the <code>notify</code> method for a
* of this object's monitor. See the {@code notify} method for a
* description of the ways in which a thread can become the owner of
* a monitor.
*
@ -505,49 +505,49 @@ public class Object {
/**
* Called by the garbage collector on an object when garbage collection
* determines that there are no more references to the object.
* A subclass overrides the <code>finalize</code> method to dispose of
* A subclass overrides the {@code finalize} method to dispose of
* system resources or to perform other cleanup.
* <p>
* The general contract of <tt>finalize</tt> is that it is invoked
* The general contract of {@code finalize} is that it is invoked
* if and when the Java<font size="-2"><sup>TM</sup></font> virtual
* machine has determined that there is no longer any
* means by which this object can be accessed by any thread that has
* not yet died, except as a result of an action taken by the
* finalization of some other object or class which is ready to be
* finalized. The <tt>finalize</tt> method may take any action, including
* finalized. The {@code finalize} method may take any action, including
* making this object available again to other threads; the usual purpose
* of <tt>finalize</tt>, however, is to perform cleanup actions before
* of {@code finalize}, however, is to perform cleanup actions before
* the object is irrevocably discarded. For example, the finalize method
* for an object that represents an input/output connection might perform
* explicit I/O transactions to break the connection before the object is
* permanently discarded.
* <p>
* The <tt>finalize</tt> method of class <tt>Object</tt> performs no
* The {@code finalize} method of class {@code Object} performs no
* special action; it simply returns normally. Subclasses of
* <tt>Object</tt> may override this definition.
* {@code Object} may override this definition.
* <p>
* The Java programming language does not guarantee which thread will
* invoke the <tt>finalize</tt> method for any given object. It is
* invoke the {@code finalize} method for any given object. It is
* guaranteed, however, that the thread that invokes finalize will not
* be holding any user-visible synchronization locks when finalize is
* invoked. If an uncaught exception is thrown by the finalize method,
* the exception is ignored and finalization of that object terminates.
* <p>
* After the <tt>finalize</tt> method has been invoked for an object, no
* After the {@code finalize} method has been invoked for an object, no
* further action is taken until the Java virtual machine has again
* determined that there is no longer any means by which this object can
* be accessed by any thread that has not yet died, including possible
* actions by other objects or classes which are ready to be finalized,
* at which point the object may be discarded.
* <p>
* The <tt>finalize</tt> method is never invoked more than once by a Java
* The {@code finalize} method is never invoked more than once by a Java
* virtual machine for any given object.
* <p>
* Any exception thrown by the <code>finalize</code> method causes
* Any exception thrown by the {@code finalize} method causes
* the finalization of this object to be halted, but is otherwise
* ignored.
*
* @throws Throwable the <code>Exception</code> raised by this method
* @throws Throwable the {@code Exception} raised by this method
*/
protected void finalize() throws Throwable { }
}

View File

@ -100,6 +100,13 @@ import java.util.StringTokenizer;
* </tr>
*
* <tr>
* <td>closeClassLoader</td>
* <td>Closing of a ClassLoader</td>
* <td>Granting this permission allows code to close any URLClassLoader
* that it has a reference to.</td>
* </tr>
*
* <tr>
* <td>setSecurityManager</td>
* <td>Setting of the security manager (possibly replacing an existing one)
* </td>

View File

@ -1,5 +1,5 @@
/*
* Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003-2009 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,6 +31,10 @@ package java.lang.annotation;
* an annotation type. Also note that this interface does not itself
* define an annotation type.
*
* More information about annotation types can be found in <i>The
* Java&trade; Language Specification, Third Edition</i>, <a
* href="http://java.sun.com/docs/books/jls/third_edition/html/interfaces.html#9.6">&sect;9.6</a>.
*
* @author Josh Bloch
* @since 1.5
*/

View File

@ -1,3 +1,28 @@
<!--
Copyright 2003-2006 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
under the terms of the GNU General Public License version 2 only, as
published by the Free Software Foundation. Sun designates this
particular file as subject to the "Classpath" exception as provided
by Sun in the LICENSE file that accompanied this code.
This code is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
version 2 for more details (a copy is included in the LICENSE file that
accompanied this code).
You should have received a copy of the GNU General Public License version
2 along with this work; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
CA 95054 USA or visit www.sun.com if you need additional information or
have any questions.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>

View File

@ -107,8 +107,9 @@ import java.io.IOException;
* </ul>
* </blockquote>
*
* <p>The implementation conforms to RFC 2965, section 3.3.
* <p>The implementation conforms to <a href="http://www.ietf.org/rfc/rfc2965.txt">RFC 2965</a>, section 3.3.
*
* @see CookiePolicy
* @author Edward Wang
* @since 1.6
*/

View File

@ -33,6 +33,7 @@ import java.util.TimeZone;
import java.util.Date;
import java.lang.NullPointerException; // for javadoc
import java.util.Locale;
/**
* An HttpCookie object represents an http cookie, which carries state
@ -1058,8 +1059,7 @@ public final class HttpCookie implements Cloneable {
if (assignor != null) {
assignor.assign(cookie, attrName, attrValue);
} else {
// must be an error
throw new IllegalArgumentException("Illegal cookie attribute");
// Ignore the attribute as per RFC 2965
}
}
@ -1097,7 +1097,7 @@ public final class HttpCookie implements Cloneable {
static {
cDateFormats = new SimpleDateFormat[COOKIE_DATE_FORMATS.length];
for (int i = 0; i < COOKIE_DATE_FORMATS.length; i++) {
cDateFormats[i] = new SimpleDateFormat(COOKIE_DATE_FORMATS[i]);
cDateFormats[i] = new SimpleDateFormat(COOKIE_DATE_FORMATS[i], Locale.US);
cDateFormats[i].setTimeZone(TimeZone.getTimeZone("GMT"));
}
}

View File

@ -31,10 +31,12 @@ import java.io.File;
import java.io.FilePermission;
import java.io.InputStream;
import java.io.IOException;
import java.io.Closeable;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandlerFactory;
import java.util.Enumeration;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
import java.util.jar.Manifest;
@ -70,7 +72,7 @@ import sun.security.util.SecurityConstants;
* @author David Connelly
* @since 1.2
*/
public class URLClassLoader extends SecureClassLoader {
public class URLClassLoader extends SecureClassLoader implements Closeable {
/* The search path for classes and resources */
URLClassPath ucp;
@ -85,13 +87,13 @@ public class URLClassLoader extends SecureClassLoader {
* to refer to a JAR file which will be downloaded and opened as needed.
*
* <p>If there is a security manager, this method first
* calls the security manager's <code>checkCreateClassLoader</code> method
* calls the security manager's {@code checkCreateClassLoader} method
* to ensure creation of a class loader is allowed.
*
* @param urls the URLs from which to load classes and resources
* @param parent the parent class loader for delegation
* @exception SecurityException if a security manager exists and its
* <code>checkCreateClassLoader</code> method doesn't allow
* {@code checkCreateClassLoader} method doesn't allow
* creation of a class loader.
* @see SecurityManager#checkCreateClassLoader
*/
@ -169,12 +171,65 @@ public class URLClassLoader extends SecureClassLoader {
acc = AccessController.getContext();
}
/**
* Closes this URLClassLoader, so that it can no longer be used to load
* new classes or resources that are defined by this loader.
* Classes and resources defined by any of this loader's parents in the
* delegation hierarchy are still accessible. Also, any classes or resources
* that are already loaded, are still accessible.
* <p>
* In the case of jar: and file: URLs, it also closes any class files,
* or JAR files that were opened by it. If another thread is loading a
* class when the {@code close} method is invoked, then the result of
* that load is undefined.
* <p>
* The method makes a best effort attempt to close all opened files,
* by catching {@link IOException}s internally. Unchecked exceptions
* and errors are not caught. Calling close on an already closed
* loader has no effect.
* <p>
* @throws IOException if closing any file opened by this class loader
* resulted in an IOException. Any such exceptions are caught, and a
* single IOException is thrown after the last file has been closed.
* If only one exception was thrown, it will be set as the <i>cause</i>
* of this IOException.
*
* @throws SecurityException if a security manager is set, and it denies
* {@link RuntimePermission}<tt>("closeClassLoader")</tt>
*
* @since 1.7
*/
public void close() throws IOException {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(new RuntimePermission("closeClassLoader"));
}
List<IOException> errors = ucp.closeLoaders();
if (errors.isEmpty()) {
return;
}
if (errors.size() == 1) {
throw new IOException (
"Error closing URLClassLoader resource",
errors.get(0)
);
}
// Several exceptions. So, just combine the error messages
String errormsg = "Error closing resources: ";
for (IOException error: errors) {
errormsg = errormsg + "[" + error.toString() + "] ";
}
throw new IOException (errormsg);
}
/**
* Appends the specified URL to the list of URLs to search for
* classes and resources.
* <p>
* If the URL specified is <code>null</code> or is already in the
* list of URLs, then invoking this method has no effect.
* list of URLs, or if this loader is closed, then invoking this
* method has no effect.
*
* @param url the URL to be added to the search path of URLs
*/
@ -199,7 +254,8 @@ public class URLClassLoader extends SecureClassLoader {
*
* @param name the name of the class
* @return the resulting class
* @exception ClassNotFoundException if the class could not be found
* @exception ClassNotFoundException if the class could not be found,
* or if the loader is closed.
*/
protected Class<?> findClass(final String name)
throws ClassNotFoundException
@ -370,7 +426,7 @@ public class URLClassLoader extends SecureClassLoader {
*
* @param name the name of the resource
* @return a <code>URL</code> for the resource, or <code>null</code>
* if the resource could not be found.
* if the resource could not be found, or if the loader is closed.
*/
public URL findResource(final String name) {
/*
@ -393,6 +449,7 @@ public class URLClassLoader extends SecureClassLoader {
* @param name the resource name
* @exception IOException if an I/O exception occurs
* @return an <code>Enumeration</code> of <code>URL</code>s
* If the loader is closed, the Enumeration will be empty.
*/
public Enumeration<URL> findResources(final String name)
throws IOException

File diff suppressed because it is too large Load Diff

View File

@ -27,6 +27,7 @@
package java.util.logging;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.security.*;
import java.lang.ref.WeakReference;
@ -165,10 +166,11 @@ public class Logger {
private static final int offValue = Level.OFF.intValue();
private LogManager manager;
private String name;
private ArrayList<Handler> handlers;
private final CopyOnWriteArrayList<Handler> handlers =
new CopyOnWriteArrayList<Handler>();
private String resourceBundleName;
private boolean useParentHandlers = true;
private Filter filter;
private volatile boolean useParentHandlers = true;
private volatile Filter filter;
private boolean anonymous;
private ResourceBundle catalog; // Cached resource bundle
@ -180,9 +182,9 @@ public class Logger {
private static Object treeLock = new Object();
// We keep weak references from parents to children, but strong
// references from children to parents.
private Logger parent; // our nearest parent.
private volatile Logger parent; // our nearest parent.
private ArrayList<WeakReference<Logger>> kids; // WeakReferences to loggers that have us as parent
private Level levelObject;
private volatile Level levelObject;
private volatile int levelValue; // current effective level value
/**
@ -438,7 +440,7 @@ public class Logger {
* @exception SecurityException if a security manager exists and if
* the caller does not have LoggingPermission("control").
*/
public synchronized void setFilter(Filter newFilter) throws SecurityException {
public void setFilter(Filter newFilter) throws SecurityException {
checkAccess();
filter = newFilter;
}
@ -448,7 +450,7 @@ public class Logger {
*
* @return a filter object (may be null)
*/
public synchronized Filter getFilter() {
public Filter getFilter() {
return filter;
}
@ -465,10 +467,9 @@ public class Logger {
if (record.getLevel().intValue() < levelValue || levelValue == offValue) {
return;
}
synchronized (this) {
if (filter != null && !filter.isLoggable(record)) {
return;
}
Filter theFilter = filter;
if (theFilter != null && !theFilter.isLoggable(record)) {
return;
}
// Post the LogRecord to all our Handlers, and then to
@ -476,12 +477,8 @@ public class Logger {
Logger logger = this;
while (logger != null) {
Handler targets[] = logger.getHandlers();
if (targets != null) {
for (int i = 0; i < targets.length; i++) {
targets[i].publish(record);
}
for (Handler handler : logger.handlers) {
handler.publish(record);
}
if (!logger.getUseParentHandlers()) {
@ -1182,13 +1179,10 @@ public class Logger {
* @exception SecurityException if a security manager exists and if
* the caller does not have LoggingPermission("control").
*/
public synchronized void addHandler(Handler handler) throws SecurityException {
public void addHandler(Handler handler) throws SecurityException {
// Check for null handler
handler.getClass();
checkAccess();
if (handlers == null) {
handlers = new ArrayList<Handler>();
}
handlers.add(handler);
}
@ -1201,14 +1195,11 @@ public class Logger {
* @exception SecurityException if a security manager exists and if
* the caller does not have LoggingPermission("control").
*/
public synchronized void removeHandler(Handler handler) throws SecurityException {
public void removeHandler(Handler handler) throws SecurityException {
checkAccess();
if (handler == null) {
return;
}
if (handlers == null) {
return;
}
handlers.remove(handler);
}
@ -1217,11 +1208,8 @@ public class Logger {
* <p>
* @return an array of all registered Handlers
*/
public synchronized Handler[] getHandlers() {
if (handlers == null) {
return emptyHandlers;
}
return handlers.toArray(new Handler[handlers.size()]);
public Handler[] getHandlers() {
return handlers.toArray(emptyHandlers);
}
/**
@ -1235,7 +1223,7 @@ public class Logger {
* @exception SecurityException if a security manager exists and if
* the caller does not have LoggingPermission("control").
*/
public synchronized void setUseParentHandlers(boolean useParentHandlers) {
public void setUseParentHandlers(boolean useParentHandlers) {
checkAccess();
this.useParentHandlers = useParentHandlers;
}
@ -1246,7 +1234,7 @@ public class Logger {
*
* @return true if output is to be sent to the logger's parent
*/
public synchronized boolean getUseParentHandlers() {
public boolean getUseParentHandlers() {
return useParentHandlers;
}
@ -1354,9 +1342,12 @@ public class Logger {
* @return nearest existing parent Logger
*/
public Logger getParent() {
synchronized (treeLock) {
return parent;
}
// Note: this used to be synchronized on treeLock. However, this only
// provided memory semantics, as there was no guarantee that the caller
// would synchronize on treeLock (in fact, there is no way for external
// callers to so synchronize). Therefore, we have made parent volatile
// instead.
return parent;
}
/**

View File

@ -34,6 +34,7 @@ import javax.swing.plaf.RootPaneUI;
import java.util.Vector;
import java.io.Serializable;
import javax.swing.border.*;
import sun.awt.AWTAccessor;
import sun.security.action.GetBooleanAction;
@ -688,6 +689,9 @@ public class JRootPane extends JComponent implements Accessible {
throw new NullPointerException("glassPane cannot be set to null.");
}
AWTAccessor.getComponentAccessor().setMixingCutoutShape(glass,
new Rectangle());
boolean visible = false;
if (glassPane != null && glassPane.getParent() == this) {
this.remove(glassPane);

View File

@ -0,0 +1,77 @@
/*
* Copyright 2009 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.awt;
import java.awt.*;
import sun.misc.Unsafe;
/** The AWTAccessor utility class.
* The main purpose of this class is to enable accessing
* private and package-private fields of classes from
* different classes/packages. See sun.misc.SharedSecretes
* for another example.
*/
public final class AWTAccessor {
private static final Unsafe unsafe = Unsafe.getUnsafe();
/** We don't need any objects of this class.
* It's rather a collection of static methods
* and interfaces.
*/
private AWTAccessor() {
}
/** An accessor for the java.awt.Component class.
*/
public interface ComponentAccessor {
// See 6797587
// Also see: 6776743, 6768307, and 6768332.
/**
* Sets the shape of a lw component to cut out from hw components.
*/
void setMixingCutoutShape(Component comp, Shape shape);
}
/* The java.awt.Component class accessor object.
*/
private static ComponentAccessor componentAccessor;
/** Set an accessor object for the java.awt.Component class.
*/
public static void setComponentAccessor(ComponentAccessor ca) {
componentAccessor = ca;
}
/** Retrieve the accessor object for the java.awt.Window class.
*/
public static ComponentAccessor getComponentAccessor() {
if (componentAccessor == null) {
unsafe.ensureClassInitialized(Component.class);
}
return componentAccessor;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-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
@ -456,6 +456,10 @@ public class HeadlessToolkit extends Toolkit
return tk.getAWTEventListeners();
}
public AWTEventListener[] getAWTEventListeners(long eventMask) {
return tk.getAWTEventListeners(eventMask);
}
public boolean isDesktopSupported() {
return false;
}
@ -464,4 +468,8 @@ public class HeadlessToolkit extends Toolkit
throws HeadlessException{
throw new HeadlessException();
}
public boolean areExtraMouseButtonsEnabled() throws HeadlessException{
throw new HeadlessException();
}
}

View File

@ -1972,6 +1972,21 @@ public abstract class SunToolkit extends Toolkit
AWTAutoShutdown.getInstance().dumpPeers(aLog);
}
private static Boolean sunAwtDisableMixing = null;
/**
* Returns the value of "sun.awt.disableMixing" property. Default
* value is {@code false}.
*/
public synchronized static boolean getSunAwtDisableMixing() {
if (sunAwtDisableMixing == null) {
sunAwtDisableMixing = Boolean.valueOf(
AccessController.doPrivileged(
new GetBooleanAction("sun.awt.disableMixing")));
}
return sunAwtDisableMixing.booleanValue();
}
/**
* Returns true if the native GTK libraries are available. The
* default implementation returns false, but UNIXToolkit overrides this
@ -2008,26 +2023,12 @@ class PostEventQueue {
/*
* Continually post pending AWTEvents to the Java EventQueue.
*/
public void flush() {
if (queueHead != null) {
EventQueueItem tempQueue;
/*
* We have to execute the loop inside the synchronized block
* to ensure that the flush is completed before a new event
* can be posted to this queue.
*/
synchronized (this) {
tempQueue = queueHead;
queueHead = queueTail = null;
/*
* If this PostEventQueue is flushed in parallel on two
* different threads tempQueue will be null for one of them.
*/
while (tempQueue != null) {
eventQueue.postEvent(tempQueue.event);
tempQueue = tempQueue.next;
}
}
public synchronized void flush() {
EventQueueItem tempQueue = queueHead;
queueHead = queueTail = null;
while (tempQueue != null) {
eventQueue.postEvent(tempQueue.event);
tempQueue = tempQueue.next;
}
}

View File

@ -28,6 +28,7 @@ package sun.java2d.pipe;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.RectangularShape;
/**
* This class encapsulates a definition of a two dimensional region which
@ -63,11 +64,28 @@ public class Region {
static final int INIT_SIZE = 50;
static final int GROW_SIZE = 50;
static final Region EMPTY_REGION = new Region(0, 0, 0, 0);
static final Region WHOLE_REGION = new Region(Integer.MIN_VALUE,
Integer.MIN_VALUE,
Integer.MAX_VALUE,
Integer.MAX_VALUE);
/**
* Immutable Region.
*/
private static final class ImmutableRegion extends Region {
protected ImmutableRegion(int lox, int loy, int hix, int hiy) {
super(lox, loy, hix, hiy);
}
// Override all the methods that mutate the object
public void appendSpans(sun.java2d.pipe.SpanIterator si) {}
public void setOutputArea(java.awt.Rectangle r) {}
public void setOutputAreaXYWH(int x, int y, int w, int h) {}
public void setOutputArea(int[] box) {}
public void setOutputAreaXYXY(int lox, int loy, int hix, int hiy) {}
}
public static final Region EMPTY_REGION = new ImmutableRegion(0, 0, 0, 0);
public static final Region WHOLE_REGION = new ImmutableRegion(
Integer.MIN_VALUE,
Integer.MIN_VALUE,
Integer.MAX_VALUE,
Integer.MAX_VALUE);
int lox;
int loy;
@ -113,7 +131,7 @@ public class Region {
return newv;
}
private Region(int lox, int loy, int hix, int hiy) {
protected Region(int lox, int loy, int hix, int hiy) {
this.lox = lox;
this.loy = loy;
this.hix = hix;
@ -194,6 +212,13 @@ public class Region {
public static Region getInstance(Region devBounds, boolean normalize,
Shape s, AffineTransform at)
{
// Optimize for empty shapes to avoid involving the SpanIterator
if (s instanceof RectangularShape &&
((RectangularShape)s).isEmpty())
{
return EMPTY_REGION;
}
int box[] = new int[4];
ShapeSpanIterator sr = new ShapeSpanIterator(normalize);
try {
@ -1206,7 +1231,7 @@ public class Region {
return false;
}
if (r.lox != this.lox || r.loy != this.loy ||
r.hiy != this.hiy || r.hiy != this.hiy)
r.hix != this.hix || r.hiy != this.hiy)
{
return false;
}

View File

@ -25,17 +25,7 @@
package sun.misc;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Hashtable;
import java.util.NoSuchElementException;
import java.util.Stack;
import java.util.Set;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.*;
import java.util.jar.JarFile;
import sun.misc.JarIndex;
import sun.misc.InvalidJarIndexException;
@ -52,12 +42,7 @@ import java.net.URLConnection;
import java.net.HttpURLConnection;
import java.net.URLStreamHandler;
import java.net.URLStreamHandlerFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.*;
import java.security.AccessController;
import java.security.AccessControlException;
import java.security.CodeSigner;
@ -100,6 +85,9 @@ public class URLClassPath {
/* The jar protocol handler to use when creating new URLs */
private URLStreamHandler jarHandler;
/* Whether this URLClassLoader has been closed yet */
private boolean closed = false;
/**
* Creates a new URLClassPath for the given URLs. The URLs will be
* searched in the order specified for classes and resources. A URL
@ -124,6 +112,22 @@ public class URLClassPath {
this(urls, null);
}
public synchronized List<IOException> closeLoaders() {
if (closed) {
return Collections.emptyList();
}
List<IOException> result = new LinkedList<IOException>();
for (Loader loader : loaders) {
try {
loader.close();
} catch (IOException e) {
result.add (e);
}
}
closed = true;
return result;
}
/**
* Appends the specified URL to the search path of directory and JAR
* file URLs from which to load classes and resources.
@ -293,6 +297,9 @@ public class URLClassPath {
* if the specified index is out of range.
*/
private synchronized Loader getLoader(int index) {
if (closed) {
return null;
}
// Expand URL search path until the request can be satisfied
// or the URL stack is empty.
while (loaders.size() < index + 1) {
@ -453,7 +460,7 @@ public class URLClassPath {
* Inner class used to represent a loader of resources and classes
* from a base URL.
*/
private static class Loader {
private static class Loader implements Closeable {
private final URL base;
/*
@ -544,6 +551,12 @@ public class URLClassPath {
return getResource(name, true);
}
/*
* close this loader and release all resources
* method overridden in sub-classes
*/
public void close () throws IOException {}
/*
* Returns the local class path for this loader, or null if none.
*/
@ -562,6 +575,7 @@ public class URLClassPath {
private MetaIndex metaIndex;
private URLStreamHandler handler;
private HashMap<URL, Loader> lmap;
private boolean closed = false;
/*
* Creates a new JarLoader for the specified URL referring to
@ -604,6 +618,17 @@ public class URLClassPath {
}
}
@Override
public void close () throws IOException {
// closing is synchronized at higher level
if (!closed) {
closed = true;
// in case not already open.
ensureOpen();
jar.close();
}
}
JarFile getJarFile () {
return jar;
}

View File

@ -39,7 +39,6 @@ import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Enumeration;
import java.util.List;
import java.util.StringTokenizer;
import java.net.InetAddress;
import java.net.UnknownHostException;
@ -156,11 +155,7 @@ public class Config {
configFile = loadConfigFile();
stanzaTable = parseStanzaTable(configFile);
} catch (IOException ioe) {
KrbException ke = new KrbException("Could not load " +
"configuration file " +
ioe.getMessage());
ke.initCause(ioe);
throw(ke);
// No krb5.conf, no problem. We'll use DNS etc.
}
}
}
@ -1057,7 +1052,12 @@ public class Config {
public boolean useDNS(String name) {
String value = getDefault(name, "libdefaults");
if (value == null) {
return getDefaultBooleanValue("dns_fallback", "libdefaults");
value = getDefault("dns_fallback", "libdefaults");
if ("false".equalsIgnoreCase(value)) {
return false;
} else {
return true;
}
} else {
return value.equalsIgnoreCase("true");
}
@ -1079,12 +1079,39 @@ public class Config {
/**
* Gets default realm.
* @throws KrbException where no realm can be located
* @return the default realm, always non null
*/
public String getDefaultRealm() throws KrbException {
Exception cause = null;
String realm = getDefault("default_realm", "libdefaults");
if ((realm == null) && useDNS_Realm()) {
// use DNS to locate Kerberos realm
realm = getRealmFromDNS();
try {
realm = getRealmFromDNS();
} catch (KrbException ke) {
cause = ke;
}
}
if (realm == null) {
realm = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<String>() {
@Override
public String run() {
String osname = System.getProperty("os.name");
if (osname.startsWith("Windows")) {
return System.getenv("USERDNSDOMAIN");
}
return null;
}
});
}
if (realm == null) {
KrbException ke = new KrbException("Cannot locate default realm");
if (cause != null) {
ke.initCause(cause);
}
throw ke;
}
return realm;
}
@ -1092,17 +1119,48 @@ public class Config {
/**
* Returns a list of KDC's with each KDC separated by a space
*
* @param realm the realm for which the master KDC is desired
* @return the list of KDCs
* @param realm the realm for which the KDC list is desired
* @throws KrbException if there's no way to find KDC for the realm
* @return the list of KDCs separated by a space, always non null
*/
public String getKDCList(String realm) throws KrbException {
if (realm == null) {
realm = getDefaultRealm();
}
Exception cause = null;
String kdcs = getDefault("kdc", realm);
if ((kdcs == null) && useDNS_KDC()) {
// use DNS to locate KDC
kdcs = getKDCFromDNS(realm);
try {
kdcs = getKDCFromDNS(realm);
} catch (KrbException ke) {
cause = ke;
}
}
if (kdcs == null) {
kdcs = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<String>() {
@Override
public String run() {
String osname = System.getProperty("os.name");
if (osname.startsWith("Windows")) {
String logonServer = System.getenv("LOGONSERVER");
if (logonServer != null
&& logonServer.startsWith("\\\\")) {
logonServer = logonServer.substring(2);
}
return logonServer;
}
return null;
}
});
}
if (kdcs == null) {
KrbException ke = new KrbException("Cannot locate KDC");
if (cause != null) {
ke.initCause(cause);
}
throw ke;
}
return kdcs;
}
@ -1117,7 +1175,7 @@ public class Config {
String realm = null;
String hostName = null;
try {
hostName = InetAddress.getLocalHost().getHostName();
hostName = InetAddress.getLocalHost().getCanonicalHostName();
} catch (UnknownHostException e) {
KrbException ke = new KrbException(Krb5.KRB_ERR_GENERIC,
"Unable to locate Kerberos realm: " + e.getMessage());

View File

@ -1,5 +1,5 @@
/*
* Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2006-2009 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
@ -133,7 +133,7 @@ class KrbServiceLocator {
*/
static String[] getKerberosService(String realmName, String protocol) {
String dnsUrl = "dns:///_kerberos." + protocol + realmName;
String dnsUrl = "dns:///_kerberos." + protocol + "." + realmName;
String[] hostports = null;
try {

View File

@ -32,10 +32,18 @@ class WindowDimensions {
private Insets insets;
private boolean isClientSizeSet;
/**
* If isClient is true, the bounds represent the client window area.
* Otherwise, they represent the entire window area, with the insets included
*/
public WindowDimensions(int x, int y, int width, int height, boolean isClient) {
this(new Rectangle(x, y, width, height), null, isClient);
}
/**
* If isClient is true, the bounds represent the client window area.
* Otherwise, they represent the entire window area, with the insets included
*/
public WindowDimensions(Rectangle rec, Insets ins, boolean isClient) {
if (rec == null) {
throw new IllegalArgumentException("Client bounds can't be null");
@ -46,10 +54,18 @@ class WindowDimensions {
setInsets(ins);
}
/**
* If isClient is true, the bounds represent the client window area.
* Otherwise, they represent the entire window area, with the insets included
*/
public WindowDimensions(Point loc, Dimension size, Insets in, boolean isClient) {
this(new Rectangle(loc, size), in, isClient);
}
/**
* If isClient is true, the bounds represent the client window area.
* Otherwise, they represent the entire window area, with the insets included
*/
public WindowDimensions(Rectangle bounds, boolean isClient) {
this(bounds, null, isClient);
}

View File

@ -979,8 +979,13 @@ public class XBaseWindow {
*/
public void handleButtonPressRelease(XEvent xev) {
XButtonEvent xbe = xev.get_xbutton();
final int buttonState = xbe.get_state() & (XConstants.Button1Mask | XConstants.Button2Mask
| XConstants.Button3Mask | XConstants.Button4Mask | XConstants.Button5Mask);
int buttonState = 0;
for (int i = 0; i<XToolkit.getNumMouseButtons(); i++){
// A bug in WM implementation: extra buttons doesn't have state!=0 as they should on Release message.
if ((i != 4) && (i != 5)){
buttonState |= (xbe.get_state() & XConstants.buttonsMask[i]);
}
}
switch (xev.get_type()) {
case XConstants.ButtonPress:
if (buttonState == 0) {
@ -1011,19 +1016,11 @@ public class XBaseWindow {
* Checks ButtonRelease released all Mouse buttons
*/
static boolean isFullRelease(int buttonState, int button) {
switch (button) {
case XConstants.Button1:
return buttonState == XConstants.Button1Mask;
case XConstants.Button2:
return buttonState == XConstants.Button2Mask;
case XConstants.Button3:
return buttonState == XConstants.Button3Mask;
case XConstants.Button4:
return buttonState == XConstants.Button4Mask;
case XConstants.Button5:
return buttonState == XConstants.Button5Mask;
if (button < 0 || button > XToolkit.getNumMouseButtons()) {
return buttonState == 0;
} else {
return buttonState == XConstants.buttonsMask[button - 1];
}
return buttonState == 0;
}
static boolean isGrabbedEvent(XEvent ev, XBaseWindow target) {

View File

@ -1534,13 +1534,23 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
}
XToolkit.awtLock();
try {
XlibWrapper.SetRectangularShape(
XToolkit.getDisplay(),
getWindow(),
shape.getLoX(), shape.getLoY(),
shape.getHiX(), shape.getHiY(),
(shape.isRectangular() ? null : shape)
);
if (shape != null) {
XlibWrapper.SetRectangularShape(
XToolkit.getDisplay(),
getWindow(),
shape.getLoX(), shape.getLoY(),
shape.getHiX(), shape.getHiY(),
(shape.isRectangular() ? null : shape)
);
} else {
XlibWrapper.SetRectangularShape(
XToolkit.getDisplay(),
getWindow(),
0, 0,
0, 0,
null
);
}
} finally {
XToolkit.awtUnlock();
}

View File

@ -197,12 +197,30 @@ final public class XConstants {
/* button masks. Used in same manner as Key masks above. Not to be confused
with button names below. */
public static final int Button1Mask = (1<<8) ;
public static final int Button2Mask = (1<<9) ;
public static final int Button3Mask = (1<<10) ;
public static final int Button4Mask = (1<<11) ;
public static final int Button5Mask = (1<<12) ;
public static final int [] buttonsMask = new int []{ 1<<8,
1<<9,
1<<10,
1<<11,
1<<12,
1<<13,
1<<14,
1<<15,
1<<16,
1<<17,
1<<18,
1<<19,
1<<20,
1<<21,
1<<22,
1<<23,
1<<24,
1<<25,
1<<26,
1<<27,
1<<28,
1<<29,
1<<30,
1<<31 };
public static final int AnyModifier = (1<<15) ; /* used in GrabButton, GrabKey */
@ -211,11 +229,7 @@ final public class XConstants {
and ButtonRelease events. Not to be confused with button masks above.
Note that 0 is already defined above as "AnyButton". */
public static final int Button1 = 1 ;
public static final int Button2 = 2 ;
public static final int Button3 = 3 ;
public static final int Button4 = 4 ;
public static final int Button5 = 5 ;
public static final int buttons [] = new int [] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
/* Notify modes */

View File

@ -492,7 +492,14 @@ abstract class XDecoratedPeer extends XWindowPeer {
// do nothing but accept it.
Rectangle reqBounds = newDimensions.getBounds();
Rectangle newBounds = constrainBounds(reqBounds.x, reqBounds.y, reqBounds.width, reqBounds.height);
newDimensions = new WindowDimensions(newBounds, newDimensions.getInsets(), newDimensions.isClientSizeSet());
Insets insets = newDimensions.getInsets();
// Inherit isClientSizeSet from newDimensions
if (newDimensions.isClientSizeSet()) {
newBounds = new Rectangle(newBounds.x, newBounds.y,
newBounds.width - insets.left - insets.right,
newBounds.height - insets.top - insets.bottom);
}
newDimensions = new WindowDimensions(newBounds, insets, newDimensions.isClientSizeSet());
}
XToolkit.awtLock();
try {

View File

@ -694,8 +694,8 @@ public final class XDragSourceContextPeer
} finally {
xmotion.dispose();
}
if (xbutton.get_button() == XConstants.Button1
|| xbutton.get_button() == XConstants.Button2) {
if (xbutton.get_button() == XConstants.buttons[0]
|| xbutton.get_button() == XConstants.buttons[1]) {
// drag is initiated with Button1 or Button2 pressed and
// ended on release of either of these buttons (as the same
// behavior was with our old Motif DnD-based implementation)

View File

@ -31,6 +31,9 @@ import sun.awt.SunToolkit;
import java.awt.Component;
import java.awt.Container;
import sun.awt.X11GraphicsConfig;
import sun.awt.X11GraphicsDevice;
/**
* Helper class implementing XEmbed protocol handling routines(client side)
* Window which wants to participate in a protocol should create an instance,
@ -39,20 +42,34 @@ import java.awt.Container;
public class XEmbedClientHelper extends XEmbedHelper implements XEventDispatcher {
private static final Logger xembedLog = Logger.getLogger("sun.awt.X11.xembed.XEmbedClientHelper");
private XEmbeddedFramePeer embedded;
private XEmbeddedFramePeer embedded; // XEmbed client
private long server; // XEmbed server
private boolean active;
private long server;
private boolean applicationActive;
XEmbedClientHelper() {
super();
}
void install(XEmbeddedFramePeer embedded) {
this.embedded = embedded;
void setClient(XEmbeddedFramePeer client) {
if (xembedLog.isLoggable(Level.FINE)) {
xembedLog.fine("XEmbed client: " + client);
}
if (embedded != null) {
XToolkit.removeEventDispatcher(embedded.getWindow(), this);
active = false;
}
embedded = client;
if (embedded != null) {
XToolkit.addEventDispatcher(embedded.getWindow(), this);
}
}
if (xembedLog.isLoggable(Level.FINE)) xembedLog.fine("Installing xembedder on " + embedded);
XToolkit.addEventDispatcher(embedded.getWindow(), this);
void install() {
if (xembedLog.isLoggable(Level.FINE)) {
xembedLog.fine("Installing xembedder on " + embedded);
}
long[] info = new long[] { XEMBED_VERSION, XEMBED_MAPPED };
long data = Native.card32ToData(info);
try {
@ -155,7 +172,24 @@ public class XEmbedClientHelper extends XEmbedHelper implements XEventDispatcher
}
public void handleReparentNotify(XEvent xev) {
XReparentEvent re = xev.get_xreparent();
server = re.get_parent();
long newParent = re.get_parent();
if (active) {
// unregister accelerators, etc. for old parent
embedded.notifyStopped();
// check if newParent is a root window
X11GraphicsConfig gc = (X11GraphicsConfig)embedded.getGraphicsConfiguration();
X11GraphicsDevice gd = (X11GraphicsDevice)gc.getDevice();
if ((newParent == XlibUtil.getRootWindow(gd.getScreen())) ||
(newParent == XToolkit.getDefaultRootWindow()))
{
// reparenting to root means XEmbed termination
active = false;
} else {
// continue XEmbed with a new parent
server = newParent;
embedded.notifyStarted();
}
}
}
boolean requestFocus() {
if (active && embedded.focusAllowedFor()) {
@ -201,12 +235,16 @@ public class XEmbedClientHelper extends XEmbedHelper implements XEventDispatcher
}
void registerAccelerator(AWTKeyStroke stroke, int id) {
long sym = getX11KeySym(stroke);
long mods = getX11Mods(stroke);
sendMessage(server, XEMBED_REGISTER_ACCELERATOR, id, sym, mods);
if (active) {
long sym = getX11KeySym(stroke);
long mods = getX11Mods(stroke);
sendMessage(server, XEMBED_REGISTER_ACCELERATOR, id, sym, mods);
}
}
void unregisterAccelerator(int id) {
sendMessage(server, XEMBED_UNREGISTER_ACCELERATOR, id, 0, 0);
if (active) {
sendMessage(server, XEMBED_UNREGISTER_ACCELERATOR, id, 0, 0);
}
}
long getX11KeySym(AWTKeyStroke stroke) {

View File

@ -63,7 +63,10 @@ public class XEmbeddedFramePeer extends XFramePeer {
void postInit(XCreateWindowParams params) {
super.postInit(params);
if (embedder != null) {
embedder.install(this);
// install X11 event dispatcher
embedder.setClient(this);
// reparent to XEmbed server
embedder.install();
} else if (getParentWindowHandle() != 0) {
XToolkit.awtLock();
try {
@ -77,6 +80,15 @@ public class XEmbeddedFramePeer extends XFramePeer {
}
}
@Override
public void dispose() {
if (embedder != null) {
// uninstall X11 event dispatcher
embedder.setClient(null);
}
super.dispose();
}
public void updateMinimumSize() {
}
@ -249,6 +261,14 @@ public class XEmbeddedFramePeer extends XFramePeer {
// XEmbed.
updateDropTarget();
}
void notifyStopped() {
if (embedder != null && embedder.isActive()) {
for (int i = strokes.size() - 1; i >= 0; i--) {
embedder.unregisterAccelerator(i);
}
}
}
long getFocusTargetWindow() {
return getWindow();
}

View File

@ -63,6 +63,8 @@ public class XKeysym {
// TODO: or not to do: add reverse lookup javakeycode2keysym,
// for robot only it seems to me. After that, we can remove lookup table
// from XWindow.c altogether.
// Another use for reverse lookup: query keyboard state, for some keys.
static Hashtable<Integer, Long> javaKeycode2KeysymHash = new Hashtable<Integer, Long>();
static long keysym_lowercase = unsafe.allocateMemory(Native.getLongSize());
static long keysym_uppercase = unsafe.allocateMemory(Native.getLongSize());
public static char convertKeysym( long ks, int state ) {
@ -196,6 +198,10 @@ public class XKeysym {
Keysym2JavaKeycode jkc = getJavaKeycode( ev );
return jkc == null ? java.awt.event.KeyEvent.VK_UNDEFINED : jkc.getJavaKeycode();
}
static long javaKeycode2Keysym( int jkey ) {
Long ks = javaKeycode2KeysymHash.get( jkey );
return (ks == null ? 0 : ks.longValue());
}
/**
Return keysym derived from a keycode and modifiers.
Usually an input method does this. However non-system input methods (e.g. Java IMs) do not.
@ -1583,6 +1589,14 @@ public class XKeysym {
keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.hpXK_mute_asciitilde), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_DEAD_TILDE, java.awt.event.KeyEvent.KEY_LOCATION_STANDARD));
keysym2JavaKeycodeHash.put( Long.valueOf(XConstants.NoSymbol), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_UNDEFINED, java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN));
/* Reverse search of keysym by keycode. */
/* Add keyboard locking codes. */
javaKeycode2KeysymHash.put( java.awt.event.KeyEvent.VK_CAPS_LOCK, XKeySymConstants.XK_Caps_Lock);
javaKeycode2KeysymHash.put( java.awt.event.KeyEvent.VK_NUM_LOCK, XKeySymConstants.XK_Num_Lock);
javaKeycode2KeysymHash.put( java.awt.event.KeyEvent.VK_SCROLL_LOCK, XKeySymConstants.XK_Scroll_Lock);
javaKeycode2KeysymHash.put( java.awt.event.KeyEvent.VK_KANA_LOCK, XKeySymConstants.XK_Kana_Lock);
};
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003-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
@ -81,11 +81,16 @@ class XRobotPeer implements RobotPeer {
return pixelArray;
}
public int getNumberOfButtons(){
return getNumberOfButtonsImpl();
}
private static native synchronized void setup();
private static native synchronized void mouseMoveImpl(X11GraphicsConfig xgc, int x, int y);
private static native synchronized void mousePressImpl(int buttons);
private static native synchronized void mouseReleaseImpl(int buttons);
private static native synchronized int getNumberOfButtonsImpl();
private static native synchronized void mouseWheelImpl(int wheelAmt);
private static native synchronized void keyPressImpl(int keycode);

View File

@ -27,6 +27,7 @@ package sun.awt.X11;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.KeyEvent;
import java.awt.datatransfer.Clipboard;
import java.awt.dnd.DragSource;
import java.awt.dnd.DragGestureListener;
@ -61,6 +62,10 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
private static Logger keyEventLog = Logger.getLogger("sun.awt.X11.kye.XToolkit");
private static final Logger backingStoreLog = Logger.getLogger("sun.awt.X11.backingStore.XToolkit");
//There is 400 ms is set by default on Windows and 500 by default on KDE and GNOME.
//We use the same hardcoded constant.
private final static int AWT_MULTICLICK_DEFAULT_TIME = 500;
static final boolean PRIMARY_LOOP = false;
static final boolean SECONDARY_LOOP = true;
@ -74,6 +79,25 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
// Dynamic Layout Resize client code setting
protected static boolean dynamicLayoutSetting = false;
//Is it allowed to generate events assigned to extra mouse buttons.
//Set to true by default.
private static boolean areExtraMouseButtonsEnabled = true;
/**
* Number of buttons.
* By default it's taken from the system. If system value does not
* fit into int type range, use our own MAX_BUTTONS_SUPPORT value.
*/
private static int numberOfButtons = 0;
/* XFree standard mention 24 buttons as maximum:
* http://www.xfree86.org/current/mouse.4.html
* We workaround systems supporting more than 24 buttons.
* Otherwise, we have to use long type values as masks
* which leads to API change.
*/
private static int MAX_BUTTONS_SUPPORT = 24;
/**
* True when the x settings have been loaded.
*/
@ -273,6 +297,9 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
arrowCursor = XlibWrapper.XCreateFontCursor(XToolkit.getDisplay(),
XCursorFontConstants.XC_arrow);
areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
//set system property if not yet assigned
System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
} finally {
awtUnlock();
}
@ -1080,6 +1107,19 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
public Map mapInputMethodHighlight(InputMethodHighlight highlight) {
return XInputMethod.mapInputMethodHighlight(highlight);
}
@Override
public boolean getLockingKeyState(int key) {
if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
}
awtLock();
try {
return getModifierState( key );
} finally {
awtUnlock();
}
}
public Clipboard getSystemClipboard() {
SecurityManager security = System.getSecurityManager();
@ -1216,7 +1256,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
String multiclick_time_query = XlibWrapper.XGetDefault(XToolkit.getDisplay(), "*", "multiClickTime");
if (multiclick_time_query != null) {
awt_multiclick_time = (int)Long.parseLong(multiclick_time_query);
// awt_multiclick_time = XtGetMultiClickTime(awt_display);
} else {
multiclick_time_query = XlibWrapper.XGetDefault(XToolkit.getDisplay(),
"OpenWindows", "MultiClickTimeout");
@ -1226,20 +1265,19 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
milliseconds */
awt_multiclick_time = (int)Long.parseLong(multiclick_time_query) * 100;
} else {
awt_multiclick_time = 200;
// awt_multiclick_time = XtGetMultiClickTime(awt_display);
awt_multiclick_time = AWT_MULTICLICK_DEFAULT_TIME;
}
}
} catch (NumberFormatException nf) {
awt_multiclick_time = 200;
awt_multiclick_time = AWT_MULTICLICK_DEFAULT_TIME;
} catch (NullPointerException npe) {
awt_multiclick_time = 200;
awt_multiclick_time = AWT_MULTICLICK_DEFAULT_TIME;
}
} finally {
awtUnlock();
}
if (awt_multiclick_time == 0) {
awt_multiclick_time = 200;
awt_multiclick_time = AWT_MULTICLICK_DEFAULT_TIME;
}
}
@ -1383,10 +1421,15 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
}
private int getNumMouseButtons() {
public static int getNumMouseButtons() {
awtLock();
try {
return XlibWrapper.XGetPointerMapping(XToolkit.getDisplay(), 0, 0);
if (numberOfButtons == 0) {
numberOfButtons = Math.min(
XlibWrapper.XGetPointerMapping(XToolkit.getDisplay(), 0, 0),
MAX_BUTTONS_SUPPORT);
}
return numberOfButtons;
} finally {
awtUnlock();
}
@ -1542,6 +1585,66 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
awtUnlock();
}
}
static boolean getModifierState( int jkc ) {
int iKeyMask = 0;
long ks = XKeysym.javaKeycode2Keysym( jkc );
int kc = XlibWrapper.XKeysymToKeycode(getDisplay(), ks);
if (kc == 0) {
return false;
}
awtLock();
try {
XModifierKeymap modmap = new XModifierKeymap(
XlibWrapper.XGetModifierMapping(getDisplay()));
int nkeys = modmap.get_max_keypermod();
long map_ptr = modmap.get_modifiermap();
for( int k = 0; k < 8; k++ ) {
for (int i = 0; i < nkeys; ++i) {
int keycode = Native.getUByte(map_ptr, k * nkeys + i);
if (keycode == 0) {
continue; // ignore zero keycode
}
if (kc == keycode) {
iKeyMask = 1 << k;
break;
}
}
if( iKeyMask != 0 ) {
break;
}
}
XlibWrapper.XFreeModifiermap(modmap.pData);
if (iKeyMask == 0 ) {
return false;
}
// Now we know to which modifier is assigned the keycode
// correspondent to the keysym correspondent to the java
// keycode. We are going to check a state of this modifier.
// If a modifier is a weird one, we cannot help it.
long window = 0;
try{
// get any application window
window = ((Long)(winMap.firstKey())).longValue();
}catch(NoSuchElementException nex) {
// get root window
window = getDefaultRootWindow();
}
boolean res = XlibWrapper.XQueryPointer(getDisplay(), window,
XlibWrapper.larg1, //root
XlibWrapper.larg2, //child
XlibWrapper.larg3, //root_x
XlibWrapper.larg4, //root_y
XlibWrapper.larg5, //child_x
XlibWrapper.larg6, //child_y
XlibWrapper.larg7);//mask
int mask = Native.getInt(XlibWrapper.larg7);
return ((mask & iKeyMask) != 0);
} finally {
awtUnlock();
}
}
/* Assign meaning - alt, meta, etc. - to X modifiers mod1 ... mod5.
* Only consider primary symbols on keycodes attached to modifiers.
@ -2166,4 +2269,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
public static native void setNoisyXErrorHandler();
public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
return areExtraMouseButtonsEnabled;
}
}

View File

@ -553,6 +553,10 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
}
static int getModifiers(int state, int button, int keyCode) {
return getModifiers(state, button, keyCode, 0, false);
}
static int getModifiers(int state, int button, int keyCode, int type, boolean wheel_mouse) {
int modifiers = 0;
if (((state & XConstants.ShiftMask) != 0) ^ (keyCode == KeyEvent.VK_SHIFT)) {
@ -570,14 +574,23 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
if (((state & XToolkit.modeSwitchMask) != 0) ^ (keyCode == KeyEvent.VK_ALT_GRAPH)) {
modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
}
if (((state & XConstants.Button1Mask) != 0) ^ (button == MouseEvent.BUTTON1)) {
modifiers |= InputEvent.BUTTON1_DOWN_MASK;
}
if (((state & XConstants.Button2Mask) != 0) ^ (button == MouseEvent.BUTTON2)) {
modifiers |= InputEvent.BUTTON2_DOWN_MASK;
}
if (((state & XConstants.Button3Mask) != 0) ^ (button == MouseEvent.BUTTON3)) {
modifiers |= InputEvent.BUTTON3_DOWN_MASK;
//InputEvent.BUTTON_DOWN_MASK array is starting from BUTTON1_DOWN_MASK on index == 0.
// button currently reflects a real button number and starts from 1. (except NOBUTTON which is zero )
/* this is an attempt to refactor button IDs in : MouseEvent, InputEvent, XlibWrapper and XWindow.*/
//reflects a button number similar to MouseEvent.BUTTON1, 2, 3 etc.
for (int i = 0; i < XConstants.buttonsMask.length; i ++){
//modifier should be added if :
// 1) current button is now still in PRESSED state (means that user just pressed mouse but not released yet) or
// 2) if Xsystem reports that "state" represents that button was just released. This only happens on RELEASE with 1,2,3 buttons.
// ONLY one of these conditions should be TRUE to add that modifier.
if (((state & XConstants.buttonsMask[i]) != 0) != (button == XConstants.buttons[i])){
//exclude wheel buttons from adding their numbers as modifiers
if (!wheel_mouse) {
modifiers |= InputEvent.getMaskForButton(i+1);
}
}
}
return modifiers;
}
@ -603,17 +616,6 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
return res;
}
private static int getButtonMask(long mouseButton) {
if (mouseButton == XConstants.Button1) {
return XConstants.Button1Mask;
} else if (mouseButton == XConstants.Button2) {
return XConstants.Button2Mask;
} else if (mouseButton == XConstants.Button3) {
return XConstants.Button3Mask;
}
return 0;
}
/**
* Returns true if this event is disabled and shouldn't be passed to Java.
* Default implementation returns false for all events.
@ -648,7 +650,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
boolean popupTrigger = false;
int button=0;
boolean wheel_mouse = false;
long lbutton = xbe.get_button();
int lbutton = xbe.get_button();
int type = xev.get_type();
when = xbe.get_time();
long jWhen = XToolkit.nowMillisUTC_offset(when);
@ -663,7 +665,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
if (type == XConstants.ButtonPress) {
//Allow this mouse button to generate CLICK event on next ButtonRelease
mouseButtonClickAllowed |= getButtonMask(lbutton);
mouseButtonClickAllowed |= XConstants.buttonsMask[lbutton];
XWindow lastWindow = (lastWindowRef != null) ? ((XWindow)lastWindowRef.get()):(null);
/*
multiclick checking
@ -693,21 +695,22 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
}
}
if (lbutton == XConstants.Button1)
button = MouseEvent.BUTTON1;
else if (lbutton == XConstants.Button2 )
button = MouseEvent.BUTTON2;
else if (lbutton == XConstants.Button3)
button = MouseEvent.BUTTON3;
else if (lbutton == XConstants.Button4) {
button = 4;
wheel_mouse = true;
} else if (lbutton == XConstants.Button5) {
button = 5;
button = XConstants.buttons[lbutton - 1];
// 4 and 5 buttons are usually considered assigned to a first wheel
if (lbutton == XConstants.buttons[3] ||
lbutton == XConstants.buttons[4]) {
wheel_mouse = true;
}
modifiers = getModifiers(xbe.get_state(),button,0);
// mapping extra buttons to numbers starting from 4.
if ((button > XConstants.buttons[4]) && (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled())){
return;
}
if (button > XConstants.buttons[4]){
button -= 2;
}
modifiers = getModifiers(xbe.get_state(),button,0, type, wheel_mouse);
if (!wheel_mouse) {
MouseEvent me = new MouseEvent((Component)getEventSource(),
@ -720,7 +723,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
postEventToEventQueue(me);
if ((type == XConstants.ButtonRelease) &&
((mouseButtonClickAllowed & getButtonMask(lbutton)) != 0) ) // No up-button in the drag-state
((mouseButtonClickAllowed & XConstants.buttonsMask[lbutton]) != 0) ) // No up-button in the drag-state
{
postEventToEventQueue(me = new MouseEvent((Component)getEventSource(),
MouseEvent.MOUSE_CLICKED,
@ -750,7 +753,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
/* Update the state variable AFTER the CLICKED event post. */
if (type == XConstants.ButtonRelease) {
/* Exclude this mouse button from allowed list.*/
mouseButtonClickAllowed &= ~getButtonMask(lbutton);
mouseButtonClickAllowed &= ~XConstants.buttonsMask[lbutton];
}
}
@ -761,7 +764,19 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
return;
}
int mouseKeyState = (xme.get_state() & (XConstants.Button1Mask | XConstants.Button2Mask | XConstants.Button3Mask));
int mouseKeyState = 0; //(xme.get_state() & (XConstants.buttonsMask[0] | XConstants.buttonsMask[1] | XConstants.buttonsMask[2]));
//this doesn't work for extra buttons because Xsystem is sending state==0 for every extra button event.
// we can't correct it in MouseEvent class as we done it with modifiers, because exact type (DRAG|MOVE)
// should be passed from XWindow.
//TODO: eliminate it with some other value obtained w/o AWTLock.
for (int i = 0; i < XToolkit.getNumMouseButtons(); i++){
// TODO : here is the bug in WM: extra buttons doesn't have state!=0 as they should.
if ((i != 4) && (i != 5)) {
mouseKeyState = mouseKeyState | (xme.get_state() & XConstants.buttonsMask[i]);
}
}
boolean isDragging = (mouseKeyState != 0);
int mouseEventType = 0;

View File

@ -1936,7 +1936,13 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
new Object[] {xme, isGrabbed(), containsGlobal(xme.get_x_root(), xme.get_y_root())});
}
if (isGrabbed()) {
boolean dragging = (xme.get_state() & (XConstants.Button1Mask | XConstants.Button2Mask | XConstants.Button3Mask)) != 0;
boolean dragging = false;
for (int i = 0; i<XToolkit.getNumMouseButtons(); i++){
// here is the bug in WM: extra buttons doesn't have state!=0 as they should.
if ((i != 4) && (i != 5)){
dragging = dragging || ((xme.get_state() & XConstants.buttonsMask[i]) != 0);
}
}
// When window is grabbed, all events are dispatched to
// it. Retarget them to the corresponding windows (notice
// that XBaseWindow.dispatchEvent does the opposite
@ -1990,12 +1996,12 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
try {
grabLog.log(Level.FINER, " - Grab event target {0} (press target {1})", new Object[] {target, pressTarget});
if (xbe.get_type() == XConstants.ButtonPress
&& xbe.get_button() == XConstants.Button1)
&& xbe.get_button() == XConstants.buttons[0])
{
// need to keep it to retarget mouse release
pressTarget = target;
} else if (xbe.get_type() == XConstants.ButtonRelease
&& xbe.get_button() == XConstants.Button1
&& xbe.get_button() == XConstants.buttons[0]
&& pressTarget != target)
{
// during grab we do receive mouse release on different component (not on the source

View File

@ -485,6 +485,7 @@ static native String XSetLocaleModifiers(String modifier_list);
static native int XdbeEndIdiom(long display);
static native int XdbeSwapBuffers(long display, long swap_info, int num_windows);
static native void XQueryKeymap(long display, long vector);
static native long XKeycodeToKeysym(long display, int keycode, int index);
static native int XKeysymToKeycode(long display, long keysym);

View File

@ -101,6 +101,8 @@ tojava static Hashtable<Long, Long> uppercaseHash = new Hashtable<Long, Long
tojava // TODO: or not to do: add reverse lookup javakeycode2keysym,
tojava // for robot only it seems to me. After that, we can remove lookup table
tojava // from XWindow.c altogether.
tojava // Another use for reverse lookup: query keyboard state, for some keys.
tojava static Hashtable<Integer, Long> javaKeycode2KeysymHash = new Hashtable<Integer, Long>();
tojava static long keysym_lowercase = unsafe.allocateMemory(Native.getLongSize());
tojava static long keysym_uppercase = unsafe.allocateMemory(Native.getLongSize());
tojava public static char convertKeysym( long ks, int state ) {
@ -234,6 +236,10 @@ tojava static int getJavaKeycodeOnly( XKeyEvent ev ) {
tojava Keysym2JavaKeycode jkc = getJavaKeycode( ev );
tojava return jkc == null ? java.awt.event.KeyEvent.VK_UNDEFINED : jkc.getJavaKeycode();
tojava }
tojava static long javaKeycode2Keysym( int jkey ) {
tojava Long ks = javaKeycode2KeysymHash.get( jkey );
tojava return (ks == null ? 0 : ks.longValue());
tojava }
tojava /**
tojava Return keysym derived from a keycode and modifiers.
tojava Usually an input method does this. However non-system input methods (e.g. Java IMs) do not.
@ -2634,6 +2640,14 @@ tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.hpXK_mu
tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.hpXK_mute_asciitilde), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_DEAD_TILDE, java.awt.event.KeyEvent.KEY_LOCATION_STANDARD));
tojava
tojava keysym2JavaKeycodeHash.put( Long.valueOf(XConstants.NoSymbol), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_UNDEFINED, java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN));
tojava
tojava /* Reverse search of keysym by keycode. */
tojava
tojava /* Add keyboard locking codes. */
tojava javaKeycode2KeysymHash.put( java.awt.event.KeyEvent.VK_CAPS_LOCK, XKeySymConstants.XK_Caps_Lock);
tojava javaKeycode2KeysymHash.put( java.awt.event.KeyEvent.VK_NUM_LOCK, XKeySymConstants.XK_Num_Lock);
tojava javaKeycode2KeysymHash.put( java.awt.event.KeyEvent.VK_SCROLL_LOCK, XKeySymConstants.XK_Scroll_Lock);
tojava javaKeycode2KeysymHash.put( java.awt.event.KeyEvent.VK_KANA_LOCK, XKeySymConstants.XK_Kana_Lock);
tojava };
tojava
tojava }

View File

@ -259,6 +259,12 @@ Java_java_lang_UNIXProcess_waitForProcessExit(JNIEnv* env,
}
}
static int
isAsciiDigit(char c)
{
return c >= '0' && c <= '9';
}
static int
closeDescriptors(void)
{
@ -284,7 +290,7 @@ closeDescriptors(void)
*/
while ((dirp = readdir64(dp)) != NULL) {
int fd;
if (isdigit(dirp->d_name[0]) &&
if (isAsciiDigit(dirp->d_name[0]) &&
(fd = strtol(dirp->d_name, NULL, 10)) >= from_fd + 2)
close(fd);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1999-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
@ -54,6 +54,7 @@ extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
// 2 would be more correct, however that's how Robot originally worked
// and tests start to fail if this value is changed
static int32_t num_buttons = 3;
static jint * masks;
static int32_t isXTestAvailable() {
int32_t major_opcode, first_event, first_error;
@ -208,6 +209,26 @@ JNIEXPORT void JNICALL
Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls) {
int32_t xtestAvailable;
// this should be called from XRobotPeer constructor
jclass inputEventClazz = (*env)->FindClass(env, "java/awt/event/InputEvent");
jmethodID getButtonDownMasksID = (*env)->GetStaticMethodID(env, inputEventClazz, "getButtonDownMasks", "()[I");
jintArray obj = (jintArray)(*env)->CallStaticObjectMethod(env, inputEventClazz, getButtonDownMasksID);
jsize len = (*env)->GetArrayLength(env, obj);
jint * tmp = (*env)->GetIntArrayElements(env, obj, JNI_FALSE);
masks = (jint *)malloc(sizeof(jint)*len);
if (masks == (jint *) NULL) {
JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL);
goto finally;
}
int i;
for (i = 0; i < len; i++) {
masks[i] = tmp[i];
}
(*env)->ReleaseIntArrayElements(env, obj, tmp, 0);
(*env)->DeleteLocalRef(env, obj);
DTRACE_PRINTLN("RobotPeer: setup()");
AWT_LOCK();
@ -221,10 +242,17 @@ Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls) {
}
getNumButtons();
finally:
AWT_UNLOCK();
}
JNIEXPORT jint JNICALL
Java_sun_awt_X11_XRobotPeer_getNumberOfButtonsImpl(JNIEnv *env,
jclass cls) {
// At the moment this routine being called we already should have an initialized num_buttons variable.
return num_buttons;
}
JNIEXPORT void JNICALL
Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env,
jclass cls,
@ -348,52 +376,65 @@ Java_sun_awt_X11_XRobotPeer_mouseMoveImpl (JNIEnv *env,
AWT_UNLOCK();
}
/*
* Function joining the code of mousePressImpl and mouseReleaseImpl
*/
void mouseAction(JNIEnv *env,
jclass cls,
jint buttonMask,
Bool isMousePress)
{
AWT_LOCK();
DTRACE_PRINTLN1("RobotPeer: mouseAction(%i)", buttonMask);
DTRACE_PRINTLN1("RobotPeer: mouseAction, press = %d", isMousePress);
if (buttonMask & java_awt_event_InputEvent_BUTTON1_MASK ||
buttonMask & java_awt_event_InputEvent_BUTTON1_DOWN_MASK )
{
XTestFakeButtonEvent(awt_display, 1, isMousePress, CurrentTime);
}
if ((buttonMask & java_awt_event_InputEvent_BUTTON2_MASK ||
buttonMask & java_awt_event_InputEvent_BUTTON2_DOWN_MASK) &&
(num_buttons >= 2)) {
XTestFakeButtonEvent(awt_display, 2, isMousePress, CurrentTime);
}
if ((buttonMask & java_awt_event_InputEvent_BUTTON3_MASK ||
buttonMask & java_awt_event_InputEvent_BUTTON3_DOWN_MASK) &&
(num_buttons >= 3)) {
XTestFakeButtonEvent(awt_display, 3, isMousePress, CurrentTime);
}
if (num_buttons > 3){
int32_t i;
int32_t button = 0;
for (i = 3; i<num_buttons; i++){
if ((buttonMask & masks[i])) {
// arrays starts from zero index => +1
// users wants to affect 4 or 5 button but they are assigned
// to the wheel so => we have to shift it to the right by 2.
button = i + 3;
XTestFakeButtonEvent(awt_display, button, isMousePress, CurrentTime);
}
}
}
XSync(awt_display, False);
AWT_UNLOCK();
}
JNIEXPORT void JNICALL
Java_sun_awt_X11_XRobotPeer_mousePressImpl (JNIEnv *env,
jclass cls,
jint buttonMask) {
AWT_LOCK();
DTRACE_PRINTLN1("RobotPeer: mousePressImpl(%i)", buttonMask);
if (buttonMask & java_awt_event_InputEvent_BUTTON1_MASK) {
XTestFakeButtonEvent(awt_display, 1, True, CurrentTime);
}
if ((buttonMask & java_awt_event_InputEvent_BUTTON2_MASK) &&
(num_buttons >= 2)) {
XTestFakeButtonEvent(awt_display, 2, True, CurrentTime);
}
if ((buttonMask & java_awt_event_InputEvent_BUTTON3_MASK) &&
(num_buttons >= 3)) {
XTestFakeButtonEvent(awt_display, 3, True, CurrentTime);
}
XSync(awt_display, False);
AWT_UNLOCK();
mouseAction(env, cls, buttonMask, True);
}
JNIEXPORT void JNICALL
Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl (JNIEnv *env,
jclass cls,
jint buttonMask) {
AWT_LOCK();
DTRACE_PRINTLN1("RobotPeer: mouseReleaseImpl(%i)", buttonMask);
if (buttonMask & java_awt_event_InputEvent_BUTTON1_MASK) {
XTestFakeButtonEvent(awt_display, 1, False, CurrentTime);
}
if ((buttonMask & java_awt_event_InputEvent_BUTTON2_MASK) &&
(num_buttons >= 2)) {
XTestFakeButtonEvent(awt_display, 2, False, CurrentTime);
}
if ((buttonMask & java_awt_event_InputEvent_BUTTON3_MASK) &&
(num_buttons >= 3)) {
XTestFakeButtonEvent(awt_display, 3, False, CurrentTime);
}
XSync(awt_display, False);
AWT_UNLOCK();
mouseAction(env, cls, buttonMask, False);
}
JNIEXPORT void JNICALL

View File

@ -1641,6 +1641,13 @@ JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XdbeSwapBuffers
AWT_CHECK_HAVE_LOCK();
return XdbeSwapBuffers((Display*) jlong_to_ptr(display), (XdbeSwapInfo *) jlong_to_ptr(swap_info), num_windows);
}
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XQueryKeymap
(JNIEnv *env, jclass clazz, jlong display, jlong vector)
{
AWT_CHECK_HAVE_LOCK();
XQueryKeymap( (Display *) jlong_to_ptr(display), (char *) jlong_to_ptr(vector));
}
JNIEXPORT jlong JNICALL
Java_sun_awt_X11_XlibWrapper_XKeycodeToKeysym(JNIEnv *env, jclass clazz,
@ -1911,19 +1918,30 @@ Java_sun_awt_X11_XlibWrapper_SetRectangularShape
jint x1, jint y1, jint x2, jint y2,
jobject region)
{
XRectangle rects[256];
XRectangle *pRect = rects;
int numrects;
AWT_CHECK_HAVE_LOCK();
numrects = RegionToYXBandedRectangles(env, x1, y1, x2, y2, region,
&pRect, 256);
// If all the params are zeros, the shape must be simply reset.
// Otherwise, the shape may be not rectangular.
if (region || x1 || x2 || y1 || y2) {
XRectangle rects[256];
XRectangle *pRect = rects;
XShapeCombineRectangles((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
int numrects = RegionToYXBandedRectangles(env, x1, y1, x2, y2, region,
&pRect, 256);
XShapeCombineRectangles((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
ShapeClip, 0, 0, pRect, numrects, ShapeSet, YXBanded);
XShapeCombineRectangles((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
ShapeBounding, 0, 0, pRect, numrects, ShapeSet, YXBanded);
if (pRect != rects) {
free(pRect);
if (pRect != rects) {
free(pRect);
}
} else {
// Reset the shape to a rectangular form.
XShapeCombineMask((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
ShapeClip, 0, 0, None, ShapeSet);
XShapeCombineMask((Display *)jlong_to_ptr(display), (Window)jlong_to_ptr(window),
ShapeBounding, 0, 0, None, ShapeSet);
}
}

View File

@ -68,13 +68,6 @@ public abstract class WComponentPeer extends WObjectPeer
private static final Logger log = Logger.getLogger("sun.awt.windows.WComponentPeer");
private static final Logger shapeLog = Logger.getLogger("sun.awt.windows.shape.WComponentPeer");
static {
wheelInit();
}
// Only actually does stuff if running on 95
native static void wheelInit();
// ComponentPeer implementation
SurfaceData surfaceData;
@ -964,8 +957,12 @@ public abstract class WComponentPeer extends WObjectPeer
+ "; SHAPE: " + shape);
}
setRectangularShape(shape.getLoX(), shape.getLoY(), shape.getHiX(), shape.getHiY(),
(shape.isRectangular() ? null : shape));
if (shape != null) {
setRectangularShape(shape.getLoX(), shape.getLoY(), shape.getHiX(), shape.getHiY(),
(shape.isRectangular() ? null : shape));
} else {
setRectangularShape(0, 0, 0, 0, null);
}
}
}

View File

@ -548,11 +548,15 @@ public class WInputMethod extends InputMethodAdapter
public void inquireCandidatePosition()
{
Component source = getClientComponent();
if (source == null) {
return;
}
// This call should return immediately just to cause
// InputMethodRequests.getTextLocation be called within
// AWT Event thread. Otherwise, a potential deadlock
// could happen.
java.awt.EventQueue.invokeLater(new Runnable() {
Runnable r = new Runnable() {
public void run() {
int x = 0;
int y = 0;
@ -573,7 +577,9 @@ public class WInputMethod extends InputMethodAdapter
openCandidateWindow(awtFocussedComponentPeer, x, y);
}
});
};
WToolkit.postEvent(WToolkit.targetToAppContext(source),
new InvocationEvent(source, r));
}
// java.awt.Toolkit#getNativeContainer() is not available

Some files were not shown because too many files have changed in this diff Show More