--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java Tue Feb 14 14:16:49 2012 -0800
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java Wed Feb 15 15:21:33 2012 -0800
@@ -137,6 +137,11 @@
g.setColor(progressBar.getForeground());
barRectHeight -= 2;
barRectWidth -= 2;
+
+ if (barRectWidth <= 0 || barRectHeight <= 0) {
+ return;
+ }
+
Graphics2D g2 = (Graphics2D)g;
g2.setStroke(new BasicStroke((float)(vertical ? barRectWidth : barRectHeight),
BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
--- a/jdk/src/share/classes/java/awt/List.java Tue Feb 14 14:16:49 2012 -0800
+++ b/jdk/src/share/classes/java/awt/List.java Wed Feb 15 15:21:33 2012 -0800
@@ -115,7 +115,7 @@
* @see #addItem(String)
* @see #getItem(int)
*/
- Vector items = new Vector();
+ Vector<String> items = new Vector<>();
/**
* This field will represent the number of visible rows in the
@@ -306,7 +306,7 @@
// to insure that it cannot be overridden by client subclasses.
// DO NOT INVOKE CLIENT CODE ON THIS THREAD!
final String getItemImpl(int index) {
- return (String)items.elementAt(index);
+ return items.elementAt(index);
}
/**
@@ -415,7 +415,7 @@
if (peer != null) {
peer.removeAll();
}
- items = new Vector();
+ items = new Vector<>();
selected = new int[0];
}
@@ -490,9 +490,9 @@
public synchronized int[] getSelectedIndexes() {
ListPeer peer = (ListPeer)this.peer;
if (peer != null) {
- selected = ((ListPeer)peer).getSelectedIndexes();
+ selected = peer.getSelectedIndexes();
}
- return (int[])selected.clone();
+ return selected.clone();
}
/**
@@ -908,7 +908,7 @@
* @since 1.4
*/
public synchronized ItemListener[] getItemListeners() {
- return (ItemListener[])(getListeners(ItemListener.class));
+ return getListeners(ItemListener.class);
}
/**
@@ -975,7 +975,7 @@
* @since 1.4
*/
public synchronized ActionListener[] getActionListeners() {
- return (ActionListener[])(getListeners(ActionListener.class));
+ return getListeners(ActionListener.class);
}
/**
--- a/jdk/src/share/classes/java/awt/Window.java Tue Feb 14 14:16:49 2012 -0800
+++ b/jdk/src/share/classes/java/awt/Window.java Wed Feb 15 15:21:33 2012 -0800
@@ -398,10 +398,10 @@
initIDs();
}
- String s = (String) java.security.AccessController.doPrivileged(
+ String s = java.security.AccessController.doPrivileged(
new GetPropertyAction("java.awt.syncLWRequests"));
systemSyncLWRequests = (s != null && s.equals("true"));
- s = (String) java.security.AccessController.doPrivileged(
+ s = java.security.AccessController.doPrivileged(
new GetPropertyAction("java.awt.Window.locationByPlatform"));
locationByPlatformProp = (s != null && s.equals("true"));
}
@@ -1378,7 +1378,7 @@
// make sure the privileged action is only
// for getting the property! We don't want the
// above checkTopLevelWindow call to always succeed!
- warningString = (String) AccessController.doPrivileged(
+ warningString = AccessController.doPrivileged(
new GetPropertyAction("awt.appletWarning",
"Java Applet Window"));
}
--- a/jdk/src/share/classes/java/awt/color/ICC_Profile.java Tue Feb 14 14:16:49 2012 -0800
+++ b/jdk/src/share/classes/java/awt/color/ICC_Profile.java Wed Feb 15 15:21:33 2012 -0800
@@ -921,9 +921,9 @@
*/
private static ICC_Profile getStandardProfile(final String name) {
- return (ICC_Profile) AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
+ return AccessController.doPrivileged(
+ new PrivilegedAction<ICC_Profile>() {
+ public ICC_Profile run() {
ICC_Profile p = null;
try {
p = getInstance (name);
--- a/jdk/src/share/classes/java/awt/event/InputEvent.java Tue Feb 14 14:16:49 2012 -0800
+++ b/jdk/src/share/classes/java/awt/event/InputEvent.java Wed Feb 15 15:21:33 2012 -0800
@@ -321,14 +321,15 @@
* @param when a long int that gives the time the event occurred.
* Passing negative or zero value
* is not recommended
- * @param modifiers the modifier keys down during event (e.g. shift, ctrl,
- * alt, meta)
- * Passing negative parameter is not recommended.
- * Zero value means no modifiers.
- * Either extended _DOWN_MASK or old _MASK modifiers
- * should be used, but both models should not be mixed
- * in one event. Use of the extended modifiers is
- * preferred
+ * @param modifiers a modifier mask describing the modifier keys and mouse
+ * buttons (for example, shift, ctrl, alt, and meta) that
+ * are down during the event.
+ * Only extended modifiers are allowed to be used as a
+ * value for this parameter (see the {@link InputEvent#getModifiersEx}
+ * class for the description of extended modifiers).
+ * Passing negative parameter
+ * is not recommended.
+ * Zero value means that no modifiers were passed
* @throws IllegalArgumentException if <code>source</code> is null
* @see #getSource()
* @see #getID()
@@ -416,9 +417,13 @@
/**
* Returns the extended modifier mask for this event.
+ * <P>
+ * Extended modifiers are the modifiers that ends with the _DOWN_MASK suffix,
+ * such as ALT_DOWN_MASK, BUTTON1_DOWN_MASK, and others.
+ * <P>
* Extended modifiers represent the state of all modal keys,
* such as ALT, CTRL, META, and the mouse buttons just after
- * the event occurred
+ * the event occurred.
* <P>
* For example, if the user presses <b>button 1</b> followed by
* <b>button 2</b>, and then releases them in the same order,
--- a/jdk/src/share/classes/java/awt/event/MouseEvent.java Tue Feb 14 14:16:49 2012 -0800
+++ b/jdk/src/share/classes/java/awt/event/MouseEvent.java Wed Feb 15 15:21:33 2012 -0800
@@ -488,14 +488,15 @@
* @param when A long integer that gives the time the event occurred.
* Passing negative or zero value
* is not recommended
- * @param modifiers The modifier keys down during event (e.g. shift, ctrl,
- * alt, meta)
+ * @param modifiers a modifier mask describing the modifier keys and mouse
+ * buttons (for example, shift, ctrl, alt, and meta) that
+ * are down during the event.
+ * Only extended modifiers are allowed to be used as a
+ * value for this parameter (see the {@link InputEvent#getModifiersEx}
+ * class for the description of extended modifiers).
* Passing negative parameter
* is not recommended.
- * Zero value means that no modifiers were passed.
- * Use either an extended _DOWN_MASK or old _MASK modifiers,
- * however do not mix models in the one event.
- * The extended modifiers are preferred for using
+ * Zero value means that no modifiers were passed
* @param x The horizontal x coordinate for the mouse location.
* It is allowed to pass negative values
* @param y The vertical y coordinate for the mouse location.
@@ -586,14 +587,15 @@
* @param when A long integer that gives the time the event occurred.
* Passing negative or zero value
* is not recommended
- * @param modifiers The modifier keys down during event (e.g. shift, ctrl,
- * alt, meta)
+ * @param modifiers a modifier mask describing the modifier keys and mouse
+ * buttons (for example, shift, ctrl, alt, and meta) that
+ * are down during the event.
+ * Only extended modifiers are allowed to be used as a
+ * value for this parameter (see the {@link InputEvent#getModifiersEx}
+ * class for the description of extended modifiers).
* Passing negative parameter
* is not recommended.
- * Zero value means that no modifiers were passed.
- * Use either an extended _DOWN_MASK or old _MASK modifiers,
- * however do not mix models in the one event.
- * The extended modifiers are preferred for using
+ * Zero value means that no modifiers were passed
* @param x The horizontal x coordinate for the mouse location.
* It is allowed to pass negative values
* @param y The vertical y coordinate for the mouse location.
@@ -657,14 +659,15 @@
* @param when A long integer that gives the time the event occurred.
* Passing negative or zero value
* is not recommended
- * @param modifiers The modifier keys down during event (e.g. shift, ctrl,
- * alt, meta)
+ * @param modifiers a modifier mask describing the modifier keys and mouse
+ * buttons (for example, shift, ctrl, alt, and meta) that
+ * are down during the event.
+ * Only extended modifiers are allowed to be used as a
+ * value for this parameter (see the {@link InputEvent#getModifiersEx}
+ * class for the description of extended modifiers).
* Passing negative parameter
* is not recommended.
- * Zero value means that no modifiers were passed.
- * Use either an extended _DOWN_MASK or old _MASK modifiers,
- * however do not mix models in the one event.
- * The extended modifiers are preferred for using
+ * Zero value means that no modifiers were passed
* @param x The horizontal x coordinate for the mouse location.
* It is allowed to pass negative values
* @param y The vertical y coordinate for the mouse location.
--- a/jdk/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java Tue Feb 14 14:16:49 2012 -0800
+++ b/jdk/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java Wed Feb 15 15:21:33 2012 -0800
@@ -180,8 +180,7 @@
if (severity == null) {
throw new NullPointerException("severity is null");
}
- return super.put((PrinterStateReason) reason,
- (Severity) severity);
+ return super.put(reason, severity);
}
/**
--- a/jdk/src/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java Tue Feb 14 14:16:49 2012 -0800
+++ b/jdk/src/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java Wed Feb 15 15:21:33 2012 -0800
@@ -141,7 +141,7 @@
* Returns the string table for class ReferenceUriSchemesSupported.
*/
protected String[] getStringTable() {
- return (String[])myStringTable.clone();
+ return myStringTable.clone();
}
/**
--- a/jdk/src/share/classes/javax/swing/JOptionPane.java Tue Feb 14 14:16:49 2012 -0800
+++ b/jdk/src/share/classes/javax/swing/JOptionPane.java Wed Feb 15 15:21:33 2012 -0800
@@ -34,7 +34,6 @@
import java.awt.Frame;
import java.awt.Point;
import java.awt.HeadlessException;
-import java.awt.Toolkit;
import java.awt.Window;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -994,8 +993,7 @@
// if the user closed the window without selecting a button
// (newValue = null in that case). Otherwise, close the dialog.
if (dialog.isVisible() && event.getSource() == JOptionPane.this &&
- (event.getPropertyName().equals(VALUE_PROPERTY) ||
- event.getPropertyName().equals(INPUT_VALUE_PROPERTY)) &&
+ (event.getPropertyName().equals(VALUE_PROPERTY)) &&
event.getNewValue() != null &&
event.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) {
dialog.setVisible(false);
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java Tue Feb 14 14:16:49 2012 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java Wed Feb 15 15:21:33 2012 -0800
@@ -1236,6 +1236,7 @@
int index = list.locationToIndex(e.getPoint());
optionPane.setInputValue(list.getModel().getElementAt(index));
+ optionPane.setValue(JOptionPane.OK_OPTION);
}
}
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java Tue Feb 14 14:16:49 2012 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java Wed Feb 15 15:21:33 2012 -0800
@@ -434,6 +434,8 @@
// Empty out the renderer pane, allowing renderers to be gc'ed.
rendererPane.removeAll();
+
+ paintContext = null;
}
private void configureRenderer(SynthContext context) {
--- a/jdk/src/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java Tue Feb 14 14:16:49 2012 -0800
+++ b/jdk/src/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java Wed Feb 15 15:21:33 2012 -0800
@@ -156,7 +156,7 @@
protected Color borderSelectionColor;
private boolean isDropCell;
- private boolean fillBackground = true;
+ private boolean fillBackground;
/**
* Set to true after the constructor has run.
--- a/jdk/src/share/classes/sun/beans/infos/ComponentBeanInfo.java Tue Feb 14 14:16:49 2012 -0800
+++ b/jdk/src/share/classes/sun/beans/infos/ComponentBeanInfo.java Wed Feb 15 15:21:33 2012 -0800
@@ -32,7 +32,7 @@
*/
public class ComponentBeanInfo extends SimpleBeanInfo {
- private static final Class beanClass = java.awt.Component.class;
+ private static final Class<java.awt.Component> beanClass = java.awt.Component.class;
public PropertyDescriptor[] getPropertyDescriptors() {
try {
--- a/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c Tue Feb 14 14:16:49 2012 -0800
+++ b/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c Wed Feb 15 15:21:33 2012 -0800
@@ -171,6 +171,53 @@
return array;
}
+/**
+ * Convert a GSList to an array of filenames (with the parent folder)
+ */
+static jobjectArray toPathAndFilenamesArray(JNIEnv *env, GSList* list)
+{
+ jstring str;
+ jclass stringCls;
+ GSList *iterator;
+ jobjectArray array;
+ int i;
+ char* entry;
+
+
+ if (list == NULL) {
+ return NULL;
+ }
+
+ stringCls = (*env)->FindClass(env, "java/lang/String");
+ if (stringCls == NULL) {
+ JNU_ThrowInternalError(env, "Could not get java.lang.String class");
+ return NULL;
+ }
+
+ array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls,
+ NULL);
+ if (array == NULL) {
+ JNU_ThrowInternalError(env, "Could not instantiate array files array");
+ return NULL;
+ }
+
+ i = 0;
+ for (iterator = list; iterator; iterator = iterator->next) {
+ entry = (char*) iterator->data;
+
+ //check for leading slash.
+ if (entry[0] == '/') {
+ entry++;
+ }
+
+ str = (*env)->NewStringUTF(env, entry);
+ (*env)->SetObjectArrayElement(env, array, i, str);
+ i++;
+ }
+
+ return array;
+}
+
static void handle_response(GtkWidget* aDialog, gint responseId, gpointer obj)
{
JNIEnv *env;
@@ -183,16 +230,25 @@
env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
current_folder = NULL;
filenames = NULL;
+ gboolean full_path_names = FALSE;
if (responseId == GTK_RESPONSE_ACCEPT) {
current_folder = fp_gtk_file_chooser_get_current_folder(
GTK_FILE_CHOOSER(aDialog));
+ if (current_folder == NULL) {
+ full_path_names = TRUE;
+ }
filenames = fp_gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(aDialog));
}
-
- jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
- jfilenames = toFilenamesArray(env, filenames);
-
+ if (full_path_names) {
+ //This is a hack for use with "Recent Folders" in gtk where each
+ //file could have its own directory.
+ jcurrent_folder = (*env)->NewStringUTF(env, "/");
+ jfilenames = toPathAndFilenamesArray(env, filenames);
+ } else {
+ jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
+ jfilenames = toFilenamesArray(env, filenames);
+ }
(*env)->CallVoidMethod(env, obj, setFileInternalMethodID, jcurrent_folder,
jfilenames);
fp_g_free(current_folder);
--- a/jdk/test/java/awt/Choice/ChoiceMouseWheelTest/ChoiceMouseWheelTest.java Tue Feb 14 14:16:49 2012 -0800
+++ b/jdk/test/java/awt/Choice/ChoiceMouseWheelTest/ChoiceMouseWheelTest.java Wed Feb 15 15:21:33 2012 -0800
@@ -96,7 +96,10 @@
// Test mouse wheel over the choice
String name = Toolkit.getDefaultToolkit().getClass().getName();
- if(!name.equals("sun.awt.X11.XToolkit")) { // mouse wheel doesn't work for the choice on X11, so skip it
+
+ // mouse wheel doesn't work for the choice on X11 and Mac, so skip it
+ if(!name.equals("sun.awt.X11.XToolkit")
+ && !name.equals("sun.lwawt.macosx.LWCToolkit")) {
robot.mouseWheel(1);
Util.waitForIdle(robot);
--- a/jdk/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java Tue Feb 14 14:16:49 2012 -0800
+++ b/jdk/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java Wed Feb 15 15:21:33 2012 -0800
@@ -54,9 +54,12 @@
Util.clickOnComp(frame.button, robot);
}
- frame.panel.stop();
+ boolean ret = frame.panel.stop();
frame.dispose();
+ if (!ret) {
+ throw new RuntimeException("Test failed!");
+ }
System.out.println("Test passed.");
}
@@ -140,17 +143,19 @@
}
}
- public void stop() {
+ public boolean stop() {
active = false;
try {
- synchronized (sync) {
- sync.notify();
- }
- synchronized (thread) {
- thread.wait();
+ sync();
+ thread.join(1000);
+ if (thread.isAlive()) {
+ thread.interrupt();
+ return false;
}
} catch (InterruptedException ex) {
+ return false;
}
+ return true;
}
public void draw() {
--- a/jdk/test/javax/swing/JFileChooser/6396844/TwentyThousandTest.java Tue Feb 14 14:16:49 2012 -0800
+++ b/jdk/test/javax/swing/JFileChooser/6396844/TwentyThousandTest.java Wed Feb 15 15:21:33 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 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
@@ -26,28 +26,29 @@
* @bug 6396844
* @summary Tests memory leak for 20000 files
* @author Sergey Malenkov
- * @run main/othervm/timeout=1000 -mx256m TwentyThousandTest
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main/othervm/timeout=1000 -mx128m TwentyThousandTest
*/
+import sun.java2d.Disposer;
+import sun.java2d.DisposerRecord;
+
import javax.swing.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
import java.io.File;
import java.io.FileWriter;
-public class TwentyThousandTest implements ActionListener, Runnable {
+public class TwentyThousandTest {
private static final int FILES = 20000;
- private static final int ATTEMPTS = 100;
+ private static final int ATTEMPTS = 20;
private static final int INTERVAL = 100;
- private static final boolean ALWAYS_NEW_INSTANCE = false;
- private static final boolean UPDATE_UI_EACH_INTERVAL = true;
- private static final boolean AUTO_CLOSE_DIALOG = true;
+ private static String tmpDir;
- private static JFileChooser CHOOSER;
-
- private static String tmpDir;
+ private static volatile boolean disposerComplete;
public static void main(String[] args) throws Exception {
tmpDir = System.getProperty("java.io.tmpdir");
@@ -77,15 +78,13 @@
System.out.println("Do " + ATTEMPTS + " attempts for " + laf.getClassName());
- for ( int i = 0; i < ATTEMPTS; i++ ) {
+ for (int i = 0; i < ATTEMPTS; i++) {
System.out.print(i + " ");
doAttempt();
}
System.out.println();
-
- CHOOSER = null;
}
System.out.println("Removing " + FILES + " files");
@@ -94,7 +93,7 @@
getTempFile(i).delete();
}
- System.out.println( "Test passed successfully" );
+ System.out.println("Test passed successfully");
}
private static File getTempFile(int i) {
@@ -104,48 +103,55 @@
private static void doAttempt() throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
- if ( ALWAYS_NEW_INSTANCE || ( CHOOSER == null ) )
- CHOOSER = new JFileChooser(tmpDir);
+ final JFileChooser chooser = new JFileChooser(tmpDir);
+
+ chooser.updateUI();
- if ( UPDATE_UI_EACH_INTERVAL )
- CHOOSER.updateUI();
+ // Postpone JFileChooser closing until it becomes visible
+ chooser.addHierarchyListener(new HierarchyListener() {
+ @Override
+ public void hierarchyChanged(HierarchyEvent e) {
+ if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
+ if (chooser.isShowing()) {
+ Thread thread = new Thread(new Runnable() {
+ public void run() {
+ try {
+ Thread.sleep(INTERVAL);
- if ( AUTO_CLOSE_DIALOG ) {
- Thread t = new Thread( new TwentyThousandTest( CHOOSER ) );
- t.start();
- CHOOSER.showOpenDialog( null );
- } else {
- CHOOSER.showOpenDialog( null );
- }
+ // Close JFileChooser
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ chooser.cancelSelection();
+ }
+ });
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+
+ thread.start();
+ }
+ }
+ }
+ });
+
+ chooser.showOpenDialog(null);
}
});
- // Allow to collect garbage by GC
- Thread.sleep(1000);
-
- System.gc();
- }
-
- private final JFileChooser chooser;
-
- TwentyThousandTest( JFileChooser chooser ) {
- this.chooser = chooser;
- }
+ DisposerRecord disposerRecord = new DisposerRecord() {
+ public void dispose() {
+ disposerComplete = true;
+ }
+ };
- public void run() {
- while ( !this.chooser.isShowing() ) {
- try {
- Thread.sleep( 30 );
- } catch ( InterruptedException exception ) {
- exception.printStackTrace();
- }
+ disposerComplete = false;
+
+ Disposer.addRecord(new Object(), disposerRecord);
+
+ while (!disposerComplete) {
+ Util.generateOOME();
}
- Timer timer = new Timer( INTERVAL, this );
- timer.setRepeats( false );
- timer.start();
- }
-
- public void actionPerformed( ActionEvent event ) {
- this.chooser.cancelSelection();
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JOptionPane/7138665/bug7138665.java Wed Feb 15 15:21:33 2012 -0800
@@ -0,0 +1,70 @@
+/*
+ * 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 7138665
+ @summary JOptionPane.getValue() unexpected change between JRE 1.6 and JRE 1.7
+ @author Pavel Porvatov
+*/
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+
+public class bug7138665 {
+ public static void main(String[] args) throws Exception {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ JOptionPane pane = new JOptionPane("Enter value", JOptionPane.QUESTION_MESSAGE,
+ JOptionPane.OK_CANCEL_OPTION, null, null, null);
+ pane.setWantsInput(true);
+
+ JDialog dialog = pane.createDialog(null, "My Dialog");
+ dialog.setVisible(true);
+
+ Object result = pane.getValue();
+
+ if (result == null || ((Integer) result).intValue() != JOptionPane.OK_OPTION) {
+ throw new RuntimeException("Invalid result: " + result);
+ }
+
+ System.out.println("Test bug7138665 passed");
+ }
+ });
+
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+ toolkit.realSync();
+
+ Robot robot = new Robot();
+
+ robot.setAutoDelay(100);
+ robot.keyPress(KeyEvent.VK_ENTER);
+ robot.keyRelease(KeyEvent.VK_ENTER);
+
+ toolkit.realSync();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JProgressBar/7141573/bug7141573.java Wed Feb 15 15:21:33 2012 -0800
@@ -0,0 +1,62 @@
+/*
+ * 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 7141573
+ @summary JProgressBar resize exception, if setStringPainted in Windows LAF
+ @author Pavel Porvatov
+*/
+
+import javax.swing.*;
+import java.awt.image.BufferedImage;
+
+public class bug7141573 {
+ public static void main(String[] args) throws Exception {
+ try {
+ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
+ } catch (Exception e) {
+ System.out.println("WindowsLookAndFeel is not supported. The test bug7141573 is skipped.");
+
+ return;
+ }
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ BufferedImage image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB);
+
+ JProgressBar bar = new JProgressBar();
+
+ bar.setStringPainted(true);
+
+ bar.setSize(100, 1);
+ bar.paint(image.getGraphics());
+
+ bar.setSize(1, 100);
+ bar.paint(image.getGraphics());
+
+ System.out.println("The test bug7141573 is passed.");
+ }
+ });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTree/4314199/bug4314199.html Wed Feb 15 15:21:33 2012 -0800
@@ -0,0 +1,8 @@
+<html>
+<body>
+Select the last tree node (marked "Here") and click on the menu.
+Look at the vertical line connecting nodes "Bug" and "Here". If
+this line disappears when the menu drops down, test fails.
+<applet code="bug4314199.class" width=200 height=200></applet>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTree/4314199/bug4314199.java Wed Feb 15 15:21:33 2012 -0800
@@ -0,0 +1,92 @@
+/*
+ * 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 4314199
+ * @summary Tests that JTree repaints correctly in a container with a JMenu
+ * @author Peter Zhelezniakov
+ * @run applet/manual=yesno bug4314199.html
+ */
+
+import javax.swing.*;
+import javax.swing.tree.*;
+
+public class bug4314199 extends JApplet {
+
+ public void init() {
+
+ try {
+ UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ public void run() {
+ createAndShowGUI();
+ }
+ });
+ } catch (final Exception e) {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ public void run() {
+ createAndShowMessage("Test fails because of exception: "
+ + e.getMessage());
+ }
+ });
+ }
+
+ }
+
+ private void createAndShowMessage(String message) {
+ getContentPane().add(new JLabel(message));
+ }
+
+ private void createAndShowGUI() {
+ JMenuBar mb = new JMenuBar();
+
+ // needed to exactly align left edge of menu and angled line of tree
+ mb.add(Box.createHorizontalStrut(27));
+
+ JMenu mn = new JMenu("Menu");
+ JMenuItem mi = new JMenuItem("MenuItem");
+ mn.add(mi);
+ mb.add(mn);
+ setJMenuBar(mb);
+
+ DefaultMutableTreeNode n1 = new DefaultMutableTreeNode("Root");
+ DefaultMutableTreeNode n2 = new DefaultMutableTreeNode("Duke");
+ n1.add(n2);
+ DefaultMutableTreeNode n3 = new DefaultMutableTreeNode("Bug");
+ n2.add(n3);
+ n3.add(new DefaultMutableTreeNode("Blah"));
+ n3.add(new DefaultMutableTreeNode("Blah"));
+ n3.add(new DefaultMutableTreeNode("Blah"));
+ DefaultMutableTreeNode n4 = new DefaultMutableTreeNode("Here");
+ n2.add(n4);
+
+ JTree tree = new JTree(new DefaultTreeModel(n1));
+ tree.putClientProperty("JTree.lineStyle", "Angled");
+ tree.expandPath(new TreePath(new Object[]{n1, n2, n3}));
+ setContentPane(tree);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/tree/DefaultTreeCellRenderer/7142955/bug7142955.java Wed Feb 15 15:21:33 2012 -0800
@@ -0,0 +1,72 @@
+/*
+ * 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 7142955
+ @summary DefaultTreeCellRenderer doesn't honor 'Tree.rendererFillBackground' LAF property
+ @author Pavel Porvatov
+*/
+
+import javax.swing.*;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+
+public class bug7142955 {
+ private static final Color TEST_COLOR = Color.RED;
+
+ public static void main(String[] args) throws Exception {
+ UIManager.put("Tree.rendererFillBackground", Boolean.FALSE);
+ UIManager.put("Tree.textBackground", TEST_COLOR);
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ int w = 200;
+ int h = 100;
+
+ BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
+
+ Graphics g = image.getGraphics();
+
+ g.setColor(Color.WHITE);
+ g.fillRect(0, 0, image.getWidth(), image.getHeight());
+
+ DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
+
+ renderer.setSize(w, h);
+ renderer.paint(g);
+
+ for (int y = 0; y < h; y++) {
+ for (int x = 0; x < w; x++) {
+ if (image.getRGB(x, y) == TEST_COLOR.getRGB()) {
+ throw new RuntimeException("Test bug7142955 failed");
+ }
+ }
+ }
+
+ System.out.println("Test bug7142955 passed.");
+ }
+ });
+ }
+}