mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-14 23:49:49 +00:00
Merge
This commit is contained in:
commit
72ce1c5159
@ -137,6 +137,11 @@ public class WindowsProgressBarUI extends BasicProgressBarUI
|
||||
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));
|
||||
|
||||
@ -115,7 +115,7 @@ public class List extends Component implements ItemSelectable, Accessible {
|
||||
* @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 @@ public class List extends Component implements ItemSelectable, Accessible {
|
||||
// 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 @@ public class List extends Component implements ItemSelectable, Accessible {
|
||||
if (peer != null) {
|
||||
peer.removeAll();
|
||||
}
|
||||
items = new Vector();
|
||||
items = new Vector<>();
|
||||
selected = new int[0];
|
||||
}
|
||||
|
||||
@ -490,9 +490,9 @@ public class List extends Component implements ItemSelectable, Accessible {
|
||||
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 @@ public class List extends Component implements ItemSelectable, Accessible {
|
||||
* @since 1.4
|
||||
*/
|
||||
public synchronized ItemListener[] getItemListeners() {
|
||||
return (ItemListener[])(getListeners(ItemListener.class));
|
||||
return getListeners(ItemListener.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -975,7 +975,7 @@ public class List extends Component implements ItemSelectable, Accessible {
|
||||
* @since 1.4
|
||||
*/
|
||||
public synchronized ActionListener[] getActionListeners() {
|
||||
return (ActionListener[])(getListeners(ActionListener.class));
|
||||
return getListeners(ActionListener.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -398,10 +398,10 @@ public class Window extends Container implements Accessible {
|
||||
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 @@ public class Window extends Container implements Accessible {
|
||||
// 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"));
|
||||
}
|
||||
|
||||
@ -921,9 +921,9 @@ public class ICC_Profile implements Serializable {
|
||||
*/
|
||||
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);
|
||||
|
||||
@ -321,14 +321,15 @@ public abstract class InputEvent extends ComponentEvent {
|
||||
* @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 @@ public abstract class InputEvent extends ComponentEvent {
|
||||
|
||||
/**
|
||||
* 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,
|
||||
|
||||
@ -488,14 +488,15 @@ public class MouseEvent extends InputEvent {
|
||||
* @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 @@ public class MouseEvent extends InputEvent {
|
||||
* @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 @@ public class MouseEvent extends InputEvent {
|
||||
* @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.
|
||||
|
||||
@ -180,8 +180,7 @@ public final class PrinterStateReasons
|
||||
if (severity == null) {
|
||||
throw new NullPointerException("severity is null");
|
||||
}
|
||||
return super.put((PrinterStateReason) reason,
|
||||
(Severity) severity);
|
||||
return super.put(reason, severity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -141,7 +141,7 @@ public class ReferenceUriSchemesSupported
|
||||
* Returns the string table for class ReferenceUriSchemesSupported.
|
||||
*/
|
||||
protected String[] getStringTable() {
|
||||
return (String[])myStringTable.clone();
|
||||
return myStringTable.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -34,7 +34,6 @@ import java.awt.KeyboardFocusManager;
|
||||
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 @@ public class JOptionPane extends JComponent implements Accessible
|
||||
// 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);
|
||||
|
||||
@ -1236,6 +1236,7 @@ public class BasicOptionPaneUI extends OptionPaneUI {
|
||||
int index = list.locationToIndex(e.getPoint());
|
||||
|
||||
optionPane.setInputValue(list.getModel().getElementAt(index));
|
||||
optionPane.setValue(JOptionPane.OK_OPTION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -434,6 +434,8 @@ public class SynthTreeUI extends BasicTreeUI
|
||||
|
||||
// Empty out the renderer pane, allowing renderers to be gc'ed.
|
||||
rendererPane.removeAll();
|
||||
|
||||
paintContext = null;
|
||||
}
|
||||
|
||||
private void configureRenderer(SynthContext context) {
|
||||
|
||||
@ -156,7 +156,7 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
protected Color borderSelectionColor;
|
||||
|
||||
private boolean isDropCell;
|
||||
private boolean fillBackground = true;
|
||||
private boolean fillBackground;
|
||||
|
||||
/**
|
||||
* Set to true after the constructor has run.
|
||||
|
||||
@ -32,7 +32,7 @@ import java.beans.*;
|
||||
*/
|
||||
|
||||
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 {
|
||||
|
||||
@ -171,6 +171,53 @@ static jobjectArray toFilenamesArray(JNIEnv *env, GSList* list)
|
||||
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 @@ static void handle_response(GtkWidget* aDialog, gint responseId, gpointer obj)
|
||||
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);
|
||||
|
||||
@ -96,7 +96,10 @@ public class ChoiceMouseWheelTest extends Frame {
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
@ -54,9 +54,12 @@ public class PaintSetEnabledDeadlock extends Frame {
|
||||
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 @@ class TestPanel extends Panel implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
|
||||
@ -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,29 +26,30 @@
|
||||
* @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 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 @@ public class TwentyThousandTest implements ActionListener, Runnable {
|
||||
|
||||
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 @@ public class TwentyThousandTest implements ActionListener, Runnable {
|
||||
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 @@ public class TwentyThousandTest implements ActionListener, Runnable {
|
||||
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);
|
||||
|
||||
if ( UPDATE_UI_EACH_INTERVAL )
|
||||
CHOOSER.updateUI();
|
||||
chooser.updateUI();
|
||||
|
||||
if ( AUTO_CLOSE_DIALOG ) {
|
||||
Thread t = new Thread( new TwentyThousandTest( CHOOSER ) );
|
||||
t.start();
|
||||
CHOOSER.showOpenDialog( null );
|
||||
} else {
|
||||
CHOOSER.showOpenDialog( null );
|
||||
}
|
||||
// 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);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while ( !this.chooser.isShowing() ) {
|
||||
try {
|
||||
Thread.sleep( 30 );
|
||||
} catch ( InterruptedException exception ) {
|
||||
exception.printStackTrace();
|
||||
DisposerRecord disposerRecord = new DisposerRecord() {
|
||||
public void dispose() {
|
||||
disposerComplete = true;
|
||||
}
|
||||
}
|
||||
Timer timer = new Timer( INTERVAL, this );
|
||||
timer.setRepeats( false );
|
||||
timer.start();
|
||||
}
|
||||
};
|
||||
|
||||
public void actionPerformed( ActionEvent event ) {
|
||||
this.chooser.cancelSelection();
|
||||
disposerComplete = false;
|
||||
|
||||
Disposer.addRecord(new Object(), disposerRecord);
|
||||
|
||||
while (!disposerComplete) {
|
||||
Util.generateOOME();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
70
jdk/test/javax/swing/JOptionPane/7138665/bug7138665.java
Normal file
70
jdk/test/javax/swing/JOptionPane/7138665/bug7138665.java
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
62
jdk/test/javax/swing/JProgressBar/7141573/bug7141573.java
Normal file
62
jdk/test/javax/swing/JProgressBar/7141573/bug7141573.java
Normal file
@ -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.");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
8
jdk/test/javax/swing/JTree/4314199/bug4314199.html
Normal file
8
jdk/test/javax/swing/JTree/4314199/bug4314199.html
Normal file
@ -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>
|
||||
92
jdk/test/javax/swing/JTree/4314199/bug4314199.java
Normal file
92
jdk/test/javax/swing/JTree/4314199/bug4314199.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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.");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user