Merge
This commit is contained in:
commit
0b0d97c2c0
@ -31,6 +31,7 @@ import java.awt.peer.MenuComponentPeer;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.MenuBarUI;
|
||||
|
||||
import com.apple.laf.ScreenMenuBar;
|
||||
import sun.lwawt.macosx.CMenuBar;
|
||||
|
||||
import com.apple.laf.AquaMenuBarUI;
|
||||
@ -72,12 +73,15 @@ class _AppMenuBarHandler {
|
||||
// scan the current frames, and see if any are foreground
|
||||
final Frame[] frames = Frame.getFrames();
|
||||
for (final Frame frame : frames) {
|
||||
if (frame.isVisible() && !isFrameMinimized(frame)) return;
|
||||
if (frame.isVisible() && !isFrameMinimized(frame)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// if we have no foreground frames, then we have to "kick" the menubar
|
||||
final JFrame pingFrame = new JFrame();
|
||||
pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
|
||||
pingFrame.setUndecorated(true);
|
||||
pingFrame.setVisible(true);
|
||||
pingFrame.toFront();
|
||||
pingFrame.setVisible(false);
|
||||
@ -101,7 +105,6 @@ class _AppMenuBarHandler {
|
||||
// Aqua was not installed
|
||||
throw new IllegalStateException("Application.setDefaultMenuBar() only works with the Aqua Look and Feel");
|
||||
}
|
||||
/* TODO: disabled until ScreenMenuBar is working
|
||||
|
||||
final AquaMenuBarUI aquaUI = (AquaMenuBarUI)ui;
|
||||
final ScreenMenuBar screenMenuBar = aquaUI.getScreenMenuBar();
|
||||
@ -118,8 +121,7 @@ class _AppMenuBarHandler {
|
||||
}
|
||||
|
||||
// grab the pointer to the CMenuBar, and retain it in native
|
||||
nativeSetDefaultMenuBar(((CMenuBar)peer).getNativeMenuBarPeer());
|
||||
*/
|
||||
nativeSetDefaultMenuBar(((CMenuBar)peer).getModel());
|
||||
}
|
||||
|
||||
void setAboutMenuItemVisible(final boolean present) {
|
||||
|
@ -182,7 +182,11 @@ public class CDataTransferer extends DataTransferer {
|
||||
Long format = predefinedClipboardNameMap.get(str);
|
||||
|
||||
if (format == null) {
|
||||
format = new Long(registerFormatWithPasteboard(str));
|
||||
if (java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) {
|
||||
// Do not try to access native system for the unknown format
|
||||
return -1L;
|
||||
}
|
||||
format = registerFormatWithPasteboard(str);
|
||||
predefinedClipboardNameMap.put(str, format);
|
||||
predefinedClipboardFormatMap.put(format, str);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public abstract class CMenuComponent implements MenuComponentPeer {
|
||||
return target;
|
||||
}
|
||||
|
||||
long getModel() {
|
||||
public long getModel() {
|
||||
return modelPtr;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ import com.apple.laf.ClientPropertyApplicator.Property;
|
||||
import com.sun.awt.AWTUtilities;
|
||||
|
||||
public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
|
||||
private native long nativeCreateNSWindow(long nsViewPtr, long styleBits, double x, double y, double w, double h);
|
||||
private native long nativeCreateNSWindow(long nsViewPtr,long ownerPtr, 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);
|
||||
private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);
|
||||
@ -230,7 +230,8 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
contentView = createContentView();
|
||||
contentView.initialize(peer, responder);
|
||||
|
||||
final long nativeWindowPtr = nativeCreateNSWindow(contentView.getAWTView(), styleBits, 0, 0, 0, 0);
|
||||
final long ownerPtr = owner != null ? owner.getNSWindowPtr() : 0L;
|
||||
final long nativeWindowPtr = nativeCreateNSWindow(contentView.getAWTView(), ownerPtr, styleBits, 0, 0, 0, 0);
|
||||
setPtr(nativeWindowPtr);
|
||||
|
||||
if (target instanceof javax.swing.RootPaneContainer) {
|
||||
|
@ -44,6 +44,7 @@
|
||||
jint styleBits;
|
||||
BOOL isEnabled;
|
||||
NSWindow *nsWindow;
|
||||
AWTWindow *ownerWindow;
|
||||
}
|
||||
|
||||
// An instance of either AWTWindow_Normal or AWTWindow_Panel
|
||||
@ -51,12 +52,15 @@
|
||||
|
||||
@property (nonatomic, retain) JNFWeakJObjectWrapper *javaPlatformWindow;
|
||||
@property (nonatomic, retain) CMenuBar *javaMenuBar;
|
||||
@property (nonatomic, retain) AWTWindow *ownerWindow;
|
||||
@property (nonatomic) NSSize javaMinSize;
|
||||
@property (nonatomic) NSSize javaMaxSize;
|
||||
@property (nonatomic) jint styleBits;
|
||||
@property (nonatomic) BOOL isEnabled;
|
||||
|
||||
|
||||
- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)javaPlatformWindow
|
||||
ownerWindow:owner
|
||||
styleBits:(jint)styleBits
|
||||
frameRect:(NSRect)frameRect
|
||||
contentView:(NSView *)contentView;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#import "sun_lwawt_macosx_CPlatformWindow.h"
|
||||
#import "com_apple_eawt_event_GestureHandler.h"
|
||||
#import "com_apple_eawt_FullScreenHandler.h"
|
||||
#import "ApplicationDelegate.h"
|
||||
|
||||
#import "AWTWindow.h"
|
||||
#import "AWTView.h"
|
||||
@ -120,6 +121,7 @@ AWT_NS_WINDOW_IMPLEMENTATION
|
||||
@synthesize javaMaxSize;
|
||||
@synthesize styleBits;
|
||||
@synthesize isEnabled;
|
||||
@synthesize ownerWindow;
|
||||
|
||||
- (void) updateMinMaxSize:(BOOL)resizable {
|
||||
if (resizable) {
|
||||
@ -201,6 +203,7 @@ AWT_NS_WINDOW_IMPLEMENTATION
|
||||
}
|
||||
|
||||
- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)platformWindow
|
||||
ownerWindow:owner
|
||||
styleBits:(jint)bits
|
||||
frameRect:(NSRect)rect
|
||||
contentView:(NSView *)view
|
||||
@ -245,6 +248,7 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
self.isEnabled = YES;
|
||||
self.javaPlatformWindow = platformWindow;
|
||||
self.styleBits = bits;
|
||||
self.ownerWindow = owner;
|
||||
[self setPropertiesForStyleBits:styleBits mask:MASK(_METHOD_PROP_BITMASK)];
|
||||
|
||||
return self;
|
||||
@ -350,7 +354,7 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
[self.javaPlatformWindow setJObject:nil withEnv:env];
|
||||
|
||||
self.nsWindow = nil;
|
||||
|
||||
self.ownerWindow = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@ -539,11 +543,27 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
[AWTToolkit eventCountPlusPlus];
|
||||
AWTWindow *opposite = [AWTWindow lastKeyWindow];
|
||||
if (!IS(self.styleBits, IS_DIALOG)) {
|
||||
[CMenuBar activate:self.javaMenuBar modallyDisabled:NO];
|
||||
} else if ((opposite != NULL) && IS(self.styleBits, IS_MODAL)) {
|
||||
[CMenuBar activate:opposite->javaMenuBar modallyDisabled:YES];
|
||||
|
||||
// Finds appropriate menubar in our hierarchy,
|
||||
AWTWindow *awtWindow = self;
|
||||
while (awtWindow.ownerWindow != nil) {
|
||||
awtWindow = awtWindow.ownerWindow;
|
||||
}
|
||||
|
||||
CMenuBar *menuBar = nil;
|
||||
BOOL isDisabled = NO;
|
||||
if ([awtWindow.nsWindow isVisible]){
|
||||
menuBar = awtWindow.javaMenuBar;
|
||||
isDisabled = !awtWindow.isEnabled;
|
||||
}
|
||||
|
||||
if (menuBar == nil) {
|
||||
menuBar = [[ApplicationDelegate sharedDelegate] defaultMenuBar];
|
||||
isDisabled = NO;
|
||||
}
|
||||
|
||||
[CMenuBar activate:menuBar modallyDisabled:isDisabled];
|
||||
|
||||
[AWTWindow setLastKeyWindow:nil];
|
||||
|
||||
[self _deliverWindowFocusEvent:YES oppositeWindow: opposite];
|
||||
@ -555,6 +575,14 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
[AWTToolkit eventCountPlusPlus];
|
||||
[self.javaMenuBar deactivate];
|
||||
|
||||
// In theory, this might cause flickering if the window gaining focus
|
||||
// has its own menu. However, I couldn't reproduce it on practice, so
|
||||
// perhaps this is a non issue.
|
||||
CMenuBar* defaultMenu = [[ApplicationDelegate sharedDelegate] defaultMenuBar];
|
||||
if (defaultMenu != nil) {
|
||||
[CMenuBar activate:defaultMenu modallyDisabled:NO];
|
||||
}
|
||||
|
||||
// the new key window
|
||||
NSWindow *keyWindow = [NSApp keyWindow];
|
||||
AWTWindow *opposite = nil;
|
||||
@ -741,7 +769,7 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
* Signature: (JJIIII)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeCreateNSWindow
|
||||
(JNIEnv *env, jobject obj, jlong contentViewPtr, jlong styleBits, jdouble x, jdouble y, jdouble w, jdouble h)
|
||||
(JNIEnv *env, jobject obj, jlong contentViewPtr, jlong ownerPtr, jlong styleBits, jdouble x, jdouble y, jdouble w, jdouble h)
|
||||
{
|
||||
__block AWTWindow *window = nil;
|
||||
|
||||
@ -750,10 +778,11 @@ JNF_COCOA_ENTER(env);
|
||||
JNFWeakJObjectWrapper *platformWindow = [JNFWeakJObjectWrapper wrapperWithJObject:obj withEnv:env];
|
||||
NSView *contentView = OBJC(contentViewPtr);
|
||||
NSRect frameRect = NSMakeRect(x, y, w, h);
|
||||
|
||||
AWTWindow *owner = [OBJC(ownerPtr) delegate];
|
||||
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
|
||||
|
||||
window = [[AWTWindow alloc] initWithPlatformWindow:platformWindow
|
||||
ownerWindow:owner
|
||||
styleBits:styleBits
|
||||
frameRect:frameRect
|
||||
contentView:contentView];
|
||||
@ -818,11 +847,19 @@ JNF_COCOA_ENTER(env);
|
||||
|
||||
AWTWindow *window = (AWTWindow*)[nsWindow delegate];
|
||||
|
||||
if ([nsWindow isKeyWindow]) [window.javaMenuBar deactivate];
|
||||
if ([nsWindow isKeyWindow]) {
|
||||
[window.javaMenuBar deactivate];
|
||||
}
|
||||
|
||||
window.javaMenuBar = menuBar;
|
||||
|
||||
CMenuBar* actualMenuBar = menuBar;
|
||||
if (actualMenuBar == nil) {
|
||||
actualMenuBar = [[ApplicationDelegate sharedDelegate] defaultMenuBar];
|
||||
}
|
||||
|
||||
if ([nsWindow isKeyWindow]) {
|
||||
[CMenuBar activate:window.javaMenuBar modallyDisabled:NO];
|
||||
[CMenuBar activate:actualMenuBar modallyDisabled:NO];
|
||||
}
|
||||
}];
|
||||
|
||||
|
@ -63,7 +63,7 @@ static BOOL sSetupHelpMenu = NO;
|
||||
if (excludingAppleMenu && ![currMenu isJavaMenu]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
[currItem setSubmenu:nil];
|
||||
[theMainMenu removeItemAtIndex:index];
|
||||
}
|
||||
|
||||
@ -154,7 +154,10 @@ static BOOL sSetupHelpMenu = NO;
|
||||
// Clean up extra items
|
||||
NSUInteger removedIndex, removedCount = [removedMenuArray count];
|
||||
for (removedIndex=removedCount; removedIndex > 0; removedIndex--) {
|
||||
[theMainMenu removeItemAtIndex:[[removedMenuArray objectAtIndex:(removedIndex-1)] integerValue]];
|
||||
NSUInteger index = [[removedMenuArray objectAtIndex:(removedIndex-1)] integerValue];
|
||||
NSMenuItem *currItem = [theMainMenu itemAtIndex:index];
|
||||
[currItem setSubmenu:nil];
|
||||
[theMainMenu removeItemAtIndex:index];
|
||||
}
|
||||
|
||||
i = cmenuIndex;
|
||||
|
@ -70,9 +70,15 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
JNF_COCOA_ENTER(env);
|
||||
|
||||
// If we are called as a result of user pressing a shorcut, do nothing,
|
||||
// If we are called as a result of user pressing a shortcut, do nothing,
|
||||
// because AVTView has already sent corresponding key event to the Java
|
||||
// layer from performKeyEquivalent
|
||||
// layer from performKeyEquivalent.
|
||||
// There is an exception from the rule above, though: if a window with
|
||||
// a menu gets minimized by user and there are no other windows to take
|
||||
// focus, the window's menu won't be removed from the global menu bar.
|
||||
// However, the Java layer won't handle invocation by a shortcut coming
|
||||
// from this "frameless" menu, because there are no active windows. This
|
||||
// means we have to handle it here.
|
||||
NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
|
||||
if ([currEvent type] == NSKeyDown) {
|
||||
NSString *menuKey = [sender keyEquivalent];
|
||||
@ -91,7 +97,8 @@ JNF_COCOA_ENTER(env);
|
||||
eventKey = [NSString stringWithCharacters: &newChar length: 1];
|
||||
}
|
||||
|
||||
if ([menuKey isEqualToString:eventKey]) {
|
||||
NSWindow *keyWindow = [NSApp keyWindow];
|
||||
if ([menuKey isEqualToString:eventKey] && keyWindow != nil) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -499,7 +499,8 @@ public class WindowsComboBoxUI extends BasicComboBoxUI {
|
||||
|
||||
public void setItem(Object item) {
|
||||
super.setItem(item);
|
||||
if (editor.hasFocus()) {
|
||||
Object focus = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
|
||||
if ((focus == editor) || (focus == editor.getParent())) {
|
||||
editor.selectAll();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 1997, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2013, 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
|
||||
@ -26,7 +26,7 @@ package java.awt;
|
||||
|
||||
|
||||
/**
|
||||
* Signals that an Absract Window Toolkit exception has occurred.
|
||||
* Signals that an Abstract Window Toolkit exception has occurred.
|
||||
*
|
||||
* @author Arthur van Hoff
|
||||
*/
|
||||
|
@ -1149,9 +1149,10 @@ public class JFileChooser extends JComponent implements Accessible {
|
||||
int index = filters.indexOf(f);
|
||||
if (index >= 0) {
|
||||
if(getFileFilter() == f) {
|
||||
if (isAcceptAllFileFilterUsed()) {
|
||||
FileFilter aaff = getAcceptAllFileFilter();
|
||||
if (isAcceptAllFileFilterUsed() && (aaff != f)) {
|
||||
// choose default filter if it is used
|
||||
setFileFilter(getAcceptAllFileFilter());
|
||||
setFileFilter(aaff);
|
||||
}
|
||||
else if (index > 0) {
|
||||
// choose the first filter, because it is not removed
|
||||
|
@ -344,7 +344,8 @@ public class SynthTreeUI extends BasicTreeUI
|
||||
configureRenderer(cellContext);
|
||||
while (!done && paintingEnumerator.hasMoreElements()) {
|
||||
path = (TreePath)paintingEnumerator.nextElement();
|
||||
if (path != null) {
|
||||
bounds = getPathBounds(tree, path);
|
||||
if ((path != null) && (bounds != null)) {
|
||||
isLeaf = treeModel.isLeaf(path.getLastPathComponent());
|
||||
if (isLeaf) {
|
||||
isExpanded = hasBeenExpanded = false;
|
||||
@ -353,7 +354,6 @@ public class SynthTreeUI extends BasicTreeUI
|
||||
isExpanded = treeState.getExpandedState(path);
|
||||
hasBeenExpanded = tree.hasBeenExpanded(path);
|
||||
}
|
||||
bounds = getPathBounds(tree, path);
|
||||
rowBounds.y = bounds.y;
|
||||
rowBounds.height = bounds.height;
|
||||
paintRow(renderer, dtcr, context, cellContext, g,
|
||||
@ -383,7 +383,8 @@ public class SynthTreeUI extends BasicTreeUI
|
||||
paintingEnumerator = treeState.getVisiblePathsFrom(initialPath);
|
||||
while (!done && paintingEnumerator.hasMoreElements()) {
|
||||
path = (TreePath)paintingEnumerator.nextElement();
|
||||
if (path != null) {
|
||||
bounds = getPathBounds(tree, path);
|
||||
if ((path != null) && (bounds != null)) {
|
||||
isLeaf = treeModel.isLeaf(path.getLastPathComponent());
|
||||
if (isLeaf) {
|
||||
isExpanded = hasBeenExpanded = false;
|
||||
@ -392,7 +393,6 @@ public class SynthTreeUI extends BasicTreeUI
|
||||
isExpanded = treeState.getExpandedState(path);
|
||||
hasBeenExpanded = tree.hasBeenExpanded(path);
|
||||
}
|
||||
bounds = getPathBounds(tree, path);
|
||||
// See if the vertical line to the parent has been drawn.
|
||||
parentPath = path.getParentPath();
|
||||
if (parentPath != null) {
|
||||
|
@ -29,12 +29,18 @@ import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.ContainerEvent;
|
||||
import java.awt.event.ContainerListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.security.AccessController;
|
||||
|
||||
import javax.swing.JLayeredPane;
|
||||
@ -80,6 +86,8 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
|
||||
private boolean copyBufferEnabled;
|
||||
private int[] copyBuffer;
|
||||
|
||||
private PropertyChangeListener layoutSizeListener;
|
||||
|
||||
/**
|
||||
* Constructs a new, initially invisible {@code JLightweightFrame}
|
||||
* instance.
|
||||
@ -94,6 +102,23 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
|
||||
if (getGraphicsConfiguration().isTranslucencyCapable()) {
|
||||
setBackground(new Color(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
layoutSizeListener = new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
Dimension d = (Dimension)e.getNewValue();
|
||||
|
||||
if ("preferredSize".equals(e.getPropertyName())) {
|
||||
content.preferredSizeChanged(d.width, d.height);
|
||||
|
||||
} else if ("maximumSize".equals(e.getPropertyName())) {
|
||||
content.maximumSizeChanged(d.width, d.height);
|
||||
|
||||
} else if ("minimumSize".equals(e.getPropertyName())) {
|
||||
content.minimumSizeChanged(d.width, d.height);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,10 +129,23 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
|
||||
*
|
||||
* @param content the {@link LightweightContent} instance
|
||||
*/
|
||||
public void setContent(LightweightContent content) {
|
||||
public void setContent(final LightweightContent content) {
|
||||
if (content == null) {
|
||||
System.err.println("JLightweightFrame.setContent: content may not be null!");
|
||||
return;
|
||||
}
|
||||
this.content = content;
|
||||
this.component = content.getComponent();
|
||||
|
||||
Dimension d = this.component.getPreferredSize();
|
||||
content.preferredSizeChanged(d.width, d.height);
|
||||
|
||||
d = this.component.getMaximumSize();
|
||||
content.maximumSizeChanged(d.width, d.height);
|
||||
|
||||
d = this.component.getMinimumSize();
|
||||
content.minimumSizeChanged(d.width, d.height);
|
||||
|
||||
initInterior();
|
||||
}
|
||||
|
||||
@ -202,6 +240,25 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
|
||||
contentPane.setLayout(new BorderLayout());
|
||||
contentPane.add(component);
|
||||
setContentPane(contentPane);
|
||||
|
||||
contentPane.addContainerListener(new ContainerListener() {
|
||||
@Override
|
||||
public void componentAdded(ContainerEvent e) {
|
||||
Component c = JLightweightFrame.this.component;
|
||||
if (e.getChild() == c) {
|
||||
c.addPropertyChangeListener("preferredSize", layoutSizeListener);
|
||||
c.addPropertyChangeListener("maximumSize", layoutSizeListener);
|
||||
c.addPropertyChangeListener("minimumSize", layoutSizeListener);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void componentRemoved(ContainerEvent e) {
|
||||
Component c = JLightweightFrame.this.component;
|
||||
if (e.getChild() == c) {
|
||||
c.removePropertyChangeListener(layoutSizeListener);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -161,4 +161,22 @@ public interface LightweightContent {
|
||||
* application that the frame has ungrabbed focus.
|
||||
*/
|
||||
public void focusUngrabbed();
|
||||
|
||||
/**
|
||||
* {@code JLightweightFrame} calls this method to notify the client
|
||||
* application that the content preferred size has changed.
|
||||
*/
|
||||
public void preferredSizeChanged(int width, int height);
|
||||
|
||||
/**
|
||||
* {@code JLightweightFrame} calls this method to notify the client
|
||||
* application that the content maximum size has changed.
|
||||
*/
|
||||
public void maximumSizeChanged(int width, int height);
|
||||
|
||||
/**
|
||||
* {@code JLightweightFrame} calls this method to notify the client
|
||||
* application that the content minimum size has changed.
|
||||
*/
|
||||
public void minimumSizeChanged(int width, int height);
|
||||
}
|
||||
|
119
jdk/test/javax/swing/JComboBox/8015300/Test8015300.java
Normal file
119
jdk/test/javax/swing/JComboBox/8015300/Test8015300.java
Normal file
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import com.sun.java.swing.plaf.windows.WindowsComboBoxUI.WindowsComboBoxEditor;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import javax.swing.ComboBoxEditor;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.UIManager;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import static javax.swing.SwingUtilities.invokeAndWait;
|
||||
import static javax.swing.SwingUtilities.windowForComponent;
|
||||
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8015300
|
||||
* @summary Tests that editable combobox select all text
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
public class Test8015300 {
|
||||
private static final SunToolkit STK = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
private static final String[] ITEMS = {
|
||||
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
|
||||
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
|
||||
|
||||
private static JComboBox<String> combo;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
UIManager.LookAndFeelInfo[] array = UIManager.getInstalledLookAndFeels();
|
||||
for (UIManager.LookAndFeelInfo info : array) {
|
||||
UIManager.setLookAndFeel(info.getClassName());
|
||||
System.err.println("L&F: " + info.getName());
|
||||
invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
combo = new JComboBox<>(ITEMS);
|
||||
combo.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent event) {
|
||||
if (ItemEvent.SELECTED == event.getStateChange() && combo.isEditable()) {
|
||||
ComboBoxEditor editor = combo.getEditor();
|
||||
Object component = editor.getEditorComponent();
|
||||
if (component instanceof JTextField) {
|
||||
JTextField text = (JTextField) component;
|
||||
boolean selected = null != text.getSelectedText();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(" - ").append(combo.getSelectedIndex());
|
||||
sb.append(": ").append(event.getItem());
|
||||
if (selected) {
|
||||
sb.append("; selected");
|
||||
}
|
||||
System.err.println(sb);
|
||||
if ((editor instanceof WindowsComboBoxEditor) == (null == text.getSelectedText())) {
|
||||
throw new Error("unexpected state of text selection");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
JFrame frame = new JFrame(getClass().getSimpleName());
|
||||
frame.add(combo);
|
||||
frame.pack();
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
for (int i = 0; i < ITEMS.length; ++i) {
|
||||
select(i, true);
|
||||
select(1, false);
|
||||
}
|
||||
invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
windowForComponent(combo).dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static void select(final int index, final boolean editable) throws Exception {
|
||||
invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
combo.setEditable(editable);
|
||||
combo.setSelectedIndex(index);
|
||||
}
|
||||
});
|
||||
STK.realSync();
|
||||
Thread.sleep(50L);
|
||||
}
|
||||
}
|
98
jdk/test/javax/swing/plaf/synth/Test8015926.java
Normal file
98
jdk/test/javax/swing/plaf/synth/Test8015926.java
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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 8015926
|
||||
* @summary Tests that there are no NPE during painting
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.event.TreeModelEvent;
|
||||
import javax.swing.event.TreeModelListener;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
|
||||
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
|
||||
|
||||
public class Test8015926 implements TreeModelListener, Runnable, Thread.UncaughtExceptionHandler {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
|
||||
SwingUtilities.invokeAndWait(new Test8015926());
|
||||
Thread.sleep(1000L);
|
||||
}
|
||||
|
||||
private JTree tree;
|
||||
|
||||
@Override
|
||||
public void treeStructureChanged(TreeModelEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void treeNodesRemoved(TreeModelEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void treeNodesInserted(TreeModelEvent event) {
|
||||
this.tree.expandPath(event.getTreePath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void treeNodesChanged(TreeModelEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Thread.currentThread().setUncaughtExceptionHandler(this);
|
||||
|
||||
DefaultMutableTreeNode root = new DefaultMutableTreeNode();
|
||||
DefaultMutableTreeNode child = new DefaultMutableTreeNode("Child");
|
||||
DefaultTreeModel model = new DefaultTreeModel(root);
|
||||
|
||||
this.tree = new JTree();
|
||||
this.tree.setModel(model);
|
||||
|
||||
JFrame frame = new JFrame(getClass().getSimpleName());
|
||||
frame.add(this.tree);
|
||||
|
||||
model.addTreeModelListener(this); // frame is not visible yet
|
||||
model.insertNodeInto(child, root, root.getChildCount());
|
||||
model.removeNodeFromParent(child);
|
||||
|
||||
frame.setSize(640, 480);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable exception) {
|
||||
exception.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user