Merge
This commit is contained in:
commit
bc231c8c92
@ -189,7 +189,7 @@ reduced-headless-image-jre:: $(RT_JAR) $(RESOURCES_JAR) $(BUILD_META_INDEX) $(HL
|
||||
$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/audio
|
||||
$(RM) -fr $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/applet
|
||||
$(RM) $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/awt_robot
|
||||
$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/xawt
|
||||
$(RM) $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/libawt_xawt.so
|
||||
$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/libsplashscreen.so
|
||||
@# Remove oblique fonts and reduce font support to LucidaSansRegular only
|
||||
$(RM) -fr $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/oblique-fonts
|
||||
|
@ -175,7 +175,7 @@ else # PLATFORM
|
||||
ifeq ($(PLATFORM), solaris)
|
||||
# Note that on Solaris, fontmanager is built against the headless library.
|
||||
LDFLAGS += -L$(LIBDIR)/$(LIBARCH)/headless
|
||||
OTHER_LDLIBS += -lawt -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt -lc $(LIBM) $(LIBCXX)
|
||||
OTHER_LDLIBS += -lawt -lawt_xawt -lc $(LIBM) $(LIBCXX)
|
||||
else # PLATFORM is linux
|
||||
OTHER_LDLIBS += -lawt $(LIBM) $(LIBCXX)
|
||||
ifeq ("$(CC_VER_MAJOR)", "3")
|
||||
|
@ -99,7 +99,7 @@ ifneq ($(PLATFORM), windows)
|
||||
endif
|
||||
else
|
||||
ifeq ($(PLATFORM), solaris)
|
||||
OTHER_LDLIBS += -lawt -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt
|
||||
OTHER_LDLIBS += -lawt -lawt_xawt
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
@ -28,11 +28,9 @@ HEADLESS = true
|
||||
NO_ROBOT = true
|
||||
MOTIF_VERSION = none
|
||||
MOTIF_VERSION_STRING=none
|
||||
LIB_LOCATION = $(LIBDIR)/$(LIBARCH)/headless
|
||||
|
||||
PACKAGE = sun.awt
|
||||
LIBRARY = mawt
|
||||
LIBRARY_OUTPUT = headless
|
||||
LIBRARY = awt_headless
|
||||
PRODUCT = sun
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
@ -113,17 +113,17 @@ CPPFLAGS += -I$(OPENWIN_HOME)/include \
|
||||
#
|
||||
ifeq ($(PLATFORM), solaris)
|
||||
ifndef BUILD_HEADLESS_ONLY
|
||||
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -L$(OPENWIN_LIB) -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt -L/usr/openwin/sfw/lib$(ISA_DIR) -lXrender
|
||||
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -L$(OPENWIN_LIB) -lawt_xawt -L/usr/openwin/sfw/lib$(ISA_DIR) -lXrender
|
||||
else
|
||||
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -L$(OPENWIN_LIB) -L$(LIBDIR)/$(LIBARCH)/headless -lmawt -L/usr/openwin/sfw/lib$(ISA_DIR) -lXrender
|
||||
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -L$(OPENWIN_LIB) -lawt_headless -L/usr/openwin/sfw/lib$(ISA_DIR) -lXrender
|
||||
endif
|
||||
endif # PLATFORM
|
||||
|
||||
ifeq ($(PLATFORM), linux)
|
||||
ifndef BUILD_HEADLESS_ONLY
|
||||
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt
|
||||
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -lawt_xawt
|
||||
else
|
||||
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -L$(LIBDIR)/$(LIBARCH)/headless -lmawt
|
||||
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -lawt_headless
|
||||
CFLAGS += -DHEADLESS
|
||||
endif
|
||||
endif # PLATFORM
|
||||
|
@ -25,9 +25,7 @@
|
||||
|
||||
BUILDDIR = ../..
|
||||
PACKAGE = sun.awt.X11
|
||||
LIBRARY = mawt
|
||||
LIBRARY_OUTPUT = xawt
|
||||
LIB_LOCATION = $(LIBDIR)/$(LIBARCH)/xawt
|
||||
LIBRARY = awt_xawt
|
||||
PRODUCT = sun
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
@ -30,6 +30,7 @@ import java.io.ObjectOutput;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.IOException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
/**
|
||||
@ -93,14 +94,14 @@ class MimeType implements Externalizable, Cloneable {
|
||||
MimeTypeParseException {
|
||||
// check to see if primary is valid
|
||||
if(isValidToken(primary)) {
|
||||
primaryType = primary.toLowerCase();
|
||||
primaryType = primary.toLowerCase(Locale.ENGLISH);
|
||||
} else {
|
||||
throw new MimeTypeParseException("Primary type is invalid.");
|
||||
}
|
||||
|
||||
// check to see if sub is valid
|
||||
if(isValidToken(sub)) {
|
||||
subType = sub.toLowerCase();
|
||||
subType = sub.toLowerCase(Locale.ENGLISH);
|
||||
} else {
|
||||
throw new MimeTypeParseException("Sub type is invalid.");
|
||||
}
|
||||
@ -158,17 +159,17 @@ MimeTypeParseException {
|
||||
throw new MimeTypeParseException("Unable to find a sub type.");
|
||||
} else if((slashIndex >= 0) && (semIndex < 0)) {
|
||||
// we have a primary and sub type but no parameter list
|
||||
primaryType = rawdata.substring(0,
|
||||
slashIndex).trim().toLowerCase();
|
||||
subType = rawdata.substring(slashIndex +
|
||||
1).trim().toLowerCase();
|
||||
primaryType = rawdata.substring(0,slashIndex).
|
||||
trim().toLowerCase(Locale.ENGLISH);
|
||||
subType = rawdata.substring(slashIndex + 1).
|
||||
trim().toLowerCase(Locale.ENGLISH);
|
||||
parameters = new MimeTypeParameterList();
|
||||
} else if (slashIndex < semIndex) {
|
||||
// we have all three items in the proper sequence
|
||||
primaryType = rawdata.substring(0,
|
||||
slashIndex).trim().toLowerCase();
|
||||
primaryType = rawdata.substring(0, slashIndex).
|
||||
trim().toLowerCase(Locale.ENGLISH);
|
||||
subType = rawdata.substring(slashIndex + 1,
|
||||
semIndex).trim().toLowerCase();
|
||||
semIndex).trim().toLowerCase(Locale.ENGLISH);
|
||||
parameters = new
|
||||
MimeTypeParameterList(rawdata.substring(semIndex));
|
||||
} else {
|
||||
|
@ -758,7 +758,6 @@ public class MouseEvent extends InputEvent {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. 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
|
||||
@ -25,134 +25,134 @@
|
||||
|
||||
package java.beans;
|
||||
|
||||
/**
|
||||
* A bean implementor who wishes to provide explicit information about
|
||||
* their bean may provide a BeanInfo class that implements this BeanInfo
|
||||
* interface and provides explicit information about the methods,
|
||||
* properties, events, etc, of their bean.
|
||||
* <p>
|
||||
* A bean implementor doesn't need to provide a complete set of
|
||||
* explicit information. You can pick and choose which information
|
||||
* you want to provide and the rest will be obtained by automatic
|
||||
* analysis using low-level reflection of the bean classes' methods
|
||||
* and applying standard design patterns.
|
||||
* <p>
|
||||
* You get the opportunity to provide lots and lots of different
|
||||
* information as part of the various XyZDescriptor classes. But
|
||||
* don't panic, you only really need to provide the minimal core
|
||||
* information required by the various constructors.
|
||||
* <P>
|
||||
* See also the SimpleBeanInfo class which provides a convenient
|
||||
* "noop" base class for BeanInfo classes, which you can override
|
||||
* for those specific places where you want to return explicit info.
|
||||
* <P>
|
||||
* To learn about all the behaviour of a bean see the Introspector class.
|
||||
*/
|
||||
import java.awt.Image;
|
||||
|
||||
/**
|
||||
* Use the {@code BeanInfo} interface
|
||||
* to create a {@code BeanInfo} class
|
||||
* and provide explicit information about the methods,
|
||||
* properties, events, and other features of your beans.
|
||||
* <p>
|
||||
* When developing your bean, you can implement
|
||||
* the bean features required for your application task
|
||||
* omitting the rest of the {@code BeanInfo} features.
|
||||
* They will be obtained through the automatic analysis
|
||||
* by using the low-level reflection of the bean methods
|
||||
* and applying standard design patterns.
|
||||
* You have an opportunity to provide additional bean information
|
||||
* through various descriptor classes.
|
||||
* <p>
|
||||
* See the {@link SimpleBeanInfo} class that is
|
||||
* a convenient basic class for {@code BeanInfo} classes.
|
||||
* You can override the methods and properties of
|
||||
* the {@code SimpleBeanInfo} class to define specific information.
|
||||
* <p>
|
||||
* See also the {@link Introspector} class to learn more about bean behavior.
|
||||
*/
|
||||
public interface BeanInfo {
|
||||
|
||||
/**
|
||||
* Gets the beans <code>BeanDescriptor</code>.
|
||||
* Returns the bean descriptor
|
||||
* that provides overall information about the bean,
|
||||
* such as its display name or its customizer.
|
||||
*
|
||||
* @return A BeanDescriptor providing overall information about
|
||||
* the bean, such as its displayName, its customizer, etc. May
|
||||
* return null if the information should be obtained by automatic
|
||||
* analysis.
|
||||
* @return a {@link BeanDescriptor} object,
|
||||
* or {@code null} if the information is to
|
||||
* be obtained through the automatic analysis
|
||||
*/
|
||||
BeanDescriptor getBeanDescriptor();
|
||||
|
||||
/**
|
||||
* Gets the beans <code>EventSetDescriptor</code>s.
|
||||
* Returns the event descriptors of the bean
|
||||
* that define the types of events fired by this bean.
|
||||
*
|
||||
* @return An array of EventSetDescriptors describing the kinds of
|
||||
* events fired by this bean. May return null if the information
|
||||
* should be obtained by automatic analysis.
|
||||
* @return an array of {@link EventSetDescriptor} objects,
|
||||
* or {@code null} if the information is to
|
||||
* be obtained through the automatic analysis
|
||||
*/
|
||||
EventSetDescriptor[] getEventSetDescriptors();
|
||||
|
||||
/**
|
||||
* A bean may have a "default" event that is the event that will
|
||||
* mostly commonly be used by humans when using the bean.
|
||||
* @return Index of default event in the EventSetDescriptor array
|
||||
* returned by getEventSetDescriptors.
|
||||
* <P> Returns -1 if there is no default event.
|
||||
* A bean may have a default event typically applied when this bean is used.
|
||||
*
|
||||
* @return index of the default event in the {@code EventSetDescriptor} array
|
||||
* returned by the {@code getEventSetDescriptors} method,
|
||||
* or -1 if there is no default event
|
||||
*/
|
||||
int getDefaultEventIndex();
|
||||
|
||||
/**
|
||||
* Returns descriptors for all properties of the bean.
|
||||
* May return {@code null} if the information
|
||||
* should be obtained by automatic analysis.
|
||||
* <p>
|
||||
* If a property is indexed, then its entry in the result array
|
||||
* will belong to the {@link IndexedPropertyDescriptor} subclass
|
||||
* belongs to the {@link IndexedPropertyDescriptor} subclass
|
||||
* of the {@link PropertyDescriptor} class.
|
||||
* A client of the {@code getPropertyDescriptors} method
|
||||
* can use "{@code instanceof}" to check
|
||||
* can use the {@code instanceof} operator to check
|
||||
* whether a given {@code PropertyDescriptor}
|
||||
* is an {@code IndexedPropertyDescriptor}.
|
||||
*
|
||||
* @return an array of {@code PropertyDescriptor}s
|
||||
* describing all properties supported by the bean
|
||||
* or {@code null}
|
||||
* @return an array of {@code PropertyDescriptor} objects,
|
||||
* or {@code null} if the information is to
|
||||
* be obtained through the automatic analysis
|
||||
*/
|
||||
PropertyDescriptor[] getPropertyDescriptors();
|
||||
|
||||
/**
|
||||
* A bean may have a "default" property that is the property that will
|
||||
* mostly commonly be initially chosen for update by human's who are
|
||||
* customizing the bean.
|
||||
* @return Index of default property in the PropertyDescriptor array
|
||||
* returned by getPropertyDescriptors.
|
||||
* <P> Returns -1 if there is no default property.
|
||||
* A bean may have a default property commonly updated when this bean is customized.
|
||||
*
|
||||
* @return index of the default property in the {@code PropertyDescriptor} array
|
||||
* returned by the {@code getPropertyDescriptors} method,
|
||||
* or -1 if there is no default property
|
||||
*/
|
||||
int getDefaultPropertyIndex();
|
||||
|
||||
/**
|
||||
* Gets the beans <code>MethodDescriptor</code>s.
|
||||
* Returns the method descriptors of the bean
|
||||
* that define the externally visible methods supported by this bean.
|
||||
*
|
||||
* @return An array of MethodDescriptors describing the externally
|
||||
* visible methods supported by this bean. May return null if
|
||||
* the information should be obtained by automatic analysis.
|
||||
* @return an array of {@link MethodDescriptor} objects,
|
||||
* or {@code null} if the information is to
|
||||
* be obtained through the automatic analysis
|
||||
*/
|
||||
MethodDescriptor[] getMethodDescriptors();
|
||||
|
||||
/**
|
||||
* This method allows a BeanInfo object to return an arbitrary collection
|
||||
* of other BeanInfo objects that provide additional information on the
|
||||
* current bean.
|
||||
* <P>
|
||||
* If there are conflicts or overlaps between the information provided
|
||||
* by different BeanInfo objects, then the current BeanInfo takes precedence
|
||||
* over the getAdditionalBeanInfo objects, and later elements in the array
|
||||
* take precedence over earlier ones.
|
||||
* This method enables the current {@code BeanInfo} object
|
||||
* to return an arbitrary collection of other {@code BeanInfo} objects
|
||||
* that provide additional information about the current bean.
|
||||
* <p>
|
||||
* If there are conflicts or overlaps between the information
|
||||
* provided by different {@code BeanInfo} objects,
|
||||
* the current {@code BeanInfo} object takes priority
|
||||
* over the additional {@code BeanInfo} objects.
|
||||
* Array elements with higher indices take priority
|
||||
* over the elements with lower indices.
|
||||
*
|
||||
* @return an array of BeanInfo objects. May return null.
|
||||
* @return an array of {@code BeanInfo} objects,
|
||||
* or {@code null} if there are no additional {@code BeanInfo} objects
|
||||
*/
|
||||
BeanInfo[] getAdditionalBeanInfo();
|
||||
|
||||
/**
|
||||
* This method returns an image object that can be used to
|
||||
* represent the bean in toolboxes, toolbars, etc. Icon images
|
||||
* will typically be GIFs, but may in future include other formats.
|
||||
* Returns an image that can be used to represent the bean in toolboxes or toolbars.
|
||||
* <p>
|
||||
* Beans aren't required to provide icons and may return null from
|
||||
* this method.
|
||||
* <p>
|
||||
* There are four possible flavors of icons (16x16 color,
|
||||
* 32x32 color, 16x16 mono, 32x32 mono). If a bean choses to only
|
||||
* support a single icon we recommend supporting 16x16 color.
|
||||
* <p>
|
||||
* We recommend that icons have a "transparent" background
|
||||
* so they can be rendered onto an existing background.
|
||||
* There are four possible types of icons:
|
||||
* 16 x 16 color, 32 x 32 color, 16 x 16 mono, and 32 x 32 mono.
|
||||
* If you implement a bean so that it supports a single icon,
|
||||
* it is recommended to use 16 x 16 color.
|
||||
* Another recommendation is to set a transparent background for the icons.
|
||||
*
|
||||
* @param iconKind The kind of icon requested. This should be
|
||||
* one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32,
|
||||
* ICON_MONO_16x16, or ICON_MONO_32x32.
|
||||
* @return An image object representing the requested icon. May
|
||||
* return null if no suitable icon is available.
|
||||
* @param iconKind the kind of icon requested
|
||||
* @return an image object representing the requested icon,
|
||||
* or {@code null} if no suitable icon is available
|
||||
*
|
||||
* @see #ICON_COLOR_16x16
|
||||
* @see #ICON_COLOR_32x32
|
||||
* @see #ICON_MONO_16x16
|
||||
* @see #ICON_MONO_32x32
|
||||
*/
|
||||
java.awt.Image getIcon(int iconKind);
|
||||
Image getIcon(int iconKind);
|
||||
|
||||
/**
|
||||
* Constant to indicate a 16 x 16 color icon.
|
||||
|
@ -473,7 +473,7 @@ public class Introspector {
|
||||
// Now analyze each method.
|
||||
for (int i = 0; i < methodList.length; i++) {
|
||||
Method method = methodList[i];
|
||||
if (method == null || method.isSynthetic()) {
|
||||
if (method == null) {
|
||||
continue;
|
||||
}
|
||||
// skip static methods.
|
||||
|
@ -559,7 +559,7 @@ public class PropertyDescriptor extends FeatureDescriptor {
|
||||
|
||||
// Normally give priority to y's readMethod.
|
||||
try {
|
||||
if (yr != null && yr.getDeclaringClass() == getClass0()) {
|
||||
if (isAssignable(xr, yr)) {
|
||||
setReadMethod(yr);
|
||||
} else {
|
||||
setReadMethod(xr);
|
||||
@ -713,4 +713,37 @@ public class PropertyDescriptor extends FeatureDescriptor {
|
||||
appendTo(sb, "readMethod", this.readMethodRef);
|
||||
appendTo(sb, "writeMethod", this.writeMethodRef);
|
||||
}
|
||||
|
||||
private boolean isAssignable(Method m1, Method m2) {
|
||||
if (m1 == null) {
|
||||
return true; // choose second method
|
||||
}
|
||||
if (m2 == null) {
|
||||
return false; // choose first method
|
||||
}
|
||||
if (!m1.getName().equals(m2.getName())) {
|
||||
return true; // choose second method by default
|
||||
}
|
||||
Class<?> type1 = m1.getDeclaringClass();
|
||||
Class<?> type2 = m2.getDeclaringClass();
|
||||
if (!type1.isAssignableFrom(type2)) {
|
||||
return false; // choose first method: it declared later
|
||||
}
|
||||
type1 = getReturnType(getClass0(), m1);
|
||||
type2 = getReturnType(getClass0(), m2);
|
||||
if (!type1.isAssignableFrom(type2)) {
|
||||
return false; // choose first method: it overrides return type
|
||||
}
|
||||
Class<?>[] args1 = getParameterTypes(getClass0(), m1);
|
||||
Class<?>[] args2 = getParameterTypes(getClass0(), m2);
|
||||
if (args1.length != args2.length) {
|
||||
return true; // choose second method by default
|
||||
}
|
||||
for (int i = 0; i < args1.length; i++) {
|
||||
if (!args1[i].isAssignableFrom(args2[i])) {
|
||||
return false; // choose first method: it overrides parameter
|
||||
}
|
||||
}
|
||||
return true; // choose second method
|
||||
}
|
||||
}
|
||||
|
@ -1115,9 +1115,8 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
|
||||
protected int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected) {
|
||||
Rectangle tabRect = rects[tabIndex];
|
||||
String propKey = (isSelected ? "selectedLabelShift" : "labelShift");
|
||||
int nudge = DefaultLookup.getInt(
|
||||
tabPane, this, "TabbedPane." + propKey, 1);
|
||||
int nudge = (isSelected ? DefaultLookup.getInt(tabPane, this, "TabbedPane.selectedLabelShift", -1) :
|
||||
DefaultLookup.getInt(tabPane, this, "TabbedPane.labelShift", 1));
|
||||
|
||||
switch (tabPlacement) {
|
||||
case BOTTOM:
|
||||
|
@ -447,10 +447,20 @@ public class SynthComboBoxUI extends BasicComboBoxUI implements
|
||||
private class SynthComboBoxRenderer extends JLabel implements ListCellRenderer<Object>, UIResource {
|
||||
public SynthComboBoxRenderer() {
|
||||
super();
|
||||
setName("ComboBox.renderer");
|
||||
setText(" ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
// SynthComboBoxRenderer should have installed Name while constructor is working.
|
||||
// The setName invocation in the SynthComboBoxRenderer() constructor doesn't work
|
||||
// because of the opaque property is installed in the constructor based on the
|
||||
// component name (see GTKStyle.isOpaque())
|
||||
String name = super.getName();
|
||||
|
||||
return name == null ? "ComboBox.renderer" : name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value,
|
||||
int index, boolean isSelected, boolean cellHasFocus) {
|
||||
|
@ -39,6 +39,7 @@ public class OSInfo {
|
||||
WINDOWS,
|
||||
LINUX,
|
||||
SOLARIS,
|
||||
MACOSX,
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
@ -100,6 +101,10 @@ public class OSInfo {
|
||||
return SOLARIS;
|
||||
}
|
||||
|
||||
if (osName.startsWith("Mac OS X")) {
|
||||
return MACOSX;
|
||||
}
|
||||
|
||||
// determine another OS here
|
||||
}
|
||||
|
||||
|
@ -255,6 +255,21 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
}
|
||||
}
|
||||
|
||||
if (owner != null || isSimpleWindow()) {
|
||||
XNETProtocol protocol = XWM.getWM().getNETProtocol();
|
||||
if (protocol != null && protocol.active()) {
|
||||
XToolkit.awtLock();
|
||||
try {
|
||||
XAtomList net_wm_state = getNETWMState();
|
||||
net_wm_state.add(protocol.XA_NET_WM_STATE_SKIP_TASKBAR);
|
||||
setNETWMState(net_wm_state);
|
||||
} finally {
|
||||
XToolkit.awtUnlock();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Init warning window(for applets)
|
||||
if (((Window)target).getWarningString() != null) {
|
||||
// accessSystemTray permission allows to display TrayIcon, TrayIcon tooltip
|
||||
@ -480,14 +495,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
bounds.x, bounds.y, bounds.width, bounds.height);
|
||||
XWM.setMotifDecor(this, false, 0, 0);
|
||||
|
||||
XNETProtocol protocol = XWM.getWM().getNETProtocol();
|
||||
if (protocol != null && protocol.active()) {
|
||||
XAtomList net_wm_state = getNETWMState();
|
||||
net_wm_state.add(protocol.XA_NET_WM_STATE_SKIP_TASKBAR);
|
||||
setNETWMState(net_wm_state);
|
||||
}
|
||||
|
||||
|
||||
boolean isResized = !bounds.getSize().equals(oldBounds.getSize());
|
||||
boolean isMoved = !bounds.getLocation().equals(oldBounds.getLocation());
|
||||
if (isMoved || isResized) {
|
||||
|
@ -310,7 +310,7 @@ static int ParseLocale(int cat, char ** std_language, char ** std_script,
|
||||
}
|
||||
|
||||
#ifdef JAVASE_EMBEDDED
|
||||
/* Determine the default embedded toolkit based on whether lib/xawt/
|
||||
/* Determine the default embedded toolkit based on whether libawt_xawt
|
||||
* exists in the JRE. This can still be overridden by -Dawt.toolkit=XXX
|
||||
*/
|
||||
static char* getEmbeddedToolkit() {
|
||||
@ -325,8 +325,8 @@ static char* getEmbeddedToolkit() {
|
||||
realpath((char *)dlinfo.dli_fname, buf);
|
||||
len = strlen(buf);
|
||||
p = strrchr(buf, '/');
|
||||
/* Default AWT Toolkit on Linux and Solaris is XAWT. */
|
||||
strncpy(p, "/xawt/", MAXPATHLEN-len-1);
|
||||
/* Default AWT Toolkit on Linux and Solaris is XAWT (libawt_xawt.so). */
|
||||
strncpy(p, "/libawt_xawt.so", MAXPATHLEN-len-1);
|
||||
/* Check if it exists */
|
||||
if (stat(buf, &statbuf) == -1 && errno == ENOENT) {
|
||||
/* No - this is a reduced-headless-jre so use special HToolkit */
|
||||
|
@ -105,7 +105,7 @@ AWT_OnLoad(JavaVM *vm, void *reserved)
|
||||
|
||||
/*
|
||||
* The code below is responsible for:
|
||||
* 1. Loading appropriate awt library, i.e. xawt/libmawt or headless/libwawt
|
||||
* 1. Loading appropriate awt library, i.e. libawt_xawt or libawt_headless
|
||||
* 2. Setting "awt.toolkit" system property to use the appropriate Java toolkit class,
|
||||
* (if user has specified the toolkit in env varialble)
|
||||
*/
|
||||
@ -130,10 +130,10 @@ AWT_OnLoad(JavaVM *vm, void *reserved)
|
||||
|
||||
/* Calculate library name to load */
|
||||
if (AWTIsHeadless()) {
|
||||
strncpy(p, "/headless/libmawt.so", MAXPATHLEN-len-1);
|
||||
strncpy(p, "/libawt_headless.so", MAXPATHLEN-len-1);
|
||||
} else {
|
||||
/* Default AWT Toolkit on Linux and Solaris is XAWT. */
|
||||
strncpy(p, "/xawt/libmawt.so", MAXPATHLEN-len-1);
|
||||
strncpy(p, "/libawt_xawt.so", MAXPATHLEN-len-1);
|
||||
}
|
||||
|
||||
if (toolkit) {
|
||||
@ -161,7 +161,7 @@ JNI_OnLoad(JavaVM *vm, void *reserved)
|
||||
/*
|
||||
* This entry point must remain in libawt.so as part of a contract
|
||||
* with the CDE variant of Java Media Framework. (sdtjmplay)
|
||||
* Reflect this call over to the correct libmawt.so.
|
||||
* Reflect this call over to the correct libawt_<toolkit>.so.
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_awt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
|
||||
@ -191,7 +191,7 @@ Java_sun_awt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
|
||||
/*
|
||||
* This entry point must remain in libawt.so as part of a contract
|
||||
* with the CDE variant of Java Media Framework. (sdtjmplay)
|
||||
* Reflect this call over to the correct libmawt.so.
|
||||
* Reflect this call over to the correct libawt_<toolkit>.so.
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_awt_motif_XsessionWMcommand_New(JNIEnv *env, jobjectArray jargv)
|
||||
@ -250,7 +250,7 @@ return_type name arglist \
|
||||
|
||||
/*
|
||||
* These entry point must remain in libawt.so ***for Java Plugin ONLY***
|
||||
* Reflect this call over to the correct libmawt.so.
|
||||
* Reflect this call over to the correct libawt_<toolkit>.so.
|
||||
*/
|
||||
|
||||
REFLECT_VOID_FUNCTION(getAwtLockFunctions,
|
||||
|
45
jdk/test/java/beans/Introspector/7122138/Test7122138.java
Normal file
45
jdk/test/java/beans/Introspector/7122138/Test7122138.java
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. 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.
|
||||
*
|
||||
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 7122138
|
||||
* @summary Tests generic methods reflection
|
||||
* @author Sergey Malenkov
|
||||
* @library ..
|
||||
*/
|
||||
|
||||
import pack.Sub;
|
||||
|
||||
public class Test7122138 {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Class<Sub> type = Sub.class;
|
||||
Sub object = type.newInstance();
|
||||
String name = "name";
|
||||
BeanUtils.getPropertyDescriptor(type, name).getWriteMethod().invoke(object, name);
|
||||
if (!name.equals(object.getName())) {
|
||||
throw new Error("name is not set");
|
||||
}
|
||||
}
|
||||
}
|
4
jdk/test/java/beans/Introspector/7122138/pack/Sub.java
Normal file
4
jdk/test/java/beans/Introspector/7122138/pack/Sub.java
Normal file
@ -0,0 +1,4 @@
|
||||
package pack;
|
||||
|
||||
public class Sub<String> extends Super {
|
||||
}
|
14
jdk/test/java/beans/Introspector/7122138/pack/Super.java
Normal file
14
jdk/test/java/beans/Introspector/7122138/pack/Super.java
Normal file
@ -0,0 +1,14 @@
|
||||
package pack;
|
||||
|
||||
class Super<T> {
|
||||
|
||||
T name;
|
||||
|
||||
public void setName(T name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public T getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
81
jdk/test/javax/swing/JComboBox/7082443/bug7082443.java
Normal file
81
jdk/test/javax/swing/JComboBox/7082443/bug7082443.java
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. 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.
|
||||
*
|
||||
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 7082443
|
||||
* @summary JComboBox not backward compatible (with Java 6)
|
||||
* @author Pavel Porvatov
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class bug7082443 {
|
||||
public static final String GTK_LAF_CLASS = "GTKLookAndFeel";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) {
|
||||
if (lookAndFeelInfo.getClassName().contains(GTK_LAF_CLASS)) {
|
||||
UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TestComboBox testComboBox = new TestComboBox();
|
||||
|
||||
if (testComboBox.isOldRendererOpaque()) {
|
||||
System.out.println("Passed for " + GTK_LAF_CLASS);
|
||||
} else {
|
||||
throw new RuntimeException("Failed for " + GTK_LAF_CLASS);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(GTK_LAF_CLASS + " is not found. The test skipped");
|
||||
}
|
||||
|
||||
private static class TestComboBox extends JComboBox {
|
||||
private final ListCellRenderer renderer = new ListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
return TestComboBox.super.getRenderer().getListCellRendererComponent(list, value, index,
|
||||
isSelected, cellHasFocus);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public ListCellRenderer getRenderer() {
|
||||
return renderer;
|
||||
}
|
||||
|
||||
public boolean isOldRendererOpaque() {
|
||||
return ((JLabel) super.getRenderer()).isOpaque();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
415
jdk/test/javax/swing/JList/6462008/bug6462008.java
Normal file
415
jdk/test/javax/swing/JList/6462008/bug6462008.java
Normal file
@ -0,0 +1,415 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. 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.
|
||||
*
|
||||
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6462008
|
||||
* @summary Tests that mouse/keyboard work properly on JList with lead < 0 or > list.getModel().getSize()
|
||||
* @author Shannon Hickey
|
||||
* @run main bug6462008
|
||||
*/
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug6462008 {
|
||||
|
||||
private static final int DONT_CARE = -2;
|
||||
private static int anchorLead;
|
||||
private static boolean isAquaLAF;
|
||||
private static int controlKey;
|
||||
private static JList list;
|
||||
private static SunToolkit toolkit;
|
||||
private static Robot robot;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
|
||||
isAquaLAF = "Aqua".equals(UIManager.getLookAndFeel().getID());
|
||||
controlKey = isAquaLAF ? KeyEvent.VK_META : KeyEvent.VK_CONTROL;
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
|
||||
setAnchorLead(-1);
|
||||
toolkit.realSync();
|
||||
|
||||
testListSelection();
|
||||
|
||||
setAnchorLead(100);
|
||||
toolkit.realSync();
|
||||
|
||||
testListSelection();
|
||||
}
|
||||
|
||||
public static void testListSelection() throws Exception {
|
||||
|
||||
// Space
|
||||
robot.keyPress(KeyEvent.VK_SPACE);
|
||||
robot.keyRelease(KeyEvent.VK_SPACE);
|
||||
|
||||
toolkit.realSync();
|
||||
checkSelection();
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
|
||||
// Control + Space
|
||||
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||
robot.keyPress(KeyEvent.VK_SPACE);
|
||||
robot.keyRelease(KeyEvent.VK_SPACE);
|
||||
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||
|
||||
toolkit.realSync();
|
||||
checkSelection();
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
|
||||
// Shift + Space
|
||||
robot.keyPress(KeyEvent.VK_SHIFT);
|
||||
robot.keyPress(KeyEvent.VK_SPACE);
|
||||
robot.keyRelease(KeyEvent.VK_SPACE);
|
||||
robot.keyRelease(KeyEvent.VK_SHIFT);
|
||||
|
||||
toolkit.realSync();
|
||||
checkSelection();
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
|
||||
// Control + Shift + Space
|
||||
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||
robot.keyPress(KeyEvent.VK_SHIFT);
|
||||
robot.keyPress(KeyEvent.VK_SPACE);
|
||||
robot.keyRelease(KeyEvent.VK_SPACE);
|
||||
robot.keyRelease(KeyEvent.VK_SHIFT);
|
||||
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||
|
||||
toolkit.realSync();
|
||||
checkSelection();
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
|
||||
|
||||
// Control + A Multiple Selection
|
||||
|
||||
robot.keyPress(controlKey);
|
||||
robot.keyPress(KeyEvent.VK_A);
|
||||
robot.keyRelease(KeyEvent.VK_A);
|
||||
robot.keyRelease(controlKey);
|
||||
|
||||
toolkit.realSync();
|
||||
checkSelectionAL(-1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||
resetList();
|
||||
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
toolkit.realSync();
|
||||
|
||||
// Control + A Single Selection
|
||||
robot.keyPress(controlKey);
|
||||
robot.keyPress(KeyEvent.VK_A);
|
||||
robot.keyRelease(KeyEvent.VK_A);
|
||||
robot.keyRelease(controlKey);
|
||||
|
||||
toolkit.realSync();
|
||||
checkSelectionAL(0, 0, 0);
|
||||
resetList();
|
||||
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
setSelectionInterval(5, 5);
|
||||
toolkit.realSync();
|
||||
|
||||
|
||||
// Control + A Selection interval (5, 5)
|
||||
robot.keyPress(controlKey);
|
||||
robot.keyPress(KeyEvent.VK_A);
|
||||
robot.keyRelease(KeyEvent.VK_A);
|
||||
robot.keyRelease(controlKey);
|
||||
|
||||
toolkit.realSync();
|
||||
checkSelection(5);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
|
||||
// Page Down
|
||||
// Not applicable for the Aqua L&F
|
||||
if (!isAquaLAF) {
|
||||
robot.keyPress(KeyEvent.VK_PAGE_DOWN);
|
||||
robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
|
||||
|
||||
toolkit.realSync();
|
||||
checkSelection(9, 9, 9);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
}
|
||||
|
||||
// Shift + Page Down
|
||||
/*
|
||||
* We really want to use robot here, but there seems to be a bug in AWT's
|
||||
* robot implementation (see 6463168). For now, we'll invoke the action
|
||||
* directly instead. When the bug is fixed, we'll use the following four
|
||||
* lines instead:
|
||||
* robot.keyPress(KeyEvent.VK_SHIFT);
|
||||
* robot.keyPress(KeyEvent.VK_PAGE_DOWN);
|
||||
* robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
|
||||
* robot.keyRelease(KeyEvent.VK_SHIFT);
|
||||
*/
|
||||
|
||||
scrollDownExtendSelection();
|
||||
|
||||
toolkit.realSync();
|
||||
checkSelection(0, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
|
||||
// Down
|
||||
robot.keyPress(KeyEvent.VK_DOWN);
|
||||
robot.keyRelease(KeyEvent.VK_DOWN);
|
||||
|
||||
toolkit.realSync();
|
||||
checkSelectionAL(0, 0, 0);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
|
||||
// L
|
||||
robot.keyPress(KeyEvent.VK_L);
|
||||
robot.keyRelease(KeyEvent.VK_L);
|
||||
|
||||
toolkit.realSync();
|
||||
checkSelectionAL(0, 0, 0);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
|
||||
// Click item 4
|
||||
Point p = clickItem4();
|
||||
robot.mouseMove(p.x, p.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
|
||||
toolkit.realSync();
|
||||
checkSelectionAL(4, 4, 4);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
|
||||
|
||||
// Control + Click item 4
|
||||
robot.keyPress(controlKey);
|
||||
p = clickItem4();
|
||||
robot.mouseMove(p.x, p.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.keyRelease(controlKey);
|
||||
|
||||
|
||||
toolkit.realSync();
|
||||
checkSelectionAL(4, 4, 4);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
|
||||
// Shift + Click item 4
|
||||
robot.keyPress(KeyEvent.VK_SHIFT);
|
||||
p = clickItem4();
|
||||
robot.mouseMove(p.x, p.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.keyRelease(KeyEvent.VK_SHIFT);
|
||||
|
||||
|
||||
toolkit.realSync();
|
||||
checkSelectionAL(0, 4, 0, 1, 2, 3, 4);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
|
||||
|
||||
// Control + Shift + Click item 4
|
||||
robot.keyPress(controlKey);
|
||||
robot.keyPress(KeyEvent.VK_SHIFT);
|
||||
p = clickItem4();
|
||||
robot.mouseMove(p.x, p.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.keyRelease(KeyEvent.VK_SHIFT);
|
||||
robot.keyRelease(controlKey);
|
||||
|
||||
toolkit.realSync();
|
||||
checkSelectionAL(0, 4);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
}
|
||||
|
||||
private static DefaultListModel getModel() {
|
||||
DefaultListModel listModel = new DefaultListModel();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
listModel.addElement("List Item " + i);
|
||||
}
|
||||
return listModel;
|
||||
}
|
||||
|
||||
private static Point clickItem4() throws Exception {
|
||||
|
||||
final Point[] result = new Point[1];
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Rectangle r = list.getCellBounds(4, 4);
|
||||
Point p = new Point(r.x + r.width / 2, r.y + r.height / 2);
|
||||
SwingUtilities.convertPointToScreen(p, list);
|
||||
result[0] = p;
|
||||
}
|
||||
});
|
||||
|
||||
return result[0];
|
||||
}
|
||||
|
||||
private static void resetList() throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
list.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
list.getSelectionModel().clearSelection();
|
||||
setAnchorLeadNonThreadSafe();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void scrollDownExtendSelection() throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
list.getActionMap().get("scrollDownExtendSelection").
|
||||
actionPerformed(new ActionEvent(list,
|
||||
ActionEvent.ACTION_PERFORMED, null));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void setSelectionMode(final int selectionMode) throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
list.getSelectionModel().setSelectionMode(selectionMode);
|
||||
setAnchorLeadNonThreadSafe();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void setSelectionInterval(final int index0, final int index1) throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
list.getSelectionModel().setSelectionInterval(index0, index1);
|
||||
setAnchorLeadNonThreadSafe();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void setAnchorLead(final int anchorLeadValue) throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
anchorLead = anchorLeadValue;
|
||||
setAnchorLeadNonThreadSafe();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void setAnchorLeadNonThreadSafe() {
|
||||
list.getSelectionModel().setAnchorSelectionIndex(anchorLead);
|
||||
((DefaultListSelectionModel) list.getSelectionModel()).moveLeadSelectionIndex(anchorLead);
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JFrame frame = new JFrame("bug6462008");
|
||||
frame.setSize(200, 500);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
list = new JList(getModel());
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(list);
|
||||
frame.getContentPane().add(panel);
|
||||
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private static void checkSelection(int... sels) throws Exception {
|
||||
checkSelectionAL(DONT_CARE, DONT_CARE, sels);
|
||||
}
|
||||
|
||||
private static void checkSelectionAL(final int anchor, final int lead, final int... sels) throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkSelectionNonThreadSafe(anchor, lead, sels);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void checkSelectionNonThreadSafe(int anchor, int lead, int... sels) {
|
||||
ListSelectionModel lsm = list.getSelectionModel();
|
||||
|
||||
int actualAnchor = lsm.getAnchorSelectionIndex();
|
||||
int actualLead = lsm.getLeadSelectionIndex();
|
||||
|
||||
if (anchor != DONT_CARE && actualAnchor != anchor) {
|
||||
throw new RuntimeException("anchor is " + actualAnchor + ", should be " + anchor);
|
||||
}
|
||||
|
||||
if (lead != DONT_CARE && actualLead != lead) {
|
||||
throw new RuntimeException("lead is " + actualLead + ", should be " + lead);
|
||||
}
|
||||
|
||||
Arrays.sort(sels);
|
||||
boolean[] checks = new boolean[list.getModel().getSize()];
|
||||
for (int i : sels) {
|
||||
checks[i] = true;
|
||||
}
|
||||
|
||||
int index0 = Math.min(lsm.getMinSelectionIndex(), 0);
|
||||
int index1 = Math.max(lsm.getMaxSelectionIndex(), list.getModel().getSize() - 1);
|
||||
|
||||
for (int i = index0; i <= index1; i++) {
|
||||
if (lsm.isSelectedIndex(i)) {
|
||||
if (i < 0 || i >= list.getModel().getSize() || !checks[i]) {
|
||||
throw new RuntimeException(i + " is selected when it should not be");
|
||||
}
|
||||
} else if (i >= 0 && i < list.getModel().getSize() && checks[i]) {
|
||||
throw new RuntimeException(i + " is supposed to be selected");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
312
jdk/test/javax/swing/JPopupMenu/4966112/bug4966112.java
Normal file
312
jdk/test/javax/swing/JPopupMenu/4966112/bug4966112.java
Normal file
@ -0,0 +1,312 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. 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.
|
||||
*
|
||||
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4966112
|
||||
* @summary Some Composite components does not show the Context Popup.
|
||||
* @library ../../regtesthelpers
|
||||
* @build Util
|
||||
* @author Alexander Zuev
|
||||
* @run main bug4966112
|
||||
*/
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.PopupMenuListener;
|
||||
import javax.swing.event.PopupMenuEvent;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4966112 {
|
||||
|
||||
private static final int NO_MOUSE_BUTTON = -1;
|
||||
private static volatile boolean shown = false;
|
||||
private static volatile int popupButton = NO_MOUSE_BUTTON;
|
||||
private static volatile JButton testButton;
|
||||
private static volatile JSplitPane jsp;
|
||||
private static volatile JSpinner spin;
|
||||
private static volatile JFileChooser filec;
|
||||
private static int buttonMask;
|
||||
private static Robot robot;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
|
||||
createAndShowButton();
|
||||
toolkit.realSync();
|
||||
|
||||
setClickPoint(testButton);
|
||||
clickMouse(InputEvent.BUTTON1_MASK);
|
||||
clickMouse(InputEvent.BUTTON2_MASK);
|
||||
clickMouse(InputEvent.BUTTON3_MASK);
|
||||
|
||||
toolkit.realSync();
|
||||
closeFrame();
|
||||
|
||||
if (popupButton == NO_MOUSE_BUTTON) {
|
||||
System.out.println("Test can't identify the popup trigger button. Test skipped");
|
||||
return;
|
||||
}
|
||||
|
||||
setButtonMask();
|
||||
|
||||
// Test Split Pane
|
||||
createAndShowSplitPane();
|
||||
toolkit.realSync();
|
||||
|
||||
clickMouse(jsp);
|
||||
toolkit.realSync();
|
||||
closeFrame();
|
||||
|
||||
if (!shown) {
|
||||
throw new RuntimeException("Popup was not shown on splitpane");
|
||||
}
|
||||
|
||||
// Test Spinner
|
||||
createAndShowSpinner();
|
||||
toolkit.realSync();
|
||||
|
||||
clickMouse(spin);
|
||||
toolkit.realSync();
|
||||
closeFrame();
|
||||
|
||||
if (!shown) {
|
||||
throw new RuntimeException("Popup was not shown on spinner");
|
||||
}
|
||||
|
||||
// Test File Chooser
|
||||
createAndShowFileChooser();
|
||||
toolkit.realSync();
|
||||
|
||||
clickMouse(filec);
|
||||
toolkit.realSync();
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
|
||||
toolkit.realSync();
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
|
||||
toolkit.realSync();
|
||||
closeFrame();
|
||||
|
||||
if (!shown) {
|
||||
throw new RuntimeException("Popup was not shown on filechooser");
|
||||
}
|
||||
}
|
||||
|
||||
private static void clickMouse(JComponent c) throws Exception {
|
||||
setClickPoint(c);
|
||||
clickMouse(buttonMask);
|
||||
}
|
||||
|
||||
private static void clickMouse(int buttons) {
|
||||
robot.mousePress(buttons);
|
||||
robot.mouseRelease(buttons);
|
||||
}
|
||||
|
||||
private static void setButtonMask() {
|
||||
switch (popupButton) {
|
||||
case MouseEvent.BUTTON1:
|
||||
buttonMask = InputEvent.BUTTON1_MASK;
|
||||
break;
|
||||
case MouseEvent.BUTTON2:
|
||||
buttonMask = InputEvent.BUTTON2_MASK;
|
||||
break;
|
||||
case MouseEvent.BUTTON3:
|
||||
buttonMask = InputEvent.BUTTON3_MASK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void setClickPoint(final JComponent c) throws Exception {
|
||||
final Point[] result = new Point[1];
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Point p = c.getLocationOnScreen();
|
||||
Dimension size = c.getSize();
|
||||
result[0] = new Point(p.x + size.width / 2, p.y + size.height / 2);
|
||||
}
|
||||
});
|
||||
|
||||
robot.mouseMove(result[0].x, result[0].y);
|
||||
}
|
||||
|
||||
private static JPopupMenu createJPopupMenu() {
|
||||
JPopupMenu jpm = new JPopupMenu();
|
||||
jpm.add("One");
|
||||
jpm.add("Two");
|
||||
jpm.add("Three");
|
||||
jpm.addPopupMenuListener(new PopupMenuListener() {
|
||||
|
||||
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
|
||||
shown = true;
|
||||
}
|
||||
|
||||
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
|
||||
}
|
||||
|
||||
public void popupMenuCanceled(PopupMenuEvent e) {
|
||||
}
|
||||
});
|
||||
|
||||
AutoClosable.INSTANCE.setPopup(jpm);
|
||||
return jpm;
|
||||
}
|
||||
|
||||
private static void createAndShowButton() throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
JFrame frame = new JFrame("Button Frame");
|
||||
frame.setLayout(new BorderLayout());
|
||||
testButton = new JButton("Popup Tester");
|
||||
|
||||
testButton.addMouseListener(new MouseAdapter() {
|
||||
|
||||
void setPopupTrigger(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
popupButton = e.getButton();
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
setPopupTrigger(e);
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
setPopupTrigger(e);
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
setPopupTrigger(e);
|
||||
}
|
||||
});
|
||||
|
||||
frame.add(testButton, BorderLayout.CENTER);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
AutoClosable.INSTANCE.setFrame(frame);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void createAndShowSplitPane() throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
JFrame frame = new JFrame("Test SplitPane");
|
||||
frame.setSize(250, 200);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setLayout(new BorderLayout());
|
||||
|
||||
shown = false;
|
||||
jsp = new JSplitPane();
|
||||
jsp.setRightComponent(new JPanel());
|
||||
jsp.setLeftComponent(new JPanel());
|
||||
jsp.setComponentPopupMenu(createJPopupMenu());
|
||||
|
||||
frame.add(jsp, BorderLayout.CENTER);
|
||||
|
||||
jsp.setDividerLocation(150);
|
||||
|
||||
frame.setLocation(400, 300);
|
||||
frame.setVisible(true);
|
||||
AutoClosable.INSTANCE.setFrame(frame);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void createAndShowSpinner() throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
JFrame frame = new JFrame("JSpinner Test");
|
||||
frame.setLayout(new BorderLayout());
|
||||
frame.setSize(200, 100);
|
||||
shown = false;
|
||||
spin = new JSpinner();
|
||||
spin.setComponentPopupMenu(createJPopupMenu());
|
||||
frame.add(spin, BorderLayout.CENTER);
|
||||
frame.setVisible(true);
|
||||
AutoClosable.INSTANCE.setFrame(frame);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void createAndShowFileChooser() throws Exception {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
JFrame frame = new JFrame("FileChooser test dialog");
|
||||
frame.setSize(100, 100);
|
||||
|
||||
shown = false;
|
||||
filec = new JFileChooser();
|
||||
filec.setComponentPopupMenu(createJPopupMenu());
|
||||
filec.showOpenDialog(frame);
|
||||
|
||||
frame.setVisible(true);
|
||||
AutoClosable.INSTANCE.setFrame(frame);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void closeFrame() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
AutoClosable.INSTANCE.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static class AutoClosable {
|
||||
|
||||
static final AutoClosable INSTANCE = new AutoClosable();
|
||||
private JFrame frame;
|
||||
private JPopupMenu popup;
|
||||
|
||||
public void setFrame(JFrame frame) {
|
||||
this.frame = frame;
|
||||
}
|
||||
|
||||
public void setPopup(JPopupMenu popup) {
|
||||
this.popup = popup;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
frame.dispose();
|
||||
if (popup != null) {
|
||||
popup.setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
145
jdk/test/javax/swing/JPopupMenu/6827786/bug6827786.java
Normal file
145
jdk/test/javax/swing/JPopupMenu/6827786/bug6827786.java
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (c) 2007, Oracle and/or its affiliates. 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.
|
||||
*
|
||||
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6827786
|
||||
* @summary Tests duplicate mnemonics
|
||||
* @author Peter Zhelezniakov
|
||||
* @library ../../regtesthelpers
|
||||
* @build Util
|
||||
* @run main bug6827786
|
||||
*/
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import javax.swing.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug6827786 {
|
||||
|
||||
private static JMenu menu;
|
||||
private static Component focusable;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
focusable.requestFocus();
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
checkfocus();
|
||||
|
||||
// select menu
|
||||
Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_F);
|
||||
// select submenu
|
||||
Util.hitKeys(robot, KeyEvent.VK_S);
|
||||
toolkit.realSync();
|
||||
// verify submenu is selected
|
||||
verify(1);
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_S);
|
||||
toolkit.realSync();
|
||||
// verify last item is selected
|
||||
verify(2);
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_S);
|
||||
toolkit.realSync();
|
||||
// selection should wrap to first item
|
||||
verify(0);
|
||||
|
||||
System.out.println("PASSED");
|
||||
|
||||
}
|
||||
|
||||
private static void checkfocus() throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
if (!focusable.isFocusOwner()) {
|
||||
throw new RuntimeException("Button is not the focus owner.");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void verify(final int index) throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
MenuElement[] path =
|
||||
MenuSelectionManager.defaultManager().getSelectedPath();
|
||||
MenuElement item = path[3];
|
||||
if (item != menu.getMenuComponent(index)) {
|
||||
System.err.println("Selected: " + item);
|
||||
System.err.println("Should be: "
|
||||
+ menu.getMenuComponent(index));
|
||||
throw new RuntimeException("Test Failed");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static JMenuBar createMenuBar() {
|
||||
menu = new JMenu("File");
|
||||
menu.setMnemonic('F');
|
||||
|
||||
menu.add(new JMenuItem("Save", 'S'));
|
||||
|
||||
JMenu sub = new JMenu("Submenu");
|
||||
sub.setMnemonic('S');
|
||||
sub.add(new JMenuItem("Sub Item"));
|
||||
menu.add(sub);
|
||||
|
||||
menu.add(new JMenuItem("Special", 'S'));
|
||||
|
||||
JMenuBar bar = new JMenuBar();
|
||||
bar.add(menu);
|
||||
return bar;
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JFrame frame = new JFrame("bug6827786");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setJMenuBar(createMenuBar());
|
||||
focusable = new JButton("Set Focus Here");
|
||||
frame.add(focusable);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
}
|
94
jdk/test/javax/swing/JTabbedPane/7010561/bug7010561.java
Normal file
94
jdk/test/javax/swing/JTabbedPane/7010561/bug7010561.java
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. 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.
|
||||
*
|
||||
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.BasicTabbedPaneUI;
|
||||
import javax.swing.plaf.synth.SynthLookAndFeel;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/* @test
|
||||
@bug 7010561
|
||||
@summary Tab text position with Synth based LaF is different to Java 5/6
|
||||
@author Pavel Porvatov
|
||||
*/
|
||||
public class bug7010561 {
|
||||
private static int[] TAB_PLACEMENT = {
|
||||
SwingConstants.BOTTOM,
|
||||
SwingConstants.BOTTOM,
|
||||
SwingConstants.TOP,
|
||||
SwingConstants.TOP,
|
||||
|
||||
};
|
||||
|
||||
private static boolean[] IS_SELECTED = {
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true
|
||||
};
|
||||
|
||||
private static int[] RETURN_VALUE = {
|
||||
-1,
|
||||
1,
|
||||
1,
|
||||
-1
|
||||
};
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
UIManager.setLookAndFeel(new SynthLookAndFeel());
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
JTabbedPane tabbedPane = new JTabbedPane();
|
||||
|
||||
tabbedPane.addTab("Tab 1", new JLabel("Tab 1"));
|
||||
|
||||
// Ensure internal TabbedPane fields are initialized
|
||||
tabbedPane.doLayout();
|
||||
|
||||
BasicTabbedPaneUI basicTabbedPaneUI = (BasicTabbedPaneUI) tabbedPane.getUI();
|
||||
|
||||
try {
|
||||
Method method = BasicTabbedPaneUI.class.getDeclaredMethod("getTabLabelShiftY", int.class,
|
||||
int.class, boolean.class);
|
||||
|
||||
method.setAccessible(true);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int res = ((Integer) method.invoke(basicTabbedPaneUI, TAB_PLACEMENT[i], 0,
|
||||
IS_SELECTED[i])).intValue();
|
||||
|
||||
if (res != RETURN_VALUE[i]) {
|
||||
throw new RuntimeException("Test bug7010561 failed on index " + i);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
System.out.println("Test bug7010561 passed");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
272
jdk/test/javax/swing/JTree/6263446/bug6263446.java
Normal file
272
jdk/test/javax/swing/JTree/6263446/bug6263446.java
Normal file
@ -0,0 +1,272 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. 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.
|
||||
*
|
||||
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6263446
|
||||
* @summary Tests that double-clicking to edit a cell doesn't select the content.
|
||||
* @author Shannon Hickey
|
||||
* @run main bug6263446
|
||||
*/
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.lang.reflect.Field;
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug6263446 {
|
||||
|
||||
private static final String FIRST = "AAAAAAAAAAA";
|
||||
private static final String SECOND = "BB";
|
||||
private static final String ALL = FIRST + " " + SECOND;
|
||||
private static JTree tree;
|
||||
private static Robot robot;
|
||||
private static SunToolkit toolkit;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
|
||||
Point point = getClickPoint();
|
||||
robot.mouseMove(point.x, point.y);
|
||||
|
||||
// click count 3
|
||||
click(1);
|
||||
assertNotEditing();
|
||||
|
||||
click(2);
|
||||
assertNotEditing();
|
||||
|
||||
click(3);
|
||||
assertEditing();
|
||||
cancelCellEditing();
|
||||
assertNotEditing();
|
||||
|
||||
click(4);
|
||||
checkSelectedText(FIRST);
|
||||
|
||||
click(5);
|
||||
checkSelectedText(ALL);
|
||||
|
||||
// click count 4
|
||||
setClickCountToStart(4);
|
||||
|
||||
click(1);
|
||||
assertNotEditing();
|
||||
|
||||
click(2);
|
||||
assertNotEditing();
|
||||
|
||||
click(3);
|
||||
assertNotEditing();
|
||||
|
||||
click(4);
|
||||
assertEditing();
|
||||
cancelCellEditing();
|
||||
assertNotEditing();
|
||||
|
||||
click(5);
|
||||
checkSelectedText(FIRST);
|
||||
|
||||
click(6);
|
||||
checkSelectedText(ALL);
|
||||
|
||||
// start path editing
|
||||
startPathEditing();
|
||||
assertEditing();
|
||||
|
||||
click(1);
|
||||
checkSelection(null);
|
||||
|
||||
click(2);
|
||||
checkSelection(FIRST);
|
||||
|
||||
click(3);
|
||||
checkSelection(ALL);
|
||||
}
|
||||
|
||||
private static void click(int times) {
|
||||
robot.delay(500);
|
||||
for (int i = 0; i < times; i++) {
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
private static Point getClickPoint() throws Exception {
|
||||
final Point[] result = new Point[1];
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Rectangle rect = tree.getRowBounds(0);
|
||||
// UPDATE !!!
|
||||
Point p = new Point(rect.x + rect.width / 2, rect.y + 2);
|
||||
SwingUtilities.convertPointToScreen(p, tree);
|
||||
result[0] = p;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return result[0];
|
||||
}
|
||||
|
||||
private static TreeModel createTreeModel() {
|
||||
return new DefaultTreeModel(new DefaultMutableTreeNode(ALL));
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
|
||||
JFrame frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
tree = new JTree(createTreeModel());
|
||||
tree.setRootVisible(true);
|
||||
tree.setEditable(true);
|
||||
|
||||
|
||||
frame.getContentPane().add(tree);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private static void setClickCountToStart(final int clicks) throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
DefaultTreeCellEditor editor =
|
||||
(DefaultTreeCellEditor) tree.getCellEditor();
|
||||
Field field = DefaultTreeCellEditor.class.getDeclaredField("realEditor");
|
||||
field.setAccessible(true);
|
||||
DefaultCellEditor ce = (DefaultCellEditor) field.get(editor);
|
||||
ce.setClickCountToStart(clicks);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
|
||||
}
|
||||
|
||||
private static void startPathEditing() throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
tree.startEditingAtPath(tree.getPathForRow(0));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void cancelCellEditing() throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
tree.getCellEditor().cancelCellEditing();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void checkSelection(final String sel) throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
DefaultTreeCellEditor editor =
|
||||
(DefaultTreeCellEditor) tree.getCellEditor();
|
||||
Field field = DefaultTreeCellEditor.class.getDeclaredField("realEditor");
|
||||
field.setAccessible(true);
|
||||
DefaultCellEditor ce = (DefaultCellEditor) field.get(editor);
|
||||
JTextField tf = (JTextField) ce.getComponent();
|
||||
String text = tf.getSelectedText();
|
||||
|
||||
if (sel == null) {
|
||||
if (text != null && text.length() != 0) {
|
||||
throw new RuntimeException("Nothing should be selected, but \"" + text + "\" is selected.");
|
||||
}
|
||||
} else if (!sel.equals(text)) {
|
||||
throw new RuntimeException("\"" + sel + "\" should be selected, but \"" + text + "\" is selected.");
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void checkSelectedText(String sel) throws Exception {
|
||||
assertEditing();
|
||||
checkSelection(sel);
|
||||
cancelCellEditing();
|
||||
assertNotEditing();
|
||||
}
|
||||
|
||||
private static void assertEditing() throws Exception {
|
||||
assertEditingNoTreeLock(true);
|
||||
}
|
||||
|
||||
private static void assertNotEditing() throws Exception {
|
||||
assertEditingNoTreeLock(false);
|
||||
}
|
||||
|
||||
private static void assertEditingNoTreeLock(final boolean editing) throws Exception {
|
||||
toolkit.realSync();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (editing && !tree.isEditing()) {
|
||||
throw new RuntimeException("Tree should be editing");
|
||||
}
|
||||
if (!editing && tree.isEditing()) {
|
||||
throw new RuntimeException("Tree should not be editing");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
106
jdk/test/javax/swing/SwingUtilities/4917669/bug4917669.java
Normal file
106
jdk/test/javax/swing/SwingUtilities/4917669/bug4917669.java
Normal file
@ -0,0 +1,106 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. 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.
|
||||
*
|
||||
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4917669
|
||||
* @summary 1.4 REGRESSION: MenuItem accelerator doesn't work if parent menu is in JDialog
|
||||
* @author Alexander Zuev
|
||||
* @library ../../regtesthelpers
|
||||
* @run main bug4917669
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4917669 {
|
||||
|
||||
private static volatile boolean passed = false;
|
||||
private static JFrame mainFrame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(500);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
createAndShowDialog();
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_O);
|
||||
toolkit.realSync();
|
||||
|
||||
if (!passed) {
|
||||
throw new RuntimeException("Action did not received by menu item.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void createAndShowDialog() {
|
||||
JDialog dialog = new JDialog(mainFrame, "Test Dialog", false);
|
||||
JMenuBar mb = new JMenuBar();
|
||||
JMenu file = new JMenu("File");
|
||||
JMenuItem menuItem = new JMenuItem("Open");
|
||||
menuItem.setAccelerator(KeyStroke.getKeyStroke("control O"));
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
passed = true;
|
||||
}
|
||||
});
|
||||
file.add(menuItem);
|
||||
mb.add(file);
|
||||
dialog.setJMenuBar(mb);
|
||||
|
||||
dialog.setSize(100, 100);
|
||||
dialog.setLocation(200, 200);
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
mainFrame = new JFrame("Bug4917669");
|
||||
mainFrame.setLayout(new BorderLayout());
|
||||
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
mainFrame.setSize(50, 50);
|
||||
mainFrame.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
113
jdk/test/javax/swing/UITest/UITest.java
Normal file
113
jdk/test/javax/swing/UITest/UITest.java
Normal file
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. 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.
|
||||
*
|
||||
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4843282 4886871
|
||||
* @summary Makes sure windows is only listed on Windows platform, and
|
||||
* GTK is not on Windows and Mac.
|
||||
* added as tabs
|
||||
* @author Scott Violet
|
||||
*/
|
||||
import javax.swing.*;
|
||||
import javax.swing.UIManager.LookAndFeelInfo;
|
||||
import sun.awt.OSInfo;
|
||||
import sun.awt.OSInfo.OSType;
|
||||
|
||||
public class UITest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
OSType os = OSInfo.getOSType();
|
||||
LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
|
||||
|
||||
switch (os) {
|
||||
case WINDOWS:
|
||||
|
||||
// Make sure we don't have GTK.
|
||||
if (hasLAF("gtk", lafInfo)) {
|
||||
throw new RuntimeException("On windows, but GTK is present");
|
||||
}
|
||||
|
||||
// Make sure we don't have Aqua.
|
||||
if (hasLAF("mac", lafInfo)) {
|
||||
throw new RuntimeException("On windows, but Aqua is present");
|
||||
}
|
||||
|
||||
// Make sure we have Windows.
|
||||
if (!hasLAF("windows", lafInfo)) {
|
||||
throw new RuntimeException("On windows and don't have Windows");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MACOSX:
|
||||
|
||||
// Make sure we don't have GTK.
|
||||
if (hasLAF("gtk", lafInfo)) {
|
||||
throw new RuntimeException("On mac, but GTK is present");
|
||||
}
|
||||
|
||||
// Make sure we don't have Windows.
|
||||
if (hasLAF("windows", lafInfo)) {
|
||||
throw new RuntimeException("On mac, but Windows is present");
|
||||
}
|
||||
|
||||
// Make sure we have Aqua.
|
||||
if (!hasLAF("mac", lafInfo)) {
|
||||
throw new RuntimeException("On mac and don't have Aqua");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
// Not windows and mac
|
||||
|
||||
// Make sure we don't have Windows.
|
||||
if (hasLAF("windows", lafInfo)) {
|
||||
throw new RuntimeException("Not on windows and have Windows");
|
||||
}
|
||||
|
||||
// Make sure we don't have Aqua.
|
||||
if (hasLAF("mac", lafInfo)) {
|
||||
throw new RuntimeException("Not on mac and have Aqua");
|
||||
}
|
||||
|
||||
// Make sure we have GTK.
|
||||
if (!hasLAF("gtk", lafInfo)) {
|
||||
throw new RuntimeException(
|
||||
"Not on Windows and Mac and don't have GTK!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean hasLAF(String name, LookAndFeelInfo[] lafInfo) {
|
||||
|
||||
for (int counter = 0; counter < lafInfo.length; counter++) {
|
||||
if (lafInfo[counter].getName().toLowerCase().indexOf(name) != -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. 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.
|
||||
*
|
||||
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4251579
|
||||
* @summary Tests if style sheets are working in JLabel
|
||||
* @author Denis Sharypov
|
||||
* @run main bug4251579
|
||||
*/
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4251579 {
|
||||
|
||||
private static JLabel htmlComponent;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
final Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
boolean passed = false;
|
||||
|
||||
Point p = htmlComponent.getLocationOnScreen();
|
||||
Dimension d = htmlComponent.getSize();
|
||||
int x0 = p.x;
|
||||
int y = p.y + d.height / 2;
|
||||
|
||||
for (int x = x0; x < x0 + d.width; x++) {
|
||||
if (robot.getPixelColor(x, y).equals(Color.blue)) {
|
||||
passed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!passed) {
|
||||
throw new RuntimeException("Test failed.");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
|
||||
String htmlText =
|
||||
"<html>"
|
||||
+ "<head><style> .blue{ color:blue; } </style></head>"
|
||||
+ "<body"
|
||||
+ "<P class=\"blue\"> should be rendered with BLUE class definition</P>"
|
||||
+ "</body>";
|
||||
|
||||
JFrame mainFrame = new JFrame("bug4251579");
|
||||
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
htmlComponent = new JLabel(htmlText);
|
||||
mainFrame.getContentPane().add(htmlComponent);
|
||||
|
||||
mainFrame.pack();
|
||||
mainFrame.setVisible(true);
|
||||
}
|
||||
}
|
112
jdk/test/javax/swing/text/html/CSS/4530474/bug4530474.java
Normal file
112
jdk/test/javax/swing/text/html/CSS/4530474/bug4530474.java
Normal file
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. 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.
|
||||
*
|
||||
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4530474
|
||||
* @summary Tests if background-color CSS attribute in HTML font tag in class attribute
|
||||
* @author Denis Sharypov
|
||||
* @run main bug4530474
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4530474 {
|
||||
|
||||
private static final Color TEST_COLOR = Color.BLUE;
|
||||
private static JEditorPane jep;
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
final Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
boolean passed = false;
|
||||
|
||||
Point p = jep.getLocationOnScreen();
|
||||
Dimension d = jep.getSize();
|
||||
int x0 = p.x;
|
||||
int y = p.y + d.height / 3;
|
||||
|
||||
StringBuilder builder = new StringBuilder("Test color: ");
|
||||
builder.append(TEST_COLOR.toString());
|
||||
builder.append(" resut colors: ");
|
||||
|
||||
for (int x = x0; x < x0 + d.width; x++) {
|
||||
Color color = robot.getPixelColor(x, y);
|
||||
builder.append(color);
|
||||
|
||||
if (TEST_COLOR.equals(color)) {
|
||||
passed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!passed) {
|
||||
throw new RuntimeException("Test Fail. " + builder.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
|
||||
JFrame mainFrame = new JFrame("bug4530474");
|
||||
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
jep = new JEditorPane();
|
||||
|
||||
try {
|
||||
File file = new File(System.getProperty("test.src", "."), "test.html");
|
||||
jep.setPage(file.toURL());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
mainFrame.getContentPane().add(jep);
|
||||
|
||||
mainFrame.pack();
|
||||
mainFrame.setVisible(true);
|
||||
}
|
||||
}
|
4
jdk/test/javax/swing/text/html/CSS/4530474/test.css
Normal file
4
jdk/test/javax/swing/text/html/CSS/4530474/test.css
Normal file
@ -0,0 +1,4 @@
|
||||
font.blackwhite {
|
||||
background-color: blue;
|
||||
color: #FFFFFF;
|
||||
}
|
7
jdk/test/javax/swing/text/html/CSS/4530474/test.html
Normal file
7
jdk/test/javax/swing/text/html/CSS/4530474/test.html
Normal file
@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<LINK REL="StyleSheet" type="text/css" HREF=test.css>
|
||||
<body>
|
||||
<font class="blackwhite">www</font>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user