提交 83a5002f 编写于 作者: L lana

Merge

......@@ -93,3 +93,5 @@ e250cef36ea05e627e7e6f7d75e5e19f529e2ba3 jdk7-b114
1657ed4e1d86c8aa2028ab5a41f9da1ac4a369f8 jdk7-b116
3e6726bbf80a4254ecd01051c8ed77ee19325e46 jdk7-b117
b357910aa04aead2a16b6d6ff395a8df4b51d1dd jdk7-b118
ecab7eefb8f2326fd90fb632f47f1b6f81e928f8 jdk7-b119
37d74e29687cf07c2bf9411af58c7e42440855c3 jdk7-b120
......@@ -429,6 +429,7 @@ SUNWprivate_1.1 {
Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetClassValue;
Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetPangoFontName;
Java_sun_awt_X11_GtkFileDialogPeer_initIDs;
Java_sun_awt_X11_GtkFileDialogPeer_run;
Java_sun_awt_X11_GtkFileDialogPeer_quit;
......
......@@ -2154,6 +2154,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
*
* @param d the dimension specifying the new size
* of this component
* @throws NullPointerException if {@code d} is {@code null}
* @see #setSize
* @see #setBounds
* @see #invalidate
......@@ -2351,6 +2352,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* invalidates the component hierarchy.
*
* @param r the new bounding rectangle for this component
* @throws NullPointerException if {@code r} is {@code null}
* @see #getBounds
* @see #setLocation(int, int)
* @see #setLocation(Point)
......@@ -4545,6 +4547,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* where the point's <i>x</i> and <i>y</i> coordinates are defined
* to be relative to the coordinate system of this component.
* @param p the point
* @throws NullPointerException if {@code p} is {@code null}
* @see #getComponentAt(Point)
* @since JDK1.1
*/
......@@ -5879,7 +5882,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @exception ClassCastException if <code>listenerType</code>
* doesn't specify a class or interface that implements
* <code>java.util.EventListener</code>
*
* @throws NullPointerException if {@code listenerType} is {@code null}
* @see #getComponentListeners
* @see #getFocusListeners
* @see #getHierarchyListeners
......@@ -8038,6 +8041,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* Prints a listing of this component to the specified output
* stream.
* @param out a print stream
* @throws NullPointerException if {@code out} is {@code null}
* @since JDK1.0
*/
public void list(PrintStream out) {
......@@ -8050,6 +8054,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @param out a print stream
* @param indent number of spaces to indent
* @see java.io.PrintStream#println(java.lang.Object)
* @throws NullPointerException if {@code out} is {@code null}
* @since JDK1.0
*/
public void list(PrintStream out, int indent) {
......@@ -8062,6 +8067,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
/**
* Prints a listing to the specified print writer.
* @param out the print writer to print to
* @throws NullPointerException if {@code out} is {@code null}
* @since JDK1.1
*/
public void list(PrintWriter out) {
......@@ -8073,6 +8079,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* the specified print writer.
* @param out the print writer to print to
* @param indent the number of spaces to indent
* @throws NullPointerException if {@code out} is {@code null}
* @see java.io.PrintStream#println(java.lang.Object)
* @since JDK1.1
*/
......
......@@ -1231,6 +1231,7 @@ public class Container extends Component {
* reflect the changes.
*
* @param comp the component to be removed
* @throws NullPointerException if {@code comp} is {@code null}
* @see #add
* @see #invalidate
* @see #validate
......@@ -2154,6 +2155,7 @@ public class Container extends Component {
* @exception ClassCastException if <code>listenerType</code>
* doesn't specify a class or interface that implements
* <code>java.util.EventListener</code>
* @exception NullPointerException if {@code listenerType} is {@code null}
*
* @see #getContainerListeners
*
......@@ -2705,6 +2707,7 @@ public class Container extends Component {
* If there is no child component at the requested point and the
* point is within the bounds of the container the container itself
* is returned.
* @throws NullPointerException if {@code p} is {@code null}
* @see Component#contains
* @see #getComponentAt
* @since 1.2
......@@ -2969,6 +2972,7 @@ public class Container extends Component {
*
* @param out a print stream
* @param indent the number of spaces to indent
* @throws NullPointerException if {@code out} is {@code null}
* @see Component#list(java.io.PrintStream, int)
* @since JDK1.0
*/
......@@ -2995,6 +2999,7 @@ public class Container extends Component {
*
* @param out a print writer
* @param indent the number of spaces to indent
* @throws NullPointerException if {@code out} is {@code null}
* @see Component#list(java.io.PrintWriter, int)
* @since JDK1.1
*/
......
......@@ -377,6 +377,7 @@ public class ScrollPane extends Container implements Accessible {
* This is a convenience method which interfaces with the Adjustable
* objects which represent the state of the scrollbars.
* @param p the Point representing the position to scroll to
* @throws NullPointerException if {@code p} is {@code null}
*/
public void setScrollPosition(Point p) {
setScrollPosition(p.x, p.y);
......
......@@ -1888,6 +1888,7 @@ public class Window extends Container implements Accessible {
* @exception ClassCastException if <code>listenerType</code>
* doesn't specify a class or interface that implements
* <code>java.util.EventListener</code>
* @exception NullPointerException if {@code listenerType} is {@code null}
*
* @see #getWindowListeners
* @since 1.3
......
......@@ -653,6 +653,10 @@ public class GroupLayout implements LayoutManager2 {
*/
public ParallelGroup createParallelGroup(Alignment alignment,
boolean resizable){
if (alignment == null) {
throw new IllegalArgumentException("alignment must be non null");
}
if (alignment == Alignment.BASELINE) {
return new BaselineGroup(resizable);
}
......
......@@ -4734,6 +4734,8 @@ public abstract class JComponent extends Container implements Serializable,
* Notifies this component that it now has a parent component.
* When this method is invoked, the chain of parent components is
* set up with <code>KeyboardAction</code> event listeners.
* This method is called by the toolkit internally and should
* not be called directly by programs.
*
* @see #registerKeyboardAction
*/
......@@ -4750,6 +4752,8 @@ public abstract class JComponent extends Container implements Serializable,
* Notifies this component that it no longer has a parent component.
* When this method is invoked, any <code>KeyboardAction</code>s
* set up in the the chain of parent components are removed.
* This method is called by the toolkit internally and should
* not be called directly by programs.
*
* @see #registerKeyboardAction
*/
......
......@@ -156,7 +156,8 @@ public class Popup {
component.setLocation(ownerX, ownerY);
component.getContentPane().add(contents, BorderLayout.CENTER);
contents.invalidate();
component.invalidate();
component.validate();
if(component.isVisible()) {
// Do not call pack() if window is not visible to
// avoid early native peer creation
......
......@@ -113,6 +113,14 @@ public class DefaultHighlighter extends LayeredHighlighter {
* @exception BadLocationException if the specified location is invalid
*/
public Object addHighlight(int p0, int p1, Highlighter.HighlightPainter p) throws BadLocationException {
if (p0 < 0) {
throw new BadLocationException("Invalid start offset", p0);
}
if (p1 < p0) {
throw new BadLocationException("Invalid end offset", p1);
}
Document doc = component.getDocument();
HighlightInfo i = (getDrawsLayeredHighlights() &&
(p instanceof LayeredHighlighter.LayerPainter)) ?
......@@ -217,6 +225,14 @@ public class DefaultHighlighter extends LayeredHighlighter {
* @exception BadLocationException if the specified location is invalid
*/
public void changeHighlight(Object tag, int p0, int p1) throws BadLocationException {
if (p0 < 0) {
throw new BadLocationException("Invalid beginning of the range", p0);
}
if (p1 < p0) {
throw new BadLocationException("Invalid end of the range", p1);
}
Document doc = component.getDocument();
if (tag instanceof LayeredHighlightInfo) {
LayeredHighlightInfo lhi = (LayeredHighlightInfo)tag;
......
......@@ -40,8 +40,10 @@ import java.awt.Component;
* <p>To listen for this event, install AWTEventListener with {@value sun.awt.SunToolkit#GRAB_EVENT_MASK}
*/
public class UngrabEvent extends AWTEvent {
private final static int UNGRAB_EVENT_ID = 1998;
public UngrabEvent(Component source) {
super(source, 0xffff);
super(source, UNGRAB_EVENT_ID);
}
public String toString() {
......
......@@ -42,11 +42,19 @@ class GtkFileDialogPeer extends XDialogPeer implements FileDialogPeer {
private FileDialog fd;
// A pointer to the native GTK FileChooser widget
private volatile long widget = 0L;
public GtkFileDialogPeer(FileDialog fd) {
super((Dialog) fd);
this.fd = fd;
}
private static native void initIDs();
static {
initIDs();
}
private native void run(String title, int mode, String dir, String file,
FilenameFilter filter, boolean isMultipleMode);
......
......@@ -2773,11 +2773,6 @@ Java_sun_awt_motif_MToolkit_init(JNIEnv *env, jobject this,
}
}
/*
scrollBugWorkAround =
(strcmp(XServerVendor(awt_display), "Sun Microsystems, Inc.") == 0
&& XVendorRelease(awt_display) == 3400);
*/
scrollBugWorkAround = TRUE;
/*
......
......@@ -557,7 +557,8 @@ JNIEXPORT jstring JNICALL Java_sun_awt_X11FontManager_getFontPath
#ifndef HEADLESS
static int isSunXServer() {
#ifdef __solaris__
return (strcmp("Sun Microsystems, Inc.", ServerVendor(awt_display)) == 0 &&
return ((strncmp(ServerVendor(awt_display), "Sun Microsystems, Inc.", 22) == 0) ||
(strncmp(ServerVendor(awt_display), "Oracle Corporation", 18) == 0) &&
VendorRelease(awt_display) >= 6410);
#else
return 0;
......
......@@ -4,13 +4,29 @@
#include <string.h>
#include "gtk2_interface.h"
#include "sun_awt_X11_GtkFileDialogPeer.h"
#include "debug_assert.h"
static JavaVM *jvm;
static GtkWidget *dialog = NULL;
/* To cache some method IDs */
static jmethodID filenameFilterCallbackMethodID = NULL;
static jmethodID setFileInternalMethodID = NULL;
static jfieldID widgetFieldID = NULL;
JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_initIDs
(JNIEnv *env, jclass cx)
{
filenameFilterCallbackMethodID = (*env)->GetMethodID(env, cx,
"filenameFilterCallback", "(Ljava/lang/String;)Z");
DASSERT(filenameFilterCallbackMethodID != NULL);
setFileInternalMethodID = (*env)->GetMethodID(env, cx,
"setFileInternal", "(Ljava/lang/String;[Ljava/lang/String;)V");
DASSERT(setFileInternalMethodID != NULL);
widgetFieldID = (*env)->GetFieldID(env, cx, "widget", "J");
DASSERT(widgetFieldID != NULL);
}
static gboolean filenameFilterCallback(const GtkFileFilterInfo * filter_info, gpointer obj)
{
......@@ -20,30 +36,17 @@ static gboolean filenameFilterCallback(const GtkFileFilterInfo * filter_info, gp
env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
if (filenameFilterCallbackMethodID == NULL) {
cx = (*env)->GetObjectClass(env, (jobject) obj);
if (cx == NULL) {
JNU_ThrowInternalError(env, "Could not get file filter class");
return 0;
}
filenameFilterCallbackMethodID = (*env)->GetMethodID(env, cx,
"filenameFilterCallback", "(Ljava/lang/String;)Z");
if (filenameFilterCallbackMethodID == NULL) {
JNU_ThrowInternalError(env,
"Could not get filenameFilterCallback method id");
return 0;
}
}
filename = (*env)->NewStringUTF(env, filter_info->filename);
return (*env)->CallBooleanMethod(env, obj, filenameFilterCallbackMethodID,
filename);
}
static void quit(gboolean isSignalHandler)
static void quit(JNIEnv * env, jobject jpeer, gboolean isSignalHandler)
{
GtkWidget * dialog = (GtkWidget*)jlong_to_ptr(
(*env)->GetLongField(env, jpeer, widgetFieldID));
if (dialog != NULL)
{
// Callbacks from GTK signals are made within the GTK lock
......@@ -57,7 +60,8 @@ static void quit(gboolean isSignalHandler)
fp_gtk_widget_destroy (dialog);
fp_gtk_main_quit ();
dialog = NULL;
(*env)->SetLongField(env, jpeer, widgetFieldID, 0);
if (!isSignalHandler) {
fp_gdk_threads_leave();
......@@ -73,7 +77,7 @@ static void quit(gboolean isSignalHandler)
JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_quit
(JNIEnv * env, jobject jpeer)
{
quit(FALSE);
quit(env, jpeer, FALSE);
}
/**
......@@ -132,24 +136,8 @@ static void handle_response(GtkWidget* aDialog, gint responseId, gpointer obj)
if (responseId == GTK_RESPONSE_ACCEPT) {
current_folder = fp_gtk_file_chooser_get_current_folder(
GTK_FILE_CHOOSER(dialog));
filenames = fp_gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
}
if (setFileInternalMethodID == NULL) {
cx = (*env)->GetObjectClass(env, (jobject) obj);
if (cx == NULL) {
JNU_ThrowInternalError(env, "Could not get GTK peer class");
return;
}
setFileInternalMethodID = (*env)->GetMethodID(env, cx,
"setFileInternal", "(Ljava/lang/String;[Ljava/lang/String;)V");
if (setFileInternalMethodID == NULL) {
JNU_ThrowInternalError(env,
"Could not get setFileInternalMethodID method id");
return;
}
GTK_FILE_CHOOSER(aDialog));
filenames = fp_gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(aDialog));
}
jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
......@@ -159,7 +147,7 @@ static void handle_response(GtkWidget* aDialog, gint responseId, gpointer obj)
jfilenames);
fp_g_free(current_folder);
quit(TRUE);
quit(env, (jobject)obj, TRUE);
}
/*
......@@ -172,6 +160,7 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer,
jstring jtitle, jint mode, jstring jdir, jstring jfile,
jobject jfilter, jboolean multiple)
{
GtkWidget *dialog = NULL;
GtkFileFilter *filter;
if (jvm == NULL) {
......@@ -233,8 +222,12 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer,
fp_g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(
handle_response), jpeer);
(*env)->SetLongField(env, jpeer, widgetFieldID, ptr_to_jlong(dialog));
fp_gtk_widget_show(dialog);
fp_gtk_main();
fp_gdk_threads_leave();
}
......@@ -9,6 +9,14 @@ extern "C"
{
#endif
/*
* Class: sun_awt_X11_GtkFileDialogPeer
* Method: initIDs
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_initIDs
(JNIEnv *, jclass);
/*
* Class: sun_awt_X11_GtkFileDialogPeer
* Method: run
......
......@@ -766,7 +766,9 @@ adjustKeySym(XEvent *event, KeySym *keysym)
static Boolean
isXsunServer(XEvent *event) {
if( awt_ServerDetected ) return awt_IsXsun;
if( strncmp( ServerVendor( event->xkey.display ), "Sun Microsystems, Inc.", 32) ) {
if( (strncmp( ServerVendor( event->xkey.display ), "Sun Microsystems, Inc.", 22) != 0) &&
(strncmp( ServerVendor( event->xkey.display ), "Oracle Corporation", 18) != 0) )
{
awt_ServerDetected = True;
awt_IsXsun = False;
return False;
......
......@@ -6084,63 +6084,67 @@ void AwtComponent::SetParent(void * param) {
void AwtComponent::_SetRectangularShape(void *param)
{
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
if (!AwtToolkit::IsMainThread()) {
AwtToolkit::GetInstance().InvokeFunction(AwtComponent::_SetRectangularShape, param);
} else {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
SetRectangularShapeStruct *data = (SetRectangularShapeStruct *)param;
jobject self = data->component;
jint x1 = data->x1;
jint x2 = data->x2;
jint y1 = data->y1;
jint y2 = data->y2;
jobject region = data->region;
SetRectangularShapeStruct *data = (SetRectangularShapeStruct *)param;
jobject self = data->component;
jint x1 = data->x1;
jint x2 = data->x2;
jint y1 = data->y1;
jint y2 = data->y2;
jobject region = data->region;
AwtComponent *c = NULL;
AwtComponent *c = NULL;
PDATA pData;
JNI_CHECK_PEER_GOTO(self, ret);
PDATA pData;
JNI_CHECK_PEER_GOTO(self, ret);
c = (AwtComponent *)pData;
if (::IsWindow(c->GetHWnd())) {
HRGN hRgn = NULL;
if (region || x1 || x2 || y1 || y2) {
// If all the params are zeros, the shape must be simply reset.
// Otherwise, convert it into a region.
RGNDATA *pRgnData = NULL;
RGNDATAHEADER *pRgnHdr;
/* reserving memory for the worst case */
size_t worstBufferSize = size_t(((x2 - x1) / 2 + 1) * (y2 - y1));
pRgnData = (RGNDATA *) safe_Malloc(sizeof(RGNDATAHEADER) +
sizeof(RECT_T) * worstBufferSize);
pRgnHdr = (RGNDATAHEADER *) pRgnData;
pRgnHdr->dwSize = sizeof(RGNDATAHEADER);
pRgnHdr->iType = RDH_RECTANGLES;
pRgnHdr->nRgnSize = 0;
pRgnHdr->rcBound.top = 0;
pRgnHdr->rcBound.left = 0;
pRgnHdr->rcBound.bottom = LONG(y2 - y1);
pRgnHdr->rcBound.right = LONG(x2 - x1);
RECT_T * pRect = (RECT_T *) (((BYTE *) pRgnData) + sizeof(RGNDATAHEADER));
pRgnHdr->nCount = RegionToYXBandedRectangles(env, x1, y1, x2, y2, region, &pRect, worstBufferSize);
hRgn = ::ExtCreateRegion(NULL,
sizeof(RGNDATAHEADER) + sizeof(RECT_T) * pRgnHdr->nCount, pRgnData);
free(pRgnData);
}
c = (AwtComponent *)pData;
if (::IsWindow(c->GetHWnd())) {
HRGN hRgn = NULL;
if (region || x1 || x2 || y1 || y2) {
// If all the params are zeros, the shape must be simply reset.
// Otherwise, convert it into a region.
RGNDATA *pRgnData = NULL;
RGNDATAHEADER *pRgnHdr;
/* reserving memory for the worst case */
size_t worstBufferSize = size_t(((x2 - x1) / 2 + 1) * (y2 - y1));
pRgnData = (RGNDATA *) safe_Malloc(sizeof(RGNDATAHEADER) +
sizeof(RECT_T) * worstBufferSize);
pRgnHdr = (RGNDATAHEADER *) pRgnData;
pRgnHdr->dwSize = sizeof(RGNDATAHEADER);
pRgnHdr->iType = RDH_RECTANGLES;
pRgnHdr->nRgnSize = 0;
pRgnHdr->rcBound.top = 0;
pRgnHdr->rcBound.left = 0;
pRgnHdr->rcBound.bottom = LONG(y2 - y1);
pRgnHdr->rcBound.right = LONG(x2 - x1);
RECT_T * pRect = (RECT_T *) (((BYTE *) pRgnData) + sizeof(RGNDATAHEADER));
pRgnHdr->nCount = RegionToYXBandedRectangles(env, x1, y1, x2, y2, region, &pRect, worstBufferSize);
hRgn = ::ExtCreateRegion(NULL,
sizeof(RGNDATAHEADER) + sizeof(RECT_T) * pRgnHdr->nCount, pRgnData);
free(pRgnData);
}
::SetWindowRgn(c->GetHWnd(), hRgn, TRUE);
}
::SetWindowRgn(c->GetHWnd(), hRgn, TRUE);
}
ret:
env->DeleteGlobalRef(self);
if (region) {
env->DeleteGlobalRef(region);
}
env->DeleteGlobalRef(self);
if (region) {
env->DeleteGlobalRef(region);
}
delete data;
delete data;
}
}
void AwtComponent::_SetZOrder(void *param) {
......
......@@ -194,9 +194,9 @@ inline jint AwtRobot::WinToJavaPixel(USHORT r, USHORT g, USHORT b)
jint AwtRobot::GetRGBPixel( jint x, jint y)
{
HDC hdc = GetDC(NULL);
HDC hdc = ::CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
COLORREF ref = ::GetPixel( hdc, x, y );
ReleaseDC(NULL,hdc);
::DeleteDC(hdc);
jint value = WinToJavaPixel(GetRValue(ref), GetGValue(ref), GetBValue(ref));
return value;
}
......
/*
* Copyright (c) 2010, 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 6988428
@summary Tests whether shape is always set
@author anthony.petrov@oracle.com: area=awt.toplevel
@run main ShapeNotSetSometimes
*/
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.geom.*;
public class ShapeNotSetSometimes {
private Frame backgroundFrame;
private Frame window;
private static final Color BACKGROUND_COLOR = Color.BLUE;
private Shape shape;
private int[][] pointsToCheck;
private static Robot robot;
public ShapeNotSetSometimes() throws Exception {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
initializeGUI();
}
});
}
private void initializeGUI() {
backgroundFrame = new BackgroundFrame();
backgroundFrame.setUndecorated(true);
backgroundFrame.setSize(300, 300);
backgroundFrame.setLocation(20, 400);
backgroundFrame.setVisible(true);
shape = null;
String shape_name = null;
Area a;
GeneralPath gp;
shape_name = "Rounded-corners";
a = new Area();
a.add(new Area(new Rectangle2D.Float(50, 0, 100, 150)));
a.add(new Area(new Rectangle2D.Float(0, 50, 200, 50)));
a.add(new Area(new Ellipse2D.Float(0, 0, 100, 100)));
a.add(new Area(new Ellipse2D.Float(0, 50, 100, 100)));
a.add(new Area(new Ellipse2D.Float(100, 0, 100, 100)));
a.add(new Area(new Ellipse2D.Float(100, 50, 100, 100)));
shape = a;
pointsToCheck = new int[][] {
// inside shape
{106, 86}, {96, 38}, {76, 107}, {180, 25}, {24, 105},
{196, 77}, {165, 50}, {14, 113}, {89, 132}, {167, 117},
// outside shape
{165, 196}, {191, 163}, {146, 185}, {61, 170}, {148, 171},
{82, 172}, {186, 11}, {199, 141}, {13, 173}, {187, 3}
};
window = new TestFrame();
window.setUndecorated(true);
window.setSize(200, 200);
window.setLocation(70, 450);
window.setShape(shape);
window.setVisible(true);
System.out.println("Checking " + window.getClass().getSuperclass().getName() + " with " + shape_name + " shape (" + window.getShape() + ")...");
}
class BackgroundFrame extends Frame {
@Override
public void paint(Graphics g) {
g.setColor(BACKGROUND_COLOR);
g.fillRect(0, 0, 300, 300);
super.paint(g);
}
}
class TestFrame extends Frame {
@Override
public void paint(Graphics g) {
g.setColor(Color.WHITE);
g.fillRect(0, 0, 200, 200);
super.paint(g);
}
}
public static void main(String[] args) throws Exception {
robot = new Robot();
for(int i = 0; i < 100; i++) {
System.out.println("Attempt " + i);
new ShapeNotSetSometimes().doTest();
}
}
private void doTest() throws Exception {
Point wls = backgroundFrame.getLocationOnScreen();
robot.mouseMove(wls.x + 5, wls.y + 5);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(10);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(500);
EventQueue.invokeAndWait(new Runnable() {
public void run() {
window.requestFocus();
}
});
robot.waitForIdle();
try {
Thread.sleep(300);
} catch (InterruptedException e) {
// ignore this one
}
// check transparency
final int COUNT_TARGET = 10;
// checking outside points only
for(int i = COUNT_TARGET; i < COUNT_TARGET * 2; i++) {
int x = pointsToCheck[i][0];
int y = pointsToCheck[i][1];
boolean inside = i < COUNT_TARGET;
Color c = robot.getPixelColor(window.getX() + x, window.getY() + y);
System.out.println("checking " + x + ", " + y + ", color = " + c);
if (inside && BACKGROUND_COLOR.equals(c) || !inside && !BACKGROUND_COLOR.equals(c)) {
System.out.println("window.getX() = " + window.getX() + ", window.getY() = " + window.getY());
System.err.println("Checking for transparency failed: point: " +
(window.getX() + x) + ", " + (window.getY() + y) +
", color = " + c + (inside ? " is of un" : " is not of ") +
"expected background color " + BACKGROUND_COLOR);
throw new RuntimeException("Test failed. The shape has not been applied.");
}
}
EventQueue.invokeAndWait(new Runnable() {
public void run() {
backgroundFrame.dispose();
window.dispose();
}
});
}
}
/*
* Copyright (c) 2010, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle 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 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 6960516
@summary check if the ungrab event has the ID < AWTEvent.RESERVED_ID_MAX
@author Andrei Dmitriev : area=awt.event
@run main UngrabID
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class UngrabID {
public static void main(String[] args){
Frame f = new Frame("Dummy");
sun.awt.UngrabEvent event = new sun.awt.UngrabEvent(f);
if (event.getID() > AWTEvent.RESERVED_ID_MAX) {
System.out.println( " Event ID : "+event.getID() + " " + event.toString());
throw new RuntimeException(" Ungrab Event ID should be less than AWTEvent.RESERVED_ID_MAX ("+AWTEvent.RESERVED_ID_MAX+"). Actual value : "+event.getID() + " Event:" + event.toString());
}
System.out.println("Test passed. ");
}
}
/*
* Copyright (c) 2010, 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 6613904
* @summary javax.swing.GroupLayout.createParallelGroup(..) doesn't throw IllegalArgumentException for null arg
* @author Pavel Porvatov
*/
import javax.swing.*;
public class bug6613904 {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
GroupLayout groupLayout = new GroupLayout(new JPanel());
try {
groupLayout.createParallelGroup(null);
throw new RuntimeException("groupLayout.createParallelGroup(null) doesn't throw IAE");
} catch (IllegalArgumentException e) {
// Ok
}
try {
groupLayout.createParallelGroup(null, true);
throw new RuntimeException("groupLayout.createParallelGroup(null, true) doesn't throw IAE");
} catch (IllegalArgumentException e) {
// Ok
}
try {
groupLayout.createParallelGroup(null, false);
throw new RuntimeException("groupLayout.createParallelGroup(null, false) doesn't throw IAE");
} catch (IllegalArgumentException e) {
// Ok
}
}
});
}
}
/*
* Copyright (c) 2010, 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 6987844
* @summary Incorrect width of JComboBox drop down
* @author Alexander Potochkin
* @run main bug6987844
*/
import sun.awt.SunToolkit;
import javax.swing.*;
import java.awt.*;
import java.awt.event.InputEvent;
public class bug6987844 {
static JMenu menu1;
static JMenu menu2;
public static void main(String... args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(200);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar bar = new JMenuBar();
menu1 = new JMenu("Menu1");
menu1.add(new JMenuItem("item"));
bar.add(menu1);
menu2 = new JMenu("Menu2");
menu2.add(new JMenuItem("item"));
menu2.add(new JMenuItem("item"));
bar.add(menu2);
frame.setJMenuBar(bar);
frame.pack();
frame.setVisible(true);
}
});
toolkit.realSync();
Point point1 = menu1.getLocationOnScreen();
Point point2 = menu2.getLocationOnScreen();
robot.mouseMove(point1.x + 1, point1.y + 1);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mouseMove(point2.x + 1, point2.y + 1);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mouseMove(point1.x + 1, point1.y + 1);
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
Dimension popupSize1 = menu1.getPopupMenu().getSize();
Dimension popupSize2 = menu2.getPopupMenu().getSize();
if (popupSize1.equals(popupSize2)) {
throw new RuntimeException("First popup unexpedetly changed its size");
}
}
});
}
}
/*
* Copyright (c) 2010, 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 6771184
* @summary Some methods in text package don't throw BadLocationException when expected
* @author Pavel Porvatov
*/
import javax.swing.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.Highlighter;
import javax.swing.text.JTextComponent;
import java.awt.*;
public class bug6771184 {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JTextArea textArea = new JTextArea("Tested string");
Highlighter highlighter = textArea.getHighlighter();
Highlighter.HighlightPainter myPainter = new Highlighter.HighlightPainter() {
public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c) {
}
};
int negativeTestedData[][] = {{50, 0},
{-1, 1},
{-5, -4},
{Integer.MAX_VALUE, Integer.MIN_VALUE},
{Integer.MIN_VALUE, Integer.MAX_VALUE},
{Integer.MIN_VALUE, Integer.MIN_VALUE}};
for (int[] data : negativeTestedData) {
try {
highlighter.addHighlight(data[0], data[1], myPainter);
throw new RuntimeException("Method addHighlight() does not throw BadLocationException for (" +
data[0] + ", " + data[1] + ") ");
} catch (BadLocationException e) {
// Ok
}
Object objRef;
try {
objRef = highlighter.addHighlight(0, 1, myPainter);
} catch (BadLocationException e) {
throw new RuntimeException("highlighter.addHighlight(0, 1, myPainter) throws exception", e);
}
try {
highlighter.changeHighlight(objRef, data[0], data[1]);
throw new RuntimeException("Method changeHighlight() does not throw BadLocationException for (" +
data[0] + ", " + data[1] + ") ");
} catch (BadLocationException e) {
// Ok
}
}
}
});
}
}
......@@ -84,6 +84,9 @@ public class InsetClipping extends Frame {
Thread.sleep(100);
} catch (Exception e) {}
}
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {}
try {
Robot robot = new Robot();
Point clientLoc = clipTest.getLocationOnScreen();
......
......@@ -56,6 +56,9 @@ public class DrawImageBilinear extends Canvas {
private VolatileImage vimg;
private static volatile BufferedImage capture;
private static void doCapture(Component test) {
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {}
// Grab the screen region
try {
Robot robot = new Robot();
......
......@@ -204,6 +204,9 @@ public class SourceClippingBlitTest extends Canvas {
int w = getWidth();
int h = getHeight();
Toolkit.getDefaultToolkit().sync();
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {}
Point p = getLocationOnScreen();
grabbedBI = robot.createScreenCapture(new Rectangle(p.x, p.y, w, h));
......
......@@ -120,6 +120,9 @@ public class SharedMemoryPixmapsTest {
}
private boolean testRendering() throws RuntimeException {
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {}
Robot r = null;
try {
r = new Robot();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册