提交 27b5dfcf 编写于 作者: D duke

Merge

......@@ -21,3 +21,4 @@ ab523b49de1fc73fefe6855ce1e0349bdbd7af29 jdk7-b39
a395e3aac4744cc9033fcd819fad1239a45add52 jdk7-b44
99846f001ca214015578d593802d26e27246a802 jdk7-b45
e8a2a4d187773a62f3309b0fa265c13425bc2258 jdk7-b46
d7744e86dedc21a8ecf6bdb73eb191b8eaf5b0da jdk7-b47
......@@ -21,3 +21,4 @@ ccd6a16502e0650d91d85c4b86be05cbcd461a87 jdk7-b42
9803dac7254041b30ca65e3852d4c566b9757c3b jdk7-b44
68814aa5b44b1f16931a97e7cd4028c70eb9586b jdk7-b45
1691dbfc08f8ee3f4e23a1ff30cdff920718696c jdk7-b46
167ad0164301f318b069a947e1c9c07ed667748a jdk7-b47
......@@ -21,3 +21,4 @@ fc6a5ae3fef5ebacfa896dbb3ae37715e388e282 jdk7-b43
809e899c638bd9b21836abf9d09ab2a30ff3900b jdk7-b44
945bf754069766e76873c53102fae48abf04cf5b jdk7-b45
16bb38eeda35b46268eefa4c1f829eb086e0ca46 jdk7-b46
fcb923bad68e2b10380a030ea83a723f4dc3d4d6 jdk7-b47
......@@ -21,3 +21,4 @@ cc5f810b5af8a3a83b0df5a29d9e24d7a0ff8086 jdk7-b38
d8eb2738db6b148911177d9bcfe888109b7f2f71 jdk7-b44
527b426497a259d0605d069e3930e838948531a6 jdk7-b45
4b03e27a44090d1f646af28dc58f9ead827e24c7 jdk7-b46
b4ac413b1f129eeef0acab3f31081c1b7dfe3b27 jdk7-b47
......@@ -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
......@@ -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
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
$(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
......@@ -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
......@@ -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;
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
/*
* 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);
}
}
......@@ -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) {
......
......@@ -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();
}
}
......
......@@ -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();
}
......
......@@ -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) {
......
......@@ -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();
}
}
......
......@@ -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);
}
}
......
......@@ -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
* 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.
*
* @param buttons the Button mask; a combination of one or more
* of these flags:
* The valid combination also depends on a
* {@link Toolkit#areExtraMouseButtonsEnabled() Toolkit.areExtraMouseButtonsEnabled()} value as follows:
* <ul>
* <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>
* <p>
* The following standard button masks are also accepted:
* <ul>
* <li><code>InputEvent.BUTTON1_MASK</code>
* <li><code>InputEvent.BUTTON2_MASK</code>
* <li><code>InputEvent.BUTTON3_MASK</code>
* <li>{@code InputEvent.BUTTON1_MASK}
* <li>{@code InputEvent.BUTTON2_MASK}
* <li>{@code InputEvent.BUTTON3_MASK}
* </ul>
* @throws IllegalArgumentException if the button mask is not a
* valid combination
* 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> 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</code>
* <li><code>InputEvent.BUTTON2_MASK</code>
* <li><code>InputEvent.BUTTON3_MASK</code>
* <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);
......
......@@ -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();
}
}
......
......@@ -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();
}
}
......
/*
* 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();
}
}
......@@ -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));
}
/**
......
<!--
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>
......@@ -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 '+'
......
......@@ -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);
......
......@@ -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);
}
......@@ -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
......
......@@ -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);
}
......@@ -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);
}
......@@ -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();
void select(int index);
/*
* DEPRECATED: Replaced by add(String, int).
/**
* Selects the item at index {@code index}.
*
* @param index the index which should be selected
*
* @see Choice#select(int)
*/
void addItem(String item, int index);
void select(int index);
}
......@@ -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,115 +50,493 @@ 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;
/**
* 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();
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);
GraphicsConfiguration getGraphicsConfiguration();
boolean handlesWheelScrolling();
void createBuffers(int numBuffers, BufferCapabilities caps) throws AWTException;
Image getBackBuffer();
void flip(int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction);
void destroyBuffers();
/**
* Reparents this peer to the new parent referenced by <code>newContainer</code> peer
* Implementation depends on toolkit and container.
* @param newContainer peer of the new parent container
* @since 1.5
* 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 reparent(ContainerPeer newContainer);
void setVisible(boolean v);
/**
* Returns whether this peer supports reparenting to another parent withour destroying the peer
* @return true if appropriate reparent is supported, false otherwise
* @since 1.5
* 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)
*/
boolean isReparentSupported();
void setEnabled(boolean e);
/**
* 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.
* 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 layout();
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);
Rectangle getBounds();
/**
* 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);
/**
* Applies the shape to the native component window.
* @since 1.7
* Called to let the component peer handle events.
*
* @param e the AWT event to handle
*
* @see Component#dispatchEvent(AWTEvent)
*/
void applyShape(Region shape);
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);
/**
* DEPRECATED: Replaced by getPreferredSize().
* Determines the location of the component on the screen.
*
* @return the location of the component on the screen
*
* @see Component#getLocationOnScreen()
*/
Dimension preferredSize();
Point getLocationOnScreen();
/**
* DEPRECATED: Replaced by getMinimumSize().
* Determines the preferred size of the component.
*
* @return the preferred size of the component
*
* @see Component#getPreferredSize()
*/
Dimension minimumSize();
Dimension getPreferredSize();
/**
* DEPRECATED: Replaced by setVisible(boolean).
* Determines the minimum size of the component.
*
* @return the minimum size of the component
*
* @see Component#getMinimumSize()
*/
void show();
Dimension getMinimumSize();
/**
* DEPRECATED: Replaced by setVisible(boolean).
* Returns the color model used by the component.
*
* @return the color model used by the component
*
* @see Component#getColorModel()
*/
void hide();
ColorModel getColorModel();
/**
* DEPRECATED: Replaced by setEnabled(boolean).
* Returns the toolkit that is responsible for the component.
*
* @return the toolkit that is responsible for the component
*
* @see Component#getToolkit()
*/
void enable();
Toolkit getToolkit();
/**
* DEPRECATED: Replaced by setEnabled(boolean).
* Returns a graphics object to paint on the component.
*
* @return a graphics object to paint on the component
*
* @see Component#getGraphics()
*/
void disable();
// TODO: Maybe change this to force Graphics2D, since many things will
// break with plain Graphics nowadays.
Graphics getGraphics();
/**
* DEPRECATED: Replaced by setBounds(int, int, int, int).
* 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)
*/
void reshape(int x, int y, int width, int height);
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();
/**
* 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} 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 without
* destroying the peer.
*
* @return true if appropriate reparent is supported, false otherwise
*
* @since 1.5
*/
boolean isReparentSupported();
/**
* 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();
/**
* Applies the shape to the native component window.
* @since 1.7
*
* @see Component#applyCompoundShape
*/
void applyShape(Region shape);
}
......@@ -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 {
/**
* 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();
boolean isPaintPending();
/**
* Restacks native windows - children of this native window - according to Java container order
* 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();
}
......@@ -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;
}
......@@ -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);
}
......@@ -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);
}
......@@ -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
......
......@@ -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();
}
......@@ -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);
}
......@@ -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);
}
......@@ -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);
void deselect(int index);
void makeVisible(int index);
void setMultipleMode(boolean b);
Dimension getPreferredSize(int rows);
Dimension getMinimumSize(int rows);
/**
* DEPRECATED: Replaced by add(String, int).
* De-selects the item at the specified {@code index}.
*
* @param index the index of the item to de-select
*
* @see List#deselect(int)
*/
void addItem(String item, int index);
void deselect(int index);
/**
* DEPRECATED: Replaced by removeAll().
* 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 clear();
void makeVisible(int index);
/**
* DEPRECATED: Replaced by setMultipleMode(boolean).
* 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 setMultipleSelections(boolean v);
void setMultipleMode(boolean m);
/**
* DEPRECATED: Replaced by getPreferredSize(int).
* 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 preferredSize(int v);
Dimension getPreferredSize(int rows);
/**
* DEPRECATED: Replaced by getMinimumSize(int).
* 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 minimumSize(int v);
Dimension getMinimumSize(int rows);
}
......@@ -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);
}
......@@ -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);
}
......@@ -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 {
void setLabel(String label);
void setEnabled(boolean b);
/**
* DEPRECATED: Replaced by setEnabled(boolean).
* Sets the label to be displayed in this menu item.
*
* @param label the label to be displayed
*/
void enable();
void setLabel(String label);
/**
* 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 disable();
void setEnabled(boolean e);
}
......@@ -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);
}
......@@ -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
......
......@@ -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
......
......@@ -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);
}
/*
* 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();
}
......@@ -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);
}
......@@ -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);
}
......@@ -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();
}
......@@ -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 {
void insert(String text, int pos);
void replaceRange(String text, int start, int end);
Dimension getPreferredSize(int rows, int columns);
Dimension getMinimumSize(int rows, int columns);
/**
* DEPRECATED: Replaced by insert(String, int).
* 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 insertText(String txt, int pos);
void insert(String text, int pos);
/**
* DEPRECATED: Replaced by ReplaceRange(String, int, int).
* 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 replaceText(String txt, int start, int end);
void replaceRange(String text, int start, int end);
/**
* DEPRECATED: Replaced by getPreferredSize(int, int).
* 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 preferredSize(int rows, int cols);
Dimension getPreferredSize(int rows, int columns);
/**
* DEPRECATED: Replaced by getMinimumSize(int, int).
* 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 minimumSize(int rows, int cols);
Dimension getMinimumSize(int rows, int columns);
}
......@@ -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();
}
......@@ -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 {
void setEchoChar(char echoChar);
Dimension getPreferredSize(int columns);
Dimension getMinimumSize(int columns);
/**
* DEPRECATED: Replaced by setEchoChar(char echoChar).
* Sets the echo character.
*
* @param echoChar the echo character to set
*
* @see TextField#getEchoChar()
*/
void setEchoCharacter(char c);
void setEchoChar(char echoChar);
/**
* DEPRECATED: Replaced by getPreferredSize(int).
* 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 preferredSize(int cols);
Dimension getPreferredSize(int columns);
/**
* DEPRECATED: Replaced by getMinimumSize(int).
* 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 minimumSize(int cols);
Dimension getMinimumSize(int columns);
}
......@@ -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);
}
......@@ -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();
}
......@@ -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
......
/*
* 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");
}
}
......@@ -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>
......
/*
* 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
*/
......
<!--
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>
......
......@@ -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
*/
......
......@@ -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"));
}
}
......
......@@ -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
......
......@@ -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;
}
/**
......
......@@ -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);
......
/*
* 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;
}
}
/*
* 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();
}
}
/*
* 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 {
......
......@@ -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 {
......
......@@ -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)
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册