提交 e3f4887c 编写于 作者: L lana

Merge

......@@ -125,6 +125,26 @@ ifeq ($(PLATFORM), windows)
OTHER_LDLIBS += jli.lib
endif
#
# Applications expect to be able to link against libjawt without invoking
# System.loadLibrary("jawt") first. This was the behaviour described in the
# devloper documentation of JAWT and what worked with OpenJDK6.
#
ifeq ($(PLATFORM), solaris)
ifeq ($(ARCH_DATA_MODEL), 32)
LDFLAGS += -R \$$ORIGIN/../lib/$(LIBARCH)
LDFLAGS += -R \$$ORIGIN/../jre/lib/$(LIBARCH)
else # ! ARCH_DATA_MODEL 64-bit
LDFLAGS += -R \$$ORIGIN/../../lib/$(LIBARCH)
LDFLAGS += -R \$$ORIGIN/../../jre/lib/$(LIBARCH)
endif # ARCH_DATA_MODEL
endif # PLATFORM SOLARIS
ifeq ($(PLATFORM), linux)
LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../lib/$(LIBARCH)
LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../jre/lib/$(LIBARCH)
endif # PLATFORM LINUX
#
# Launcher specific files.
#
......
......@@ -30,6 +30,13 @@ PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
#
# libjawt links to other programs, but nothing links to it directly. An RPATH
# entry has been added to the launcher so third-party programs linked against
# it will be able to find it no matter where the JDK or the third-party program
# is located.
#
#
# Files
#
......
......@@ -34,7 +34,7 @@ import javax.swing.plaf.ComponentUI;
import sun.lwawt.macosx.CMenuItem;
class ScreenMenuItem extends MenuItem implements ActionListener, ComponentListener, ScreenMenuPropertyHandler {
final class ScreenMenuItem extends MenuItem implements ActionListener, ComponentListener, ScreenMenuPropertyHandler {
ScreenMenuPropertyListener fListener;
JMenuItem fMenuItem;
......@@ -96,21 +96,31 @@ class ScreenMenuItem extends MenuItem implements ActionListener, ComponentListen
fMenuItem.removeComponentListener(this);
}
public void setAccelerator(final KeyStroke ks) {
if (ks == null) {
setShortcut(null);
static void syncLabelAndKS(MenuItem menuItem, String label, KeyStroke ks) {
final MenuComponentPeer peer = menuItem.getPeer();
if (!(peer instanceof CMenuItem)) {
//Is it possible?
return;
}
final MenuComponentPeer peer = getPeer();
if (peer instanceof CMenuItem) {
final CMenuItem ourPeer = (CMenuItem)peer;
ourPeer.setLabel(fMenuItem.getText(), ks.getKeyChar(), ks.getKeyCode(), ks.getModifiers());
final CMenuItem cmi = (CMenuItem) peer;
if (ks == null) {
cmi.setLabel(label);
} else {
setShortcut(new MenuShortcut(ks.getKeyCode(), (ks.getModifiers() & InputEvent.SHIFT_MASK) != 0));
cmi.setLabel(label, ks.getKeyChar(), ks.getKeyCode(),
ks.getModifiers());
}
}
@Override
public synchronized void setLabel(final String label) {
syncLabelAndKS(this, label, fMenuItem.getAccelerator());
}
@Override
public void setAccelerator(final KeyStroke ks) {
syncLabelAndKS(this, fMenuItem.getText(), ks);
}
public void actionPerformed(final ActionEvent e) {
fMenuItem.doClick(0); // This takes care of all the different events
}
......
......@@ -36,7 +36,7 @@ import com.apple.laf.AquaMenuItemUI.IndeterminateListener;
import sun.lwawt.macosx.*;
class ScreenMenuItemCheckbox extends CheckboxMenuItem implements ActionListener, ComponentListener, ScreenMenuPropertyHandler, ItemListener {
final class ScreenMenuItemCheckbox extends CheckboxMenuItem implements ActionListener, ComponentListener, ScreenMenuPropertyHandler, ItemListener {
JMenuItem fMenuItem;
MenuContainer fParent;
......@@ -110,19 +110,14 @@ class ScreenMenuItemCheckbox extends CheckboxMenuItem implements ActionListener,
super.removeNotify();
}
public void setAccelerator(final KeyStroke ks) {
if (ks == null) {
setShortcut(null);
return;
}
@Override
public synchronized void setLabel(final String label) {
ScreenMenuItem.syncLabelAndKS(this, label, fMenuItem.getAccelerator());
}
final MenuComponentPeer peer = getPeer();
if (peer instanceof CMenuItem) {
final CMenuItem ourPeer = (CMenuItem)peer;
ourPeer.setLabel(fMenuItem.getText(), ks.getKeyChar(), ks.getKeyCode(), ks.getModifiers());
} else {
setShortcut(new MenuShortcut(ks.getKeyCode(), (ks.getModifiers() & InputEvent.SHIFT_MASK) != 0));
}
@Override
public void setAccelerator(final KeyStroke ks) {
ScreenMenuItem.syncLabelAndKS(this, fMenuItem.getText(), ks);
}
public void actionPerformed(final ActionEvent e) {
......
......@@ -31,8 +31,12 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.ImageCapabilities;
import java.awt.Rectangle;
import java.awt.Transparency;
import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
......@@ -44,6 +48,7 @@ import java.awt.image.WritableRaster;
import sun.awt.CGraphicsConfig;
import sun.awt.CGraphicsDevice;
import sun.awt.TextureSizeConstraining;
import sun.awt.image.OffScreenImage;
import sun.awt.image.SunVolatileImage;
import sun.awt.image.SurfaceManager;
......@@ -65,7 +70,7 @@ import sun.java2d.pipe.hw.AccelDeviceEventNotifier;
import sun.lwawt.macosx.CPlatformView;
public class CGLGraphicsConfig extends CGraphicsConfig
implements OGLGraphicsConfig
implements OGLGraphicsConfig, TextureSizeConstraining
{
//private static final int kOpenGLSwapInterval = RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
private static final int kOpenGLSwapInterval = 0; // TODO
......@@ -242,6 +247,8 @@ public class CGLGraphicsConfig extends CGraphicsConfig
} finally {
rq.unlock();
}
updateTotalDisplayBounds();
}
@Override
......@@ -478,4 +485,50 @@ public class CGLGraphicsConfig extends CGraphicsConfig
public void removeDeviceEventListener(AccelDeviceEventListener l) {
AccelDeviceEventNotifier.removeListener(l);
}
private static final Rectangle totalDisplayBounds = new Rectangle();
private static void updateTotalDisplayBounds() {
synchronized (totalDisplayBounds) {
Rectangle virtualBounds = new Rectangle();
for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
for (GraphicsConfiguration gc : gd.getConfigurations()) {
virtualBounds = virtualBounds.union(gc.getBounds());
}
}
totalDisplayBounds.setBounds(virtualBounds);
}
}
// 7160609: GL still fails to create a square texture of this size,
// so we use this value to cap the total display bounds.
native private static int getMaxTextureSize();
@Override
public int getMaxTextureWidth() {
int width;
synchronized (totalDisplayBounds) {
if (totalDisplayBounds.width == 0) {
updateTotalDisplayBounds();
}
width = totalDisplayBounds.width;
}
return Math.min(width, getMaxTextureSize());
}
@Override
public int getMaxTextureHeight() {
int height;
synchronized (totalDisplayBounds) {
if (totalDisplayBounds.height == 0) {
updateTotalDisplayBounds();
}
height = totalDisplayBounds.height;
}
return Math.min(height, getMaxTextureSize());
}
}
......@@ -282,7 +282,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
* Note that we call setVisible() at the end of initialization.
*/
public final void initialize() {
platformComponent.initialize(target, this, getPlatformWindow());
platformComponent.initialize(getPlatformWindow());
initializeImpl();
setVisible(target.isVisible());
}
......
......@@ -338,6 +338,18 @@ public class LWWindowPeer
h = MINIMUM_HEIGHT;
}
if (graphicsConfig instanceof TextureSizeConstraining) {
final int maxW = ((TextureSizeConstraining)graphicsConfig).getMaxTextureWidth();
final int maxH = ((TextureSizeConstraining)graphicsConfig).getMaxTextureHeight();
if (w > maxW) {
w = maxW;
}
if (h > maxH) {
h = maxH;
}
}
// Don't post ComponentMoved/Resized and Paint events
// until we've got a notification from the delegate
setBounds(x, y, w, h, op, false, false);
......@@ -405,14 +417,33 @@ public class LWWindowPeer
@Override
public void updateMinimumSize() {
Dimension d = null;
final Dimension min;
if (getTarget().isMinimumSizeSet()) {
d = getTarget().getMinimumSize();
min = getTarget().getMinimumSize();
min.width = Math.max(min.width, MINIMUM_WIDTH);
min.height = Math.max(min.height, MINIMUM_HEIGHT);
} else {
min = new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT);
}
if (d == null) {
d = new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT);
final int maxW, maxH;
if (graphicsConfig instanceof TextureSizeConstraining) {
maxW = ((TextureSizeConstraining)graphicsConfig).getMaxTextureWidth();
maxH = ((TextureSizeConstraining)graphicsConfig).getMaxTextureHeight();
} else {
maxW = maxH = Integer.MAX_VALUE;
}
final Dimension max;
if (getTarget().isMaximumSizeSet()) {
max = getTarget().getMaximumSize();
max.width = Math.min(max.width, maxW);
max.height = Math.min(max.height, maxH);
} else {
max = new Dimension(maxW, maxH);
}
platformWindow.setMinimumSize(d.width, d.height);
platformWindow.setSizeConstraints(min.width, min.height, max.width, max.height);
}
@Override
......
......@@ -23,15 +23,38 @@
* questions.
*/
package sun.lwawt;
import java.awt.Component;
package sun.lwawt;
/**
* Can be used to store information about native resource related to the
* lightweight component.
*/
public interface PlatformComponent {
public void initialize(Component target, LWComponentPeer peer, PlatformWindow platformWindow);
/**
* Initializes platform component.
*
* @param platformWindow already initialized {@code PlatformWindow}.
*/
void initialize(PlatformWindow platformWindow);
public void setBounds(int x, int y, int w, int h);
/**
* Moves and resizes this component. The new location of the top-left corner
* is specified by {@code x} and {@code y}, and the new size is specified by
* {@code w} and {@code h}. The location is specified relative to the {@code
* platformWindow}.
*
* @param x the X location of the component
* @param y the Y location of the component
* @param w the width of the component
* @param h the height of the component
*/
void setBounds(int x, int y, int w, int h);
public void dispose();
/**
* Releases all of the native resources used by this {@code
* PlatformComponent}.
*/
void dispose();
}
......@@ -131,7 +131,10 @@ public interface PlatformWindow {
public void setResizable(boolean resizable);
public void setMinimumSize(int width, int height);
/**
* Applies the minimum and maximum size to the platform window.
*/
public void setSizeConstraints(int minW, int minH, int maxW, int maxH);
/**
* Transforms the given Graphics object according to the native
......
......@@ -33,8 +33,8 @@ package sun.lwawt.macosx;
public class CFRetainedResource {
private static native void nativeCFRelease(final long ptr, final boolean disposeOnAppKitThread);
final boolean disposeOnAppKitThread;
protected long ptr;
private final boolean disposeOnAppKitThread;
protected volatile long ptr;
/**
* @param ptr CFRetained native object pointer
......
......@@ -30,12 +30,14 @@ import java.awt.peer.*;
import java.awt.BufferCapabilities.FlipContents;
import java.awt.event.*;
import java.awt.image.*;
import java.security.AccessController;
import java.util.List;
import java.io.*;
import sun.awt.CausedFocusEvent.Cause;
import sun.awt.AWTAccessor;
import sun.java2d.pipe.Region;
import sun.security.action.GetBooleanAction;
class CFileDialog implements FileDialogPeer {
......@@ -53,11 +55,14 @@ class CFileDialog implements FileDialogPeer {
if (title == null) {
title = " ";
}
Boolean chooseDirectories = AccessController.doPrivileged(
new GetBooleanAction("apple.awt.fileDialogForDirectories"));
String[] userFileNames = nativeRunFileDialog(title,
dialogMode,
target.isMultipleMode(),
navigateApps,
chooseDirectories,
target.getFilenameFilter() != null,
target.getDirectory(),
target.getFile());
......@@ -142,7 +147,8 @@ class CFileDialog implements FileDialogPeer {
}
private native String[] nativeRunFileDialog(String title, int mode,
boolean multipleMode, boolean shouldNavigateApps, boolean hasFilenameFilter,
boolean multipleMode, boolean shouldNavigateApps,
boolean canChooseDirectories, boolean hasFilenameFilter,
String directory, String file);
@Override
......
......@@ -23,27 +23,24 @@
* questions.
*/
package sun.lwawt.macosx;
import java.awt.Component;
import java.awt.Insets;
import sun.lwawt.PlatformComponent;
import sun.lwawt.PlatformWindow;
import sun.lwawt.LWComponentPeer;
import sun.lwawt.macosx.CFRetainedResource;
public class CPlatformComponent extends CFRetainedResource implements PlatformComponent {
Component target;
LWComponentPeer peer;
PlatformWindow platformWindow;
/**
* On OSX {@code CPlatformComponent} stores pointer to the native CAlayer which
* can be used from JAWT.
*/
final class CPlatformComponent extends CFRetainedResource
implements PlatformComponent {
private native long nativeCreateComponent(long windowLayer);
private native long nativeSetBounds(long ptr, int x, int y, int width, int height);
private volatile PlatformWindow platformWindow;
public CPlatformComponent() {
CPlatformComponent() {
super(0, true);
}
......@@ -51,27 +48,28 @@ public class CPlatformComponent extends CFRetainedResource implements PlatformCo
return ptr;
}
public void initialize(Component target, LWComponentPeer peer, PlatformWindow platformWindow) {
this.target = target;
this.peer = peer;
@Override
public void initialize(final PlatformWindow platformWindow) {
this.platformWindow = platformWindow;
long windowLayerPtr = platformWindow.getLayerPtr();
setPtr(nativeCreateComponent(windowLayerPtr));
setPtr(nativeCreateComponent(platformWindow.getLayerPtr()));
}
// TODO: visibility, z-order
@Override
public void setBounds(int x, int y, int width, int height) {
public void setBounds(final int x, final int y, final int w, final int h) {
// translates values from the coordinate system of the top-level window
// to the coordinate system of the content view
Insets insets = platformWindow.getPeer().getInsets();
nativeSetBounds(getPointer(), x - insets.left, y - insets.top, width, height);
final Insets insets = platformWindow.getPeer().getInsets();
nativeSetBounds(getPointer(), x - insets.left, y - insets.top, w, h);
}
@Override
public void dispose() {
super.dispose();
}
private native long nativeCreateComponent(long windowLayer);
private native void nativeSetBounds(long ptr, int x, int y, int w, int h);
}
......@@ -180,7 +180,7 @@ public class CPlatformEmbeddedFrame implements PlatformWindow {
public void setResizable(boolean resizable) {}
@Override
public void setMinimumSize(int width, int height) {}
public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {}
@Override
public Graphics transformGraphics(Graphics g) {
......
......@@ -672,20 +672,15 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
// Re-apply the size constraints and the size to ensure the space
// occupied by the grow box is counted properly
setMinimumSize(1, 1); // the method ignores its arguments
peer.updateMinimumSize();
Rectangle bounds = peer.getBounds();
setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
}
@Override
public void setMinimumSize(int width, int height) {
//TODO width, height should be used
//NOTE: setResizable() calls setMinimumSize(1,1) relaying on the logic below
final long nsWindowPtr = getNSWindowPtr();
final Dimension min = target.getMinimumSize();
final Dimension max = target.getMaximumSize();
nativeSetNSWindowMinMax(nsWindowPtr, min.getWidth(), min.getHeight(), max.getWidth(), max.getHeight());
public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {
nativeSetNSWindowMinMax(getNSWindowPtr(), minW, minH, maxW, maxH);
}
@Override
......
......@@ -78,11 +78,10 @@
// translates values to the coordinate system of the "root" layer
CGFloat newY = windowLayer.bounds.size.height - rect.origin.y - rect.size.height;
CGRect newRect = CGRectMake(rect.origin.x, newY, rect.size.width, rect.size.height);
// REMIND: why do we need to inverse position?
CGRect newRect = CGRectMake(-rect.origin.x, -newY, rect.size.width, rect.size.height);
layer.frame = newRect;
layer.bounds = newRect;
[AWTSurfaceLayers repaintLayersRecursively:layer];
}
......
......@@ -52,6 +52,9 @@
// Should we navigate into apps?
BOOL fNavigateApps;
// Can the dialog choose directories ?
BOOL fChooseDirectories;
// Contains the absolute paths of the selected files as URLs
NSArray *fURLs;
}
......@@ -65,6 +68,7 @@
mode:(jint)inMode
multipleMode:(BOOL)inMultipleMode
shouldNavigate:(BOOL)inNavigateApps
canChooseDirectories:(BOOL)inChooseDirectories
withEnv:(JNIEnv*)env;
// Invoked from the main thread
......
......@@ -43,6 +43,7 @@
mode:(jint)inMode
multipleMode:(BOOL)inMultipleMode
shouldNavigate:(BOOL)inNavigateApps
canChooseDirectories:(BOOL)inChooseDirectories
withEnv:(JNIEnv*)env;
{
if (self == [super init]) {
......@@ -57,6 +58,7 @@
fMode = inMode;
fMultipleMode = inMultipleMode;
fNavigateApps = inNavigateApps;
fChooseDirectories = inChooseDirectories;
fPanelResult = NSCancelButton;
}
......@@ -109,7 +111,7 @@
NSOpenPanel *openPanel = (NSOpenPanel *)thePanel;
[openPanel setAllowsMultipleSelection:fMultipleMode];
[openPanel setCanChooseFiles:YES];
[openPanel setCanChooseDirectories:NO];
[openPanel setCanChooseDirectories:fChooseDirectories];
[openPanel setCanCreateDirectories:YES];
}
......@@ -182,7 +184,8 @@
JNIEXPORT jobjectArray JNICALL
Java_sun_lwawt_macosx_CFileDialog_nativeRunFileDialog
(JNIEnv *env, jobject peer, jstring title, jint mode, jboolean multipleMode,
jboolean navigateApps, jboolean hasFilter, jstring directory, jstring file)
jboolean navigateApps, jboolean chooseDirectories, jboolean hasFilter,
jstring directory, jstring file)
{
jobjectArray returnValue = NULL;
......@@ -200,6 +203,7 @@ JNF_COCOA_ENTER(env);
mode:mode
multipleMode:multipleMode
shouldNavigate:navigateApps
canChooseDirectories:chooseDirectories
withEnv:env];
[JNFRunLoop performOnMainThread:@selector(safeSaveOrLoad)
......
......@@ -447,3 +447,20 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getOGLCapabilities
return cglinfo->context->caps;
}
}
JNIEXPORT jint JNICALL
Java_sun_java2d_opengl_CGLGraphicsConfig_getMaxTextureSize
(JNIEnv *env, jclass cglgc)
{
J2dTraceLn(J2D_TRACE_INFO, "CGLGraphicsConfig_getMaxTextureSize");
__block int max = 0;
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
[sharedContext makeCurrentContext];
j2d_glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max);
}];
return (jint)max;
}
......@@ -28,7 +28,6 @@
@interface NSApplicationAWT : NSApplication {
NSString *fApplicationName;
BOOL fUseDefaultIcon;
NSWindow *eventTransparentWindow;
}
......
......@@ -52,7 +52,6 @@ BOOL postEventDuringEventSynthesis = NO;
AWT_ASSERT_APPKIT_THREAD;
fApplicationName = nil;
fUseDefaultIcon = NO;
// NSApplication will call _RegisterApplication with the application's bundle, but there may not be one.
// So, we need to call it ourselves to ensure the app is set up properly.
......@@ -147,10 +146,6 @@ AWT_ASSERT_APPKIT_THREAD;
if (appName != NULL) {
fApplicationName = [NSString stringWithUTF8String:appName];
unsetenv(envVar);
// If this environment variable was set we were launched from the command line, so we
// should use a generic app icon if one wasn't set.
fUseDefaultIcon = YES;
}
// If it wasn't specified as an argument, see if it was specified as a system property.
......@@ -171,9 +166,6 @@ AWT_ASSERT_APPKIT_THREAD;
if (lastPeriod.location != NSNotFound) {
fApplicationName = [fApplicationName substringFromIndex:lastPeriod.location + 1];
}
// If this environment variable was set we were launched from the command line, so we
// should use a generic app icon if one wasn't set.
fUseDefaultIcon = YES;
}
}
......@@ -266,8 +258,11 @@ AWT_ASSERT_APPKIT_THREAD;
// If the icon file wasn't specified as an argument and we need to get an icon
// we'll use the generic java app icon.
NSString *defaultIconPath = [NSString stringWithFormat:@"%@%@", SHARED_FRAMEWORK_BUNDLE, @"/Resources/GenericApp.icns"];
if (fUseDefaultIcon && (theIconPath == nil)) {
theIconPath = defaultIconPath;
if (theIconPath == nil) {
NSString* bundleIcon = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIconFile"];
if (bundleIcon == nil) {
theIconPath = defaultIconPath;
}
}
// Set up the dock icon if we have an icon name.
......
......@@ -150,7 +150,7 @@ import sun.util.logging.PlatformLogger;
* import java.awt.event.*;
* import java.io.Serializable;
*
* class MyApp java.io.Serializable
* class MyApp implements java.io.Serializable
* {
* BigObjectThatShouldNotBeSerializedWithAButton bigOne;
* Button aButton = new Button();
......
......@@ -36,6 +36,8 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.EmptyStackException;
import sun.awt.dnd.SunDropTargetEvent;
import sun.util.logging.PlatformLogger;
import sun.awt.AppContext;
......@@ -464,7 +466,9 @@ public class EventQueue {
case MouseEvent.MOUSE_MOVED:
return MOVE;
case MouseEvent.MOUSE_DRAGGED:
return DRAG;
// Return -1 for SunDropTargetEvent since they are usually synchronous
// and we don't want to skip them by coalescing with MouseEvent or other drag events
return e instanceof SunDropTargetEvent ? -1 : DRAG;
default:
return e instanceof PeerEvent ? PEER : -1;
}
......
......@@ -657,7 +657,7 @@ public class PropertyDescriptor extends FeatureDescriptor {
throw new IntrospectionException("bad write method arg count: "
+ writeMethod);
}
if (propertyType != null && propertyType != params[0]) {
if (propertyType != null && !params[0].isAssignableFrom(propertyType)) {
throw new IntrospectionException("type mismatch between read and write methods");
}
propertyType = params[0];
......
......@@ -8590,7 +8590,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* <code>null</code> if this object is not on the screen
*/
public Point getLocationOnScreen() {
if (parent != null) {
if (parent != null && parent.isShowing()) {
Point parentLocation = parent.getLocationOnScreen();
Point componentLocation = getLocation();
componentLocation.translate(parentLocation.x, parentLocation.y);
......@@ -9391,7 +9391,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* <code>null</code> if this object is not on the screen
*/
public Point getLocationOnScreen() {
if (parent != null) {
if (parent != null && parent.isShowing()) {
Point parentLocation = parent.getLocationOnScreen();
Point componentLocation = getLocation();
componentLocation.translate(parentLocation.x, parentLocation.y);
......
/*
* 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. 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.
*/
package sun.awt;
/**
* A GraphicsConfiguration implements the TextureSizeConstraining
* interface to indicate that it imposes certain limitations on the
* maximum size of supported textures.
*/
public interface TextureSizeConstraining {
/**
* Returns the maximum width of any texture image.
*/
public int getMaxTextureWidth();
/**
* Returns the maximum height of any texture image.
*/
public int getMaxTextureHeight();
}
/*
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
* 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
......@@ -22,19 +22,28 @@
*/
/*
* @test
* @bug 4380468
* @summary JColorChooser's HSB panel should display all RGB digits
* @author Andrey Pikalev
* @run applet/manual=yesno Test4380468.html
*/
@test
@bug 7160609
@summary A window with huge dimensions shouldn't crash JVM
@author anthony.petrov@oracle.com: area=awt.toplevel
@run main HugeFrame
*/
import java.awt.*;
public class HugeFrame {
public static void main(String[] args) throws Exception {
Frame f = new Frame("Huge");
// 8193+ should already produce a crash, but let's go extreme...
f.setBounds(10, 10, 30000, 500000);
f.setVisible(true);
import java.awt.Color;
import javax.swing.JApplet;
import javax.swing.JColorChooser;
// We would crash by now if the bug wasn't fixed
Thread.sleep(1000);
System.err.println(f.getBounds());
public class Test4380468 extends JApplet {
public void init() {
add(new JColorChooser(Color.GREEN));
// Cleanup
f.dispose();
}
}
/*
* 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 7189112
* @summary Tests overridden getter
* @author Sergey Malenkov
*/
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
public class Test7189112 {
public static void main(String[] args) throws IntrospectionException {
for (PropertyDescriptor pd : Introspector.getBeanInfo(MyBean.class).getPropertyDescriptors()) {
if (pd.getName().equals("value") && (null == pd.getWriteMethod())) {
throw new Error("The property setter is not found");
}
}
}
public static class BaseBean {
private Object value;
public Object getValue() {
return this.value;
}
public void setValue(Object value) {
this.value = value;
}
}
public static class MyBean extends BaseBean {
@Override
public String getValue() {
return (String) super.getValue();
}
}
}
<html>
<body>
1. Click the HSB tab at the ColorChooser.
2. Click in the lower left corner of the gradient palette
in order to select a color such that all three RGB values
are single digit colors (such as 0, 0, 0 or 5, 3, 1).
3. Click another tab, then click back to the HSB tab.
4. Now click the lighter colors that should have
2 and 3 digit RGB values (in the upper right corner).
If all digits of each RGB value are shown then test passes.
If only the last digit of their values are shown then test fails.
<applet width="500" height="400" code="Test4380468.class">
</applet>
</body>
</html>
/*
* 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 4201995
* @summary Tests that JSplitPane is opaque
* @author Scott Violet
*/
import javax.swing.*;
public class bug4201995 {
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
boolean expectedOpaqueValue = !"Nimbus".equals(UIManager.getLookAndFeel().getName());
JSplitPane sp = new JSplitPane();
if (sp.isOpaque() != expectedOpaqueValue) {
throw new RuntimeException("JSplitPane has incorrect default opaque value");
}
}
});
}
}
/*
* 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 4235420
@summary Tests that JTable delays creating Renderers and Editors
@author Peter Zhelezniakov
*/
import javax.swing.*;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class bug4235420 {
public static void main(String[] argv) throws Exception {
if ("Nimbus".equals(UIManager.getLookAndFeel().getName())) {
System.out.println("The test is skipped for Nimbus");
return;
}
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
Table table = new Table();
table.test();
}
});
}
private static class Table extends JTable {
public void test() {
// Renderers
Class[] rendererClasses = {Object.class, Number.class, Date.class, ImageIcon.class, Boolean.class};
Map copy = new HashMap(defaultRenderersByColumnClass);
for (Class rendererClass : rendererClasses) {
Object obj = copy.get(rendererClass);
if (obj instanceof TableCellRenderer) {
throw new Error("Failed: TableCellRenderer created for " +
rendererClass.getClass().getName());
}
}
// Editors
Class[] editorClasses = {Object.class, Number.class, Boolean.class};
copy = new HashMap(defaultEditorsByColumnClass);
for (Class editorClass : editorClasses) {
Object obj = copy.get(editorClass);
if (obj instanceof TableCellEditor) {
throw new Error("Failed: TableCellEditor created for " +
editorClass.getClass().getName());
}
}
}
}
}
/*
* 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.
*/
/*
* Portions Copyright (c) 2012 IBM Corporation
*/
/* @test
* @bug 7188612
* @summary AccessibleTableHeader and AccessibleJTableCell should stick to
* AccessibleComponent.getLocationOnScreen api.
* @author Frank Ding
*/
import javax.accessibility.AccessibleComponent;
import javax.accessibility.AccessibleTable;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
public class JTableAccessibleGetLocationOnScreen {
private static JFrame frame;
private static JTable table;
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
constructInEDT();
try {
assertGetLocation();
} finally {
frame.dispose();
}
}
});
}
private static void constructInEDT() {
String[] columnNames = { "col1", "col2", };
Object[][] data = { { "row1, col1", "row1, col2" },
{ "row2, col1", "row2, col2" }, };
frame = new JFrame(
"JTable AccessibleTableHeader and AccessibleJTableCell test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
table = new JTable(data, columnNames);
frame.add(table);
frame.pack();
}
private static void assertGetLocation() {
// the frame is now invisible
// test getLocationOnScreen() of
// JTable$AccessibleJTable$AccessibleJTableHeaderCell
// and JTable$AccessibleJTable$AccessibleJTableCell
AccessibleTable accessibleTable = (AccessibleTable) table
.getAccessibleContext();
AccessibleTable header = accessibleTable.getAccessibleColumnHeader();
AccessibleComponent accessibleComp1 = (AccessibleComponent) header
.getAccessibleAt(0, 0);
// getLocation() must be null according to its javadoc and no exception
// is thrown
if (null != accessibleComp1.getLocationOnScreen()) {
throw new RuntimeException(
"JTable$AccessibleJTable$AccessibleJTableHeaderCell."
+ "getLocation() must be null");
}
JComponent.AccessibleJComponent accessibleJComponent =
(JComponent.AccessibleJComponent) table.getAccessibleContext();
AccessibleComponent accessibleComp2 = (AccessibleComponent)
accessibleJComponent.getAccessibleChild(3);
// getLocation() must be null according to its javadoc and no exception
// is thrown
if (null != accessibleComp2.getLocationOnScreen()) {
throw new RuntimeException("JTable$AccessibleJTable$"
+ "AccessibleJTableCell.getLocation() must be null");
}
}
}
/*
* 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 7190813
* @summary Check for extended RPATHs on *nixes
* @compile -XDignore.symbol.file RunpathTest.java
* @run main RunpathTest
* @author ksrini
*/
import java.io.File;
public class RunpathTest extends TestHelper {
final String elfreaderCmd;
RunpathTest() {
elfreaderCmd = findElfReader();
}
final String findElfReader() {
String[] paths = {"/bin", "/sbin", "/usr/bin", "/usr/sbin", "/usr/ccs/bin"};
final String cmd = isSolaris ? "elfdump" : "readelf";
for (String x : paths) {
File p = new File(x);
File e = new File(p, cmd);
if (e.canExecute()) {
return e.getAbsolutePath();
}
}
System.err.println("Warning: no suitable elf reader!");
return null;
}
void elfCheck(String javacmd, String expectedRpath) {
final TestResult tr = doExec(elfreaderCmd, "-d", javacmd);
if (!tr.matches(expectedRpath)) {
System.out.println(tr);
throw new RuntimeException("FAILED: RPATH strings " +
expectedRpath + " not found in " + javaCmd);
}
System.out.println(javacmd + " contains expected RPATHS");
}
void testRpath() {
if (isDualMode && is64Bit) {
String expectedRpath = ".*RPATH.*\\$ORIGIN/../../lib/" + getJreArch()
+ ":\\$ORIGIN/../../jre/lib/" + getJreArch() + ".*";
elfCheck(java64Cmd, expectedRpath);
} else {
String expectedRpath = ".*RPATH.*\\$ORIGIN/../lib/" + getJreArch()
+ ":\\$ORIGIN/../jre/lib/" + getJreArch() + ".*";
elfCheck(javaCmd, expectedRpath);
}
}
public static void main(String... args) throws Exception {
if (isSolaris || isLinux) {
RunpathTest rp = new RunpathTest();
rp.testRpath();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册