Merge
This commit is contained in:
commit
33c12b1f1a
@ -598,29 +598,21 @@ public class LWWindowPeer
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the delegate when any part of the window should be repainted.
|
||||
* Called by the {@code PlatformWindow} when any part of the window should
|
||||
* be repainted.
|
||||
*/
|
||||
public void notifyExpose(final int x, final int y, final int w, final int h) {
|
||||
// TODO: there's a serious problem with Swing here: it handles
|
||||
// the exposition internally, so SwingPaintEventDispatcher always
|
||||
// return null from createPaintEvent(). However, we flush the
|
||||
// back buffer here unconditionally, so some flickering may appear.
|
||||
// A possible solution is to split postPaintEvent() into two parts,
|
||||
// and override that part which is only called after if
|
||||
// createPaintEvent() returned non-null value and flush the buffer
|
||||
// from the overridden method
|
||||
flushOnscreenGraphics();
|
||||
repaintPeer(new Rectangle(x, y, w, h));
|
||||
public final void notifyExpose(final Rectangle r) {
|
||||
repaintPeer(r);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the delegate when this window is moved/resized by user.
|
||||
* There's no notifyReshape() in LWComponentPeer as the only
|
||||
* Called by the {@code PlatformWindow} when this window is moved/resized by
|
||||
* user. There's no notifyReshape() in LWComponentPeer as the only
|
||||
* components which could be resized by user are top-level windows.
|
||||
*/
|
||||
public final void notifyReshape(int x, int y, int w, int h) {
|
||||
boolean moved = false;
|
||||
boolean resized = false;
|
||||
final boolean moved;
|
||||
final boolean resized;
|
||||
synchronized (getStateLock()) {
|
||||
moved = (x != sysX) || (y != sysY);
|
||||
resized = (w != sysW) || (h != sysH);
|
||||
@ -644,12 +636,13 @@ public class LWWindowPeer
|
||||
flushOnscreenGraphics();
|
||||
}
|
||||
|
||||
// Third, COMPONENT_MOVED/COMPONENT_RESIZED events
|
||||
// Third, COMPONENT_MOVED/COMPONENT_RESIZED/PAINT events
|
||||
if (moved) {
|
||||
handleMove(x, y, true);
|
||||
}
|
||||
if (resized) {
|
||||
handleResize(w, h,true);
|
||||
handleResize(w, h, true);
|
||||
repaintPeer();
|
||||
}
|
||||
}
|
||||
|
||||
@ -682,8 +675,9 @@ public class LWWindowPeer
|
||||
getLWToolkit().getCursorManager().updateCursorLater(this);
|
||||
}
|
||||
|
||||
public void notifyActivation(boolean activation) {
|
||||
changeFocusedWindow(activation);
|
||||
public void notifyActivation(boolean activation, LWWindowPeer opposite) {
|
||||
Window oppositeWindow = (opposite == null)? null : opposite.getTarget();
|
||||
changeFocusedWindow(activation, oppositeWindow);
|
||||
}
|
||||
|
||||
// MouseDown in non-client area
|
||||
@ -1158,6 +1152,9 @@ public class LWWindowPeer
|
||||
Window currentActive = KeyboardFocusManager.
|
||||
getCurrentKeyboardFocusManager().getActiveWindow();
|
||||
|
||||
Window opposite = LWKeyboardFocusManagerPeer.getInstance().
|
||||
getCurrentFocusedWindow();
|
||||
|
||||
// Make the owner active window.
|
||||
if (isSimpleWindow()) {
|
||||
LWWindowPeer owner = getOwnerFrameDialog(this);
|
||||
@ -1184,16 +1181,17 @@ public class LWWindowPeer
|
||||
}
|
||||
|
||||
// DKFM will synthesize all the focus/activation events correctly.
|
||||
changeFocusedWindow(true);
|
||||
changeFocusedWindow(true, opposite);
|
||||
return true;
|
||||
|
||||
// In case the toplevel is active but not focused, change focus directly,
|
||||
// as requesting native focus on it will not have effect.
|
||||
} else if (getTarget() == currentActive && !getTarget().hasFocus()) {
|
||||
|
||||
changeFocusedWindow(true);
|
||||
changeFocusedWindow(true, opposite);
|
||||
return true;
|
||||
}
|
||||
|
||||
return platformWindow.requestWindowFocus();
|
||||
}
|
||||
|
||||
@ -1223,7 +1221,7 @@ public class LWWindowPeer
|
||||
/*
|
||||
* Changes focused window on java level.
|
||||
*/
|
||||
private void changeFocusedWindow(boolean becomesFocused) {
|
||||
private void changeFocusedWindow(boolean becomesFocused, Window opposite) {
|
||||
if (focusLog.isLoggable(PlatformLogger.FINE)) {
|
||||
focusLog.fine((becomesFocused?"gaining":"loosing") + " focus window: " + this);
|
||||
}
|
||||
@ -1247,9 +1245,6 @@ public class LWWindowPeer
|
||||
}
|
||||
}
|
||||
|
||||
KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
|
||||
Window oppositeWindow = becomesFocused ? kfmPeer.getCurrentFocusedWindow() : null;
|
||||
|
||||
// Note, the method is not called:
|
||||
// - when the opposite (gaining focus) window is an owned/owner window.
|
||||
// - for a simple window in any case.
|
||||
@ -1261,10 +1256,11 @@ public class LWWindowPeer
|
||||
grabbingWindow.ungrab();
|
||||
}
|
||||
|
||||
KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
|
||||
kfmPeer.setCurrentFocusedWindow(becomesFocused ? getTarget() : null);
|
||||
|
||||
int eventID = becomesFocused ? WindowEvent.WINDOW_GAINED_FOCUS : WindowEvent.WINDOW_LOST_FOCUS;
|
||||
WindowEvent windowEvent = new TimedWindowEvent(getTarget(), eventID, oppositeWindow, System.currentTimeMillis());
|
||||
WindowEvent windowEvent = new TimedWindowEvent(getTarget(), eventID, opposite, System.currentTimeMillis());
|
||||
|
||||
// TODO: wrap in SequencedEvent
|
||||
postEvent(windowEvent);
|
||||
|
@ -113,14 +113,14 @@ public class CEmbeddedFrame extends EmbeddedFrame {
|
||||
public void handleFocusEvent(boolean focused) {
|
||||
this.focused = focused;
|
||||
if (parentWindowActive) {
|
||||
responder.handleWindowFocusEvent(focused);
|
||||
responder.handleWindowFocusEvent(focused, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleWindowFocusEvent(boolean parentWindowActive) {
|
||||
this.parentWindowActive = parentWindowActive;
|
||||
if (focused) {
|
||||
responder.handleWindowFocusEvent(parentWindowActive);
|
||||
responder.handleWindowFocusEvent(parentWindowActive, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ final class CPlatformResponder {
|
||||
}
|
||||
}
|
||||
|
||||
void handleWindowFocusEvent(boolean gained) {
|
||||
peer.notifyActivation(gained);
|
||||
void handleWindowFocusEvent(boolean gained, LWWindowPeer opposite) {
|
||||
peer.notifyActivation(gained, opposite);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.lwawt.macosx;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.VolatileImage;
|
||||
|
||||
import sun.awt.CGraphicsConfig;
|
||||
@ -202,12 +201,11 @@ public class CPlatformView extends CFRetainedResource {
|
||||
event.getCharactersIgnoringModifiers(), event.getKeyCode(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the native delegate in layer backed view mode or in the simple
|
||||
* NSView mode. See NSView.drawRect().
|
||||
*/
|
||||
private void deliverWindowDidExposeEvent() {
|
||||
Rectangle r = peer.getBounds();
|
||||
peer.notifyExpose(0, 0, r.width, r.height);
|
||||
}
|
||||
|
||||
private void deliverWindowDidExposeEvent(float x, float y, float w, float h) {
|
||||
peer.notifyExpose((int)x, (int)y, (int)w, (int)h);
|
||||
peer.notifyExpose(peer.getSize());
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ import com.apple.laf.*;
|
||||
import com.apple.laf.ClientPropertyApplicator.Property;
|
||||
import com.sun.awt.AWTUtilities;
|
||||
|
||||
public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
|
||||
public final class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
|
||||
private native long nativeCreateNSWindow(long nsViewPtr, long styleBits, double x, double y, double w, double h);
|
||||
private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
|
||||
private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
|
||||
@ -199,7 +199,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
// In order to keep it up-to-date we will update them on
|
||||
// 1) setting native bounds via nativeSetBounds() call
|
||||
// 2) getting notification from the native level via deliverMoveResizeEvent()
|
||||
private Rectangle nativeBounds;
|
||||
private Rectangle nativeBounds = new Rectangle(0, 0, 0, 0);
|
||||
private volatile boolean isFullScreenMode = false;
|
||||
|
||||
private Window target;
|
||||
@ -869,16 +869,24 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
}
|
||||
}
|
||||
|
||||
private void flushBuffers() {
|
||||
if (isVisible() && !nativeBounds.isEmpty()) {
|
||||
LWCToolkit.getLWCToolkit().flushPendingEventsOnAppkit(target);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* Callbacks from the AWTWindow and AWTView objc classes.
|
||||
*************************************************************/
|
||||
private void deliverWindowFocusEvent(boolean gained){
|
||||
private void deliverWindowFocusEvent(boolean gained, CPlatformWindow opposite){
|
||||
// Fix for 7150349: ingore "gained" notifications when the app is inactive.
|
||||
if (gained && !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive()) {
|
||||
focusLogger.fine("the app is inactive, so the notification is ignored");
|
||||
return;
|
||||
}
|
||||
responder.handleWindowFocusEvent(gained);
|
||||
|
||||
LWWindowPeer oppositePeer = (opposite == null)? null : opposite.getPeer();
|
||||
responder.handleWindowFocusEvent(gained, oppositePeer);
|
||||
}
|
||||
|
||||
private void deliverMoveResizeEvent(int x, int y, int width, int height) {
|
||||
@ -886,10 +894,16 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
// move/resize notifications contain a bounds smaller than
|
||||
// the whole screen and therefore we ignore the native notifications
|
||||
// and the content view itself creates correct synthetic notifications
|
||||
if (isFullScreenMode) return;
|
||||
if (isFullScreenMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Rectangle oldB = nativeBounds;
|
||||
nativeBounds = new Rectangle(x, y, width, height);
|
||||
peer.notifyReshape(x, y, width, height);
|
||||
if (!oldB.getSize().equals(nativeBounds.getSize()) ) {
|
||||
flushBuffers();
|
||||
}
|
||||
//TODO validateSurface already called from notifyReshape
|
||||
validateSurface();
|
||||
}
|
||||
|
@ -150,6 +150,10 @@ public final class LWCToolkit extends LWToolkit {
|
||||
});
|
||||
}
|
||||
|
||||
public static LWCToolkit getLWCToolkit() {
|
||||
return (LWCToolkit)Toolkit.getDefaultToolkit();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PlatformWindow createPlatformWindow(PeerType peerType) {
|
||||
if (peerType == PeerType.EMBEDDEDFRAME) {
|
||||
@ -407,7 +411,6 @@ public final class LWCToolkit extends LWToolkit {
|
||||
return BUTTONS;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isTraySupported() {
|
||||
return true;
|
||||
@ -489,6 +492,22 @@ public final class LWCToolkit extends LWToolkit {
|
||||
synchronized(ret) { return ret[0]; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Just a wrapper for LWCToolkit.invokeAndWait. Posts an empty event to the
|
||||
* appropriate event queue and waits for it to finish.
|
||||
*/
|
||||
public static void flushPendingEventsOnAppkit(final Component component) {
|
||||
try {
|
||||
invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
}
|
||||
}, component);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Kicks an event over to the appropriate eventqueue and waits for it to finish
|
||||
// To avoid deadlocking, we manually run the NSRunLoop while waiting
|
||||
// Any selector invoked using ThreadUtilities performOnMainThread will be processed in doAWTRunLoop
|
||||
|
@ -86,11 +86,14 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
if (windowLayer != nil) {
|
||||
self.cglLayer = windowLayer;
|
||||
//Layer hosting view
|
||||
[self setLayer: cglLayer];
|
||||
[self setWantsLayer: YES];
|
||||
[self.layer addSublayer: (CALayer *)cglLayer];
|
||||
[self setLayerContentsRedrawPolicy: NSViewLayerContentsRedrawDuringViewResize];
|
||||
[self setLayerContentsPlacement: NSViewLayerContentsPlacementTopLeft];
|
||||
[self setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
|
||||
//Layer backed view
|
||||
//[self.layer addSublayer: (CALayer *)cglLayer];
|
||||
//[self setLayerContentsRedrawPolicy: NSViewLayerContentsRedrawDuringViewResize];
|
||||
//[self setLayerContentsPlacement: NSViewLayerContentsPlacementTopLeft];
|
||||
//[self setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
|
||||
|
||||
#ifdef REMOTELAYER
|
||||
CGLLayer *parentLayer = (CGLLayer*)self.cglLayer;
|
||||
|
@ -69,6 +69,9 @@
|
||||
- (BOOL) worksWhenModal;
|
||||
- (void)sendEvent:(NSEvent *)event;
|
||||
|
||||
+ (void) setLastKeyWindow:(AWTWindow *)window;
|
||||
+ (AWTWindow *) lastKeyWindow;
|
||||
|
||||
@end
|
||||
|
||||
@interface AWTWindow_Normal : NSWindow
|
||||
|
@ -51,6 +51,14 @@
|
||||
|
||||
static JNF_CLASS_CACHE(jc_CPlatformWindow, "sun/lwawt/macosx/CPlatformWindow");
|
||||
|
||||
// Cocoa windowDidBecomeKey/windowDidResignKey notifications
|
||||
// doesn't provide information about "opposite" window, so we
|
||||
// have to do a bit of tracking. This variable points to a window
|
||||
// which had been the key window just before a new key window
|
||||
// was set. It would be nil if the new key window isn't an AWT
|
||||
// window or the app currently has no key window.
|
||||
static AWTWindow* lastKeyWindow = nil;
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// NSWindow/NSPanel descendants implementation
|
||||
#define AWT_NS_WINDOW_IMPLEMENTATION \
|
||||
@ -505,15 +513,17 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
[self _deliverIconify:JNI_FALSE];
|
||||
}
|
||||
|
||||
- (void) _deliverWindowFocusEvent:(BOOL)focused {
|
||||
- (void) _deliverWindowFocusEvent:(BOOL)focused oppositeWindow:(AWTWindow *)opposite {
|
||||
//AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
|
||||
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
static JNF_MEMBER_CACHE(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(Z)V");
|
||||
JNFCallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused);
|
||||
jobject oppositeWindow = [opposite.javaPlatformWindow jObjectWithEnv:env];
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(ZLsun/lwawt/macosx/CPlatformWindow;)V");
|
||||
JNFCallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused, oppositeWindow);
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
(*env)->DeleteLocalRef(env, oppositeWindow);
|
||||
}
|
||||
}
|
||||
|
||||
@ -522,7 +532,10 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
[AWTToolkit eventCountPlusPlus];
|
||||
[CMenuBar activate:self.javaMenuBar modallyDisabled:NO];
|
||||
[self _deliverWindowFocusEvent:YES];
|
||||
AWTWindow *opposite = [AWTWindow lastKeyWindow];
|
||||
[AWTWindow setLastKeyWindow:nil];
|
||||
|
||||
[self _deliverWindowFocusEvent:YES oppositeWindow: opposite];
|
||||
}
|
||||
|
||||
- (void) windowDidResignKey: (NSNotification *) notification {
|
||||
@ -530,7 +543,18 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
[AWTToolkit eventCountPlusPlus];
|
||||
[self.javaMenuBar deactivate];
|
||||
[self _deliverWindowFocusEvent:NO];
|
||||
|
||||
// the new key window
|
||||
NSWindow *keyWindow = [NSApp keyWindow];
|
||||
AWTWindow *opposite = nil;
|
||||
if ([AWTWindow isAWTWindow: keyWindow]) {
|
||||
opposite = (AWTWindow *)[keyWindow delegate];
|
||||
[AWTWindow setLastKeyWindow: self];
|
||||
} else {
|
||||
[AWTWindow setLastKeyWindow: nil];
|
||||
}
|
||||
|
||||
[self _deliverWindowFocusEvent:NO oppositeWindow: opposite];
|
||||
}
|
||||
|
||||
- (void) windowDidBecomeMain: (NSNotification *) notification {
|
||||
@ -684,6 +708,17 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
}
|
||||
}
|
||||
|
||||
+ (void) setLastKeyWindow:(AWTWindow *)window {
|
||||
[window retain];
|
||||
[lastKeyWindow release];
|
||||
lastKeyWindow = window;
|
||||
}
|
||||
|
||||
+ (AWTWindow *) lastKeyWindow {
|
||||
return lastKeyWindow;
|
||||
}
|
||||
|
||||
|
||||
@end // AWTWindow
|
||||
|
||||
|
||||
@ -1208,6 +1243,10 @@ JNF_COCOA_ENTER(env);
|
||||
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
|
||||
AWTWindow *window = (AWTWindow*)[nsWindow delegate];
|
||||
|
||||
if ([AWTWindow lastKeyWindow] == window) {
|
||||
[AWTWindow setLastKeyWindow: nil];
|
||||
}
|
||||
|
||||
// AWTWindow holds a reference to the NSWindow in its nsWindow
|
||||
// property. Unsetting the delegate allows it to be deallocated
|
||||
// which releases the reference. This, in turn, allows the window
|
||||
|
@ -76,7 +76,7 @@ JNF_COCOA_ENTER(env);
|
||||
NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
|
||||
if ([currEvent type] == NSKeyDown) {
|
||||
NSString *menuKey = [sender keyEquivalent];
|
||||
NSString *eventKey = [currEvent characters];
|
||||
NSString *eventKey = [currEvent charactersIgnoringModifiers];
|
||||
if ([menuKey isEqualToString:eventKey]) {
|
||||
return;
|
||||
}
|
||||
|
@ -57,9 +57,10 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
// NOTE: async=YES means that the layer is re-cached periodically
|
||||
self.asynchronous = FALSE;
|
||||
self.autoresizingMask = kCALayerWidthSizable | kCALayerHeightSizable;
|
||||
self.contentsGravity = kCAGravityTopLeft;
|
||||
self.needsDisplayOnBoundsChange = YES;
|
||||
//Layer backed view
|
||||
//self.needsDisplayOnBoundsChange = YES;
|
||||
//self.autoresizingMask = kCALayerWidthSizable | kCALayerHeightSizable;
|
||||
textureID = 0; // texture will be created by rendering pipe
|
||||
target = 0;
|
||||
|
||||
@ -109,6 +110,10 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
glDisable(target);
|
||||
}
|
||||
|
||||
-(BOOL)canDrawInCGLContext:(CGLContextObj)glContext pixelFormat:(CGLPixelFormatObj)pixelFormat forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp{
|
||||
return textureID == 0 ? NO : YES;
|
||||
}
|
||||
|
||||
-(void)drawInCGLContext:(CGLContextObj)glContext pixelFormat:(CGLPixelFormatObj)pixelFormat forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp
|
||||
{
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
|
@ -31,6 +31,8 @@ import java.awt.Event;
|
||||
import java.awt.KeyEventPostProcessor;
|
||||
import java.awt.Window;
|
||||
import java.awt.Toolkit;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
@ -133,10 +135,15 @@ public class WindowsRootPaneUI extends BasicRootPaneUI {
|
||||
// window. If this time appears to be greater than the altRelease
|
||||
// event time the event is skipped to avoid unexpected menu
|
||||
// activation. See 7121442.
|
||||
// Also we must ensure that original source of key event belongs
|
||||
// to the same window object as winAncestor. See 8001633.
|
||||
boolean skip = false;
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
if (tk instanceof SunToolkit) {
|
||||
skip = ev.getWhen() <= ((SunToolkit)tk).getWindowDeactivationTime(winAncestor);
|
||||
Component originalSource = AWTAccessor.getKeyEventAccessor()
|
||||
.getOriginalSource(ev);
|
||||
skip = SunToolkit.getContainingWindow(originalSource) != winAncestor ||
|
||||
ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor);
|
||||
}
|
||||
|
||||
if (menu != null && !skip) {
|
||||
|
@ -930,6 +930,10 @@ public class KeyEvent extends InputEvent {
|
||||
long extendedKeyCode) {
|
||||
ev.extendedKeyCode = extendedKeyCode;
|
||||
}
|
||||
|
||||
public Component getOriginalSource( KeyEvent ev ) {
|
||||
return ev.originalSource;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -939,6 +943,14 @@ public class KeyEvent extends InputEvent {
|
||||
*/
|
||||
private static native void initIDs();
|
||||
|
||||
/**
|
||||
* The original event source.
|
||||
*
|
||||
* Event source can be changed during processing, but in some cases
|
||||
* we need to be able to obtain original source.
|
||||
*/
|
||||
private Component originalSource;
|
||||
|
||||
private KeyEvent(Component source, int id, long when, int modifiers,
|
||||
int keyCode, char keyChar, int keyLocation, boolean isProxyActive) {
|
||||
this(source, id, when, modifiers, keyCode, keyChar, keyLocation);
|
||||
@ -1023,6 +1035,7 @@ public class KeyEvent extends InputEvent {
|
||||
} else if ((getModifiers() == 0) && (getModifiersEx() != 0)) {
|
||||
setOldModifiers();
|
||||
}
|
||||
originalSource = source;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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
|
||||
@ -45,7 +45,7 @@ import java.io.Serializable;
|
||||
@SuppressWarnings("serial")
|
||||
class AncestorNotifier implements ComponentListener, PropertyChangeListener, Serializable
|
||||
{
|
||||
Component firstInvisibleAncestor;
|
||||
transient Component firstInvisibleAncestor;
|
||||
EventListenerList listenerList = new EventListenerList();
|
||||
JComponent root;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 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
|
||||
@ -952,7 +952,7 @@ class Parser implements DTDConstants {
|
||||
ch = readCh();
|
||||
break;
|
||||
}
|
||||
char data[] = {mapNumericReference((char) n)};
|
||||
char data[] = mapNumericReference(n);
|
||||
return data;
|
||||
}
|
||||
addString('#');
|
||||
@ -1021,7 +1021,7 @@ class Parser implements DTDConstants {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts numeric character reference to Unicode character.
|
||||
* Converts numeric character reference to char array.
|
||||
*
|
||||
* Normally the code in a reference should be always converted
|
||||
* to the Unicode character with the same code, but due to
|
||||
@ -1030,13 +1030,21 @@ class Parser implements DTDConstants {
|
||||
* to displayable characters with other codes.
|
||||
*
|
||||
* @param c the code of numeric character reference.
|
||||
* @return the character corresponding to the reference code.
|
||||
* @return a char array corresponding to the reference code.
|
||||
*/
|
||||
private char mapNumericReference(char c) {
|
||||
if (c < 130 || c > 159) {
|
||||
return c;
|
||||
private char[] mapNumericReference(int c) {
|
||||
char[] data;
|
||||
if (c >= 0xffff) { // outside unicode BMP.
|
||||
try {
|
||||
data = Character.toChars(c);
|
||||
} catch (IllegalArgumentException e) {
|
||||
data = new char[0];
|
||||
}
|
||||
} else {
|
||||
data = new char[1];
|
||||
data[0] = (c < 130 || c > 159) ? (char) c : cp1252Map[c - 130];
|
||||
}
|
||||
return cp1252Map[c - 130];
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -629,6 +629,11 @@ public final class AWTAccessor {
|
||||
* Sets extendedKeyCode field for KeyEvent
|
||||
*/
|
||||
void setExtendedKeyCode(KeyEvent ev, long extendedKeyCode);
|
||||
|
||||
/**
|
||||
* Gets original source for KeyEvent
|
||||
*/
|
||||
Component getOriginalSource(KeyEvent ev);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,7 +111,7 @@ public class ScreenUpdateManager {
|
||||
SurfaceData oldsd)
|
||||
{
|
||||
SurfaceData surfaceData = peer.getSurfaceData();
|
||||
if (surfaceData.isValid()) {
|
||||
if (surfaceData == null || surfaceData.isValid()) {
|
||||
return surfaceData;
|
||||
}
|
||||
peer.replaceSurfaceData();
|
||||
|
@ -150,6 +150,7 @@ AwtFont::AwtFont(int num, JNIEnv *env, jobject javaFont)
|
||||
|
||||
AwtFont::~AwtFont()
|
||||
{
|
||||
delete[] m_hFont;
|
||||
}
|
||||
|
||||
void AwtFont::Dispose() {
|
||||
@ -160,11 +161,12 @@ void AwtFont::Dispose() {
|
||||
/* NOTE: delete of windows HFONT happens in FontCache::Remove
|
||||
only when the final reference to the font is disposed */
|
||||
} else if (font != NULL) {
|
||||
// if font was not in cache, its not shared and we delete it now
|
||||
VERIFY(::DeleteObject(font));
|
||||
// if font was not in cache, its not shared and we delete it now
|
||||
DASSERT(::GetObjectType(font) == OBJ_FONT);
|
||||
VERIFY(::DeleteObject(font));
|
||||
}
|
||||
m_hFont[i] = NULL;
|
||||
}
|
||||
delete[] m_hFont;
|
||||
|
||||
AwtObject::Dispose();
|
||||
}
|
||||
|
@ -534,7 +534,6 @@ BOOL AwtToolkit::Dispose() {
|
||||
D3DInitializer::GetInstance().Clean();
|
||||
|
||||
AwtObjectList::Cleanup();
|
||||
AwtFont::Cleanup();
|
||||
|
||||
awt_dnd_uninitialize();
|
||||
awt_clipboard_uninitialize((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2));
|
||||
@ -554,6 +553,8 @@ BOOL AwtToolkit::Dispose() {
|
||||
::DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
AwtFont::Cleanup();
|
||||
|
||||
HWND toolkitHWndToDestroy = tk.m_toolkitHWnd;
|
||||
tk.m_toolkitHWnd = 0;
|
||||
VERIFY(::DestroyWindow(toolkitHWndToDestroy) != NULL);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/ksh -p
|
||||
|
||||
#
|
||||
# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2007, 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
|
||||
@ -39,7 +39,7 @@ status=1
|
||||
|
||||
#Call this from anywhere to fail the test with an error message
|
||||
# usage: fail "reason why the test failed"
|
||||
fail()
|
||||
fail()
|
||||
{ echo "The test failed :-("
|
||||
echo "$*" 1>&2
|
||||
echo "exit status was $status"
|
||||
@ -48,7 +48,7 @@ fail()
|
||||
|
||||
#Call this from anywhere to pass the test with a message
|
||||
# usage: pass "reason why the test passed if applicable"
|
||||
pass()
|
||||
pass()
|
||||
{ echo "The test passed!!!"
|
||||
echo "$*" 1>&2
|
||||
exit 0
|
||||
@ -64,20 +64,42 @@ OS=`uname -s`
|
||||
case "$OS" in
|
||||
SunOS )
|
||||
VAR="One value for Sun"
|
||||
DEFAULT_JDK=/usr/local/java/jdk1.2/solaris
|
||||
DEFAULT_JDK=/
|
||||
FILESEP="/"
|
||||
PATHSEP=":"
|
||||
TMP="/tmp"
|
||||
;;
|
||||
|
||||
Linux )
|
||||
VAR="A different value for Linux"
|
||||
DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i386
|
||||
DEFAULT_JDK=/
|
||||
FILESEP="/"
|
||||
PATHSEP=":"
|
||||
TMP="/tmp"
|
||||
;;
|
||||
|
||||
Windows_95 | Windows_98 | Windows_NT | Windows_ME )
|
||||
Darwin )
|
||||
VAR="A different value for MacOSX"
|
||||
DEFAULT_JDK=/usr
|
||||
FILESEP="/"
|
||||
PATHSEP=":"
|
||||
TMP="/tmp"
|
||||
;;
|
||||
|
||||
Windows* )
|
||||
VAR="A different value for Win32"
|
||||
DEFAULT_JDK=/usr/local/java/jdk1.2/win32
|
||||
DEFAULT_JDK="C:/Program Files/Java/jdk1.8.0"
|
||||
FILESEP="\\"
|
||||
PATHSEP=";"
|
||||
TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
|
||||
;;
|
||||
|
||||
CYGWIN* )
|
||||
VAR="A different value for Cygwin"
|
||||
DEFAULT_JDK="/cygdrive/c/Program\ Files/Java/jdk1.8.0"
|
||||
FILESEP="/"
|
||||
PATHSEP=";"
|
||||
TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
|
||||
;;
|
||||
|
||||
# catch all other OSs
|
||||
@ -88,8 +110,8 @@ case "$OS" in
|
||||
esac
|
||||
|
||||
|
||||
# Want this test to run standalone as well as in the harness, so do the
|
||||
# following to copy the test's directory into the harness's scratch directory
|
||||
# Want this test to run standalone as well as in the harness, so do the
|
||||
# following to copy the test's directory into the harness's scratch directory
|
||||
# and set all appropriate variables:
|
||||
|
||||
if [ -z "${TESTJAVA}" ] ; then
|
||||
@ -104,7 +126,7 @@ if [ -z "${TESTJAVA}" ] ; then
|
||||
if [ -n "$1" ] ;
|
||||
then TESTJAVA=$1
|
||||
else echo "no JDK specified on command line so using default!"
|
||||
TESTJAVA=$DEFAULT_JDK
|
||||
TESTJAVA=$DEFAULT_JDK
|
||||
fi
|
||||
TESTSRC=.
|
||||
TESTCLASSES=.
|
||||
@ -113,25 +135,25 @@ fi
|
||||
echo "JDK under test is: $TESTJAVA"
|
||||
|
||||
#Deal with .class files:
|
||||
if [ -n "${STANDALONE}" ] ;
|
||||
then
|
||||
if [ -n "${STANDALONE}" ] ;
|
||||
then
|
||||
#if standalone, remind user to cd to dir. containing test before running it
|
||||
echo "Just a reminder: cd to the dir containing this test when running it"
|
||||
# then compile all .java files (if there are any) into .class files
|
||||
if [ -a *.java ] ;
|
||||
if [ -a *.java ] ;
|
||||
then echo "Reminder, this test should be in its own directory with all"
|
||||
echo "supporting files it needs in the directory with it."
|
||||
${TESTJAVA}/bin/javac ./*.java ;
|
||||
${TESTJAVA}/bin/javac ./*.java ;
|
||||
fi
|
||||
# else in harness so copy all the class files from where jtreg put them
|
||||
# over to the scratch directory this test is running in.
|
||||
# over to the scratch directory this test is running in.
|
||||
else cp ${TESTCLASSES}/*.class . ;
|
||||
fi
|
||||
|
||||
#if in test harness, then copy the entire directory that the test is in over
|
||||
#if in test harness, then copy the entire directory that the test is in over
|
||||
# to the scratch directory. This catches any support files needed by the test.
|
||||
if [ -z "${STANDALONE}" ] ;
|
||||
then cp ${TESTSRC}/* .
|
||||
if [ -z "${STANDALONE}" ] ;
|
||||
then cp ${TESTSRC}/* .
|
||||
fi
|
||||
|
||||
#Just before executing anything, make sure it has executable permission!
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
# 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
|
||||
@ -38,7 +38,7 @@ status=1
|
||||
|
||||
#Call this from anywhere to fail the test with an error message
|
||||
# usage: fail "reason why the test failed"
|
||||
fail()
|
||||
fail()
|
||||
{ echo "The test failed :-("
|
||||
echo "$*" 1>&2
|
||||
echo "exit status was $status"
|
||||
@ -47,7 +47,7 @@ fail()
|
||||
|
||||
#Call this from anywhere to pass the test with a message
|
||||
# usage: pass "reason why the test passed if applicable"
|
||||
pass()
|
||||
pass()
|
||||
{ echo "The test passed!!!"
|
||||
echo "$*" 1>&2
|
||||
exit 0
|
||||
@ -99,20 +99,42 @@ OS=`uname -s`
|
||||
case "$OS" in
|
||||
SunOS )
|
||||
VAR="One value for Sun"
|
||||
DEFAULT_JDK=/usr/local/java/jdk1.2.1/solaris
|
||||
DEFAULT_JDK=/
|
||||
FILESEP="/"
|
||||
PATHSEP=":"
|
||||
TMP="/tmp"
|
||||
;;
|
||||
|
||||
Linux )
|
||||
VAR="A different value for Linux"
|
||||
DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i386
|
||||
DEFAULT_JDK=/
|
||||
FILESEP="/"
|
||||
PATHSEP=":"
|
||||
TMP="/tmp"
|
||||
;;
|
||||
|
||||
Windows_95 | Windows_98 | Windows_NT | Windows_ME | CYGWIN_NT-5.1)
|
||||
Darwin )
|
||||
VAR="A different value for MacOSX"
|
||||
DEFAULT_JDK=/usr
|
||||
FILESEP="/"
|
||||
PATHSEP=":"
|
||||
TMP="/tmp"
|
||||
;;
|
||||
|
||||
Windows* )
|
||||
VAR="A different value for Win32"
|
||||
DEFAULT_JDK=/usr/local/java/jdk1.2.1/win32
|
||||
DEFAULT_JDK="C:/Program Files/Java/jdk1.8.0"
|
||||
FILESEP="\\"
|
||||
PATHSEP=";"
|
||||
TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
|
||||
;;
|
||||
|
||||
CYGWIN* )
|
||||
VAR="A different value for Cygwin"
|
||||
DEFAULT_JDK="/cygdrive/c/Program\ Files/Java/jdk1.8.0"
|
||||
FILESEP="/"
|
||||
PATHSEP=";"
|
||||
TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
|
||||
;;
|
||||
|
||||
# catch all other OSs
|
||||
@ -132,12 +154,12 @@ fi
|
||||
# note that the name of the executable is in the fail string as well.
|
||||
# this is how to check for presence of the compiler, etc.
|
||||
#RESOURCE=`whence SomeProgramOrFileNeeded`
|
||||
#if [ "${RESOURCE}" = "" ] ;
|
||||
# then fail "Need SomeProgramOrFileNeeded to perform the test" ;
|
||||
#if [ "${RESOURCE}" = "" ] ;
|
||||
# then fail "Need SomeProgramOrFileNeeded to perform the test" ;
|
||||
#fi
|
||||
|
||||
# Want this test to run standalone as well as in the harness, so do the
|
||||
# following to copy the test's directory into the harness's scratch directory
|
||||
# Want this test to run standalone as well as in the harness, so do the
|
||||
# following to copy the test's directory into the harness's scratch directory
|
||||
# and set all appropriate variables:
|
||||
|
||||
if [ -z "${TESTJAVA}" ] ; then
|
||||
@ -152,7 +174,7 @@ if [ -z "${TESTJAVA}" ] ; then
|
||||
if [ -n "$1" ] ;
|
||||
then TESTJAVA=$1
|
||||
else echo "no JDK specified on command line so using default!"
|
||||
TESTJAVA=$DEFAULT_JDK
|
||||
TESTJAVA=$DEFAULT_JDK
|
||||
fi
|
||||
TESTSRC=.
|
||||
TESTCLASSES=.
|
||||
@ -161,25 +183,25 @@ fi
|
||||
echo "JDK under test is: $TESTJAVA"
|
||||
|
||||
#Deal with .class files:
|
||||
if [ -n "${STANDALONE}" ] ;
|
||||
then
|
||||
if [ -n "${STANDALONE}" ] ;
|
||||
then
|
||||
#if standalone, remind user to cd to dir. containing test before running it
|
||||
echo "Just a reminder: cd to the dir containing this test when running it"
|
||||
# then compile all .java files (if there are any) into .class files
|
||||
if [ -a *.java ] ;
|
||||
if [ -a *.java ] ;
|
||||
then echo "Reminder, this test should be in its own directory with all"
|
||||
echo "supporting files it needs in the directory with it."
|
||||
${TESTJAVA}/bin/javac ./*.java ;
|
||||
${TESTJAVA}/bin/javac ./*.java ;
|
||||
fi
|
||||
# else in harness so copy all the class files from where jtreg put them
|
||||
# over to the scratch directory this test is running in.
|
||||
# over to the scratch directory this test is running in.
|
||||
else cp ${TESTCLASSES}/*.class . ;
|
||||
fi
|
||||
|
||||
#if in test harness, then copy the entire directory that the test is in over
|
||||
#if in test harness, then copy the entire directory that the test is in over
|
||||
# to the scratch directory. This catches any support files needed by the test.
|
||||
#if [ -z "${STANDALONE}" ] ;
|
||||
# then cp ${TESTSRC}/* .
|
||||
#if [ -z "${STANDALONE}" ] ;
|
||||
# then cp ${TESTSRC}/* .
|
||||
#fi
|
||||
|
||||
#Just before executing anything, make sure it has executable permission!
|
||||
@ -198,7 +220,7 @@ chmod 777 ./*
|
||||
# this shell test as appropriate ( 0 status is considered a pass here )
|
||||
|
||||
# The test verifies that appletviewer correctly works with the different
|
||||
# names of the files, including relative and absolute paths
|
||||
# names of the files, including relative and absolute paths
|
||||
|
||||
# 6619458: exclude left brace from the name of the files managed by the VCS
|
||||
NAME='test.html'
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2009, 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
|
||||
@ -78,28 +78,44 @@ OS=`uname -s`
|
||||
case "$OS" in
|
||||
SunOS )
|
||||
VAR="One value for Sun"
|
||||
DEFAULT_JDK=/usr/local/java/jdk1.2/solaris
|
||||
DEFAULT_JDK=/
|
||||
FILESEP="/"
|
||||
PATHSEP=":"
|
||||
TMP="/tmp"
|
||||
;;
|
||||
|
||||
Linux | Darwin )
|
||||
Linux )
|
||||
VAR="A different value for Linux"
|
||||
DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i386
|
||||
DEFAULT_JDK=/
|
||||
FILESEP="/"
|
||||
PATHSEP=":"
|
||||
TMP="/tmp"
|
||||
;;
|
||||
|
||||
Windows_95 | Windows_98 | Windows_NT | Windows_ME | CYGWIN* )
|
||||
Darwin )
|
||||
VAR="A different value for MacOSX"
|
||||
DEFAULT_JDK=/usr
|
||||
FILESEP="/"
|
||||
PATHSEP=":"
|
||||
TMP="/tmp"
|
||||
;;
|
||||
|
||||
Windows* )
|
||||
VAR="A different value for Win32"
|
||||
DEFAULT_JDK=/usr/local/java/jdk1.2/win32
|
||||
DEFAULT_JDK="C:/Program Files/Java/jdk1.8.0"
|
||||
FILESEP="\\"
|
||||
PATHSEP=";"
|
||||
TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
|
||||
;;
|
||||
|
||||
CYGWIN* )
|
||||
VAR="A different value for Cygwin"
|
||||
DEFAULT_JDK="/cygdrive/c/Program\ Files/Java/jdk1.8.0"
|
||||
FILESEP="/"
|
||||
PATHSEP=";"
|
||||
TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
|
||||
;;
|
||||
|
||||
# catch all other OSs
|
||||
* )
|
||||
echo "Unrecognized system! $OS"
|
||||
|
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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 7193219
|
||||
@summary JComboBox serialization fails in JDK 1.7
|
||||
@author Anton Litvinov
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class bug7193219 {
|
||||
private static byte[] serializeGUI() {
|
||||
// Create and set up the window.
|
||||
JFrame frame = new JFrame("Serialization");
|
||||
JPanel mainPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* If JComboBox is replaced with other component like JLabel
|
||||
* The issue does not happen.
|
||||
*/
|
||||
JComboBox status = new JComboBox();
|
||||
status.addItem("123");
|
||||
mainPanel.add(status);
|
||||
frame.getContentPane().add(mainPanel);
|
||||
frame.pack();
|
||||
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||
oos.writeObject(mainPanel);
|
||||
oos.flush();
|
||||
frame.dispose();
|
||||
return baos.toByteArray();
|
||||
} catch (IOException ioe) {
|
||||
throw new RuntimeException(ioe);
|
||||
}
|
||||
}
|
||||
|
||||
private static void deserializeGUI(byte[] serializedData) {
|
||||
try {
|
||||
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(serializedData));
|
||||
JPanel mainPanel = (JPanel)ois.readObject();
|
||||
JFrame frame = new JFrame("Deserialization");
|
||||
frame.getContentPane().add(mainPanel);
|
||||
frame.pack();
|
||||
frame.dispose();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
deserializeGUI(serializeGUI());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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 7160951
|
||||
* @summary [macosx] ActionListener called twice for JMenuItem using ScreenMenuBar
|
||||
* @author vera.akulova@oracle.com
|
||||
* @run main ActionListenerCalledTwiceTest
|
||||
*/
|
||||
|
||||
import sun.awt.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class ActionListenerCalledTwiceTest {
|
||||
static volatile int listenerCallCounter = 0;
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.MACOSX) {
|
||||
System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
|
||||
return;
|
||||
}
|
||||
System.setProperty("apple.laf.useScreenMenuBar", "true");
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
robot.keyPress(KeyEvent.VK_META);
|
||||
robot.keyPress(KeyEvent.VK_E);
|
||||
robot.keyRelease(KeyEvent.VK_E);
|
||||
robot.keyRelease(KeyEvent.VK_META);
|
||||
toolkit.realSync();
|
||||
if (listenerCallCounter != 1) {
|
||||
throw new Exception("Test failed: ActionListener called " + listenerCallCounter + " times instead of 1!");
|
||||
}
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JMenuItem newItem = new JMenuItem("Exit");
|
||||
newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK));
|
||||
newItem.addActionListener(
|
||||
new ActionListener(){
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
listenerCallCounter++;
|
||||
}
|
||||
}
|
||||
);
|
||||
JMenu menu = new JMenu("Menu");
|
||||
menu.add(newItem);
|
||||
JMenuBar bar = new JMenuBar();
|
||||
bar.add(menu);
|
||||
JFrame frame = new JFrame("Test");
|
||||
frame.setJMenuBar(bar);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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 7186371
|
||||
* @summary [macosx] Main menu shortcuts not displayed
|
||||
* @author vera.akulova@oracle.com
|
||||
* @run main/manual ShortcutNotDisplayedTest
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class ShortcutNotDisplayedTest {
|
||||
static volatile boolean done = false;
|
||||
static volatile boolean pass = false;
|
||||
static final String PASS_COMMAND = "pass";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.MACOSX) {
|
||||
System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
|
||||
return;
|
||||
}
|
||||
System.setProperty("apple.laf.useScreenMenuBar", "true");
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
do { try { Thread.sleep(300); } catch (Exception e) {} } while (!done) ;
|
||||
if (!pass) {
|
||||
throw new Exception("Shortcuts not displayed as expected in the screen menu bar.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JMenuItem newItem = new JMenuItem("Exit");
|
||||
newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, java.awt.event.InputEvent.META_MASK));
|
||||
|
||||
JMenu menu = new JMenu("Test Frame Window Menu");
|
||||
menu.setMnemonic(KeyEvent.VK_M);
|
||||
menu.add(newItem);
|
||||
|
||||
JMenuBar bar = new JMenuBar();
|
||||
bar.add(menu);
|
||||
JTextArea text = new JTextArea(
|
||||
" Please follow instructions:\n" +
|
||||
" 1. You should see \"Test Frame Window Menu\" menu on the screen menu bar.\n" +
|
||||
" 2. Open \"Test Frame Window Menu\" menu. \n" +
|
||||
" Check that menu item \"Exit\" has a shortcut with image for Command Key and symbol \"E\". \n" +
|
||||
" If you see the shortcut press \"Passed\". Otherwise press \"Failed\".\n"
|
||||
);
|
||||
text.setEditable(false);
|
||||
|
||||
JScrollPane sp = new JScrollPane(text);
|
||||
sp.setSize(300,200);
|
||||
|
||||
JButton passBtn = new JButton("Pass");
|
||||
passBtn.setActionCommand(PASS_COMMAND);
|
||||
JButton failBtn = new JButton("Fail");
|
||||
ActionListener listener = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getActionCommand().equals(PASS_COMMAND)) {
|
||||
pass = true;
|
||||
}
|
||||
done = true;
|
||||
}
|
||||
};
|
||||
|
||||
JFrame testFrame = new JFrame("Test Frame Window");
|
||||
testFrame.setLayout(new FlowLayout());
|
||||
testFrame.setBounds(100, 100, 600, 180);
|
||||
testFrame.setJMenuBar(bar);
|
||||
testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
passBtn.addActionListener(listener);
|
||||
failBtn.addActionListener(listener);
|
||||
testFrame.getContentPane().add(sp);
|
||||
testFrame.getContentPane().add(passBtn);
|
||||
testFrame.getContentPane().add(failBtn);
|
||||
testFrame.setVisible(true);
|
||||
}
|
||||
}
|
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* 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 8001633
|
||||
@summary Wrong alt processing during switching between windows
|
||||
@author mikhail.cherkasov@oracle.com
|
||||
@run main WrongAltProcessing
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
|
||||
public class WrongAltProcessing {
|
||||
|
||||
private static Robot robot;
|
||||
private static JFrame firstFrame;
|
||||
private static JFrame secondFrame;
|
||||
private static JTextField mainFrameTf1;
|
||||
private static JTextField mainFrameTf2;
|
||||
private static JTextField secondFrameTf;
|
||||
|
||||
public static void main(String[] args) throws AWTException {
|
||||
try {
|
||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
|
||||
} catch (Exception e) {
|
||||
return;// miss unsupported platforms.
|
||||
}
|
||||
createWindows();
|
||||
initRobot();
|
||||
runScript();
|
||||
verify();
|
||||
}
|
||||
|
||||
private static void verify() {
|
||||
Component c = DefaultKeyboardFocusManager
|
||||
.getCurrentKeyboardFocusManager().getFocusOwner();
|
||||
if (!(c == mainFrameTf2)) {
|
||||
throw new RuntimeException("Wrong focus owner.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void sync() {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
toolkit.realSync();
|
||||
}
|
||||
|
||||
public static void initRobot() throws AWTException {
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
}
|
||||
|
||||
private static void clickWindowsTitle(JFrame frame) {
|
||||
Point point = frame.getLocationOnScreen();
|
||||
robot.mouseMove(point.x + (frame.getWidth() / 2), point.y + 5);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
}
|
||||
|
||||
public static void runScript() {
|
||||
robot.delay(1000);
|
||||
printABCD();
|
||||
pressTab();
|
||||
clickWindowsTitle(secondFrame);
|
||||
robot.delay(500);
|
||||
robot.keyPress(KeyEvent.VK_ALT);
|
||||
robot.keyRelease(KeyEvent.VK_ALT);
|
||||
clickWindowsTitle(firstFrame);
|
||||
sync();
|
||||
}
|
||||
|
||||
private static void pressTab() {
|
||||
robot.keyPress(KeyEvent.VK_TAB);
|
||||
robot.keyRelease(KeyEvent.VK_TAB);
|
||||
}
|
||||
|
||||
private static void printABCD() {
|
||||
robot.keyPress(KeyEvent.VK_A);
|
||||
robot.keyRelease(KeyEvent.VK_A);
|
||||
robot.keyPress(KeyEvent.VK_B);
|
||||
robot.keyRelease(KeyEvent.VK_B);
|
||||
robot.keyPress(KeyEvent.VK_C);
|
||||
robot.keyRelease(KeyEvent.VK_C);
|
||||
robot.keyPress(KeyEvent.VK_D);
|
||||
robot.keyRelease(KeyEvent.VK_D);
|
||||
}
|
||||
|
||||
public static void createWindows() {
|
||||
firstFrame = new JFrame("Frame");
|
||||
firstFrame.setLayout(new FlowLayout());
|
||||
|
||||
JMenuBar bar = new JMenuBar();
|
||||
JMenu menu = new JMenu("File");
|
||||
JMenuItem item = new JMenuItem("Save");
|
||||
|
||||
mainFrameTf1 = new JTextField(10);
|
||||
mainFrameTf2 = new JTextField(10);
|
||||
|
||||
mainFrameTf1.addKeyListener(new KeyAdapter() {
|
||||
public void keyPressed(KeyEvent EVT) {
|
||||
if (EVT.getKeyChar() >= 'a' && EVT.getKeyChar() <= 'z') {
|
||||
try {
|
||||
// imitate some long processing
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
menu.add(item);
|
||||
bar.add(menu);
|
||||
firstFrame.setJMenuBar(bar);
|
||||
|
||||
|
||||
firstFrame.add(mainFrameTf1);
|
||||
firstFrame.add(mainFrameTf2);
|
||||
|
||||
firstFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
firstFrame.pack();
|
||||
|
||||
secondFrame = new JFrame("Frame 2");
|
||||
secondFrame.setLocation(0, 150);
|
||||
secondFrameTf = new JTextField(20);
|
||||
secondFrame.add(secondFrameTf);
|
||||
secondFrame.pack();
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
secondFrame.setVisible(true);
|
||||
}
|
||||
});
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
firstFrame.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
mainFrameTf1.requestFocus();
|
||||
sync();
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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 6836089
|
||||
* @summary Tests correct parsing of characters outside Base Multilingual Plane
|
||||
* @author Vladislav Karnaukhov
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.html.*;
|
||||
|
||||
public class bug6836089 {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
JTextPane htmlPane = new JTextPane();
|
||||
htmlPane.setEditorKit(new HTMLEditorKit());
|
||||
|
||||
htmlPane.setText("<html><head></head><body>𠀀</body></html>");
|
||||
String str = htmlPane.getText();
|
||||
if (str.contains("�")) {
|
||||
throw new RuntimeException("Test failed");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user