# HG changeset patch # User lana # Date 1295904080 28800 # Node ID 1f5dc732e4d6bc917a58ccb80803ddd8920e7ca7 # Parent 865c081c83721b8032d9d6419abd780406cd388f# Parent fda4ca3f7b24060326f091a477b248c3ed4ed210 Merge diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/make/common/Demo.gmk --- a/jdk/make/common/Demo.gmk Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/make/common/Demo.gmk Mon Jan 24 13:21:20 2011 -0800 @@ -73,8 +73,11 @@ # Destination "src" directory DEMO_BUILD_SRCDIR = $(DEMO_BUILD_AREA)/src -DEMO_BUILD_SRCZIP = $(DEMO_BUILD_AREA)/src.zip -DEMO_SOURCE_ZIP = $(DEMO_DESTDIR)/src.zip + +ifndef DEMO_SKIP_SRCZIP + DEMO_BUILD_SRCZIP = $(DEMO_BUILD_AREA)/src.zip + DEMO_SOURCE_ZIP = $(DEMO_DESTDIR)/src.zip +endif # Place to hold the jar image we are creating DEMO_JAR_IMAGE = $(DEMO_BUILD_AREA)/jar_image @@ -258,14 +261,16 @@ endif -# Create a src.zip file -$(DEMO_BUILD_SRCZIP): $(DEMO_FULL_SOURCES) +ifndef DEMO_SKIP_SRCZIP + # Create a src.zip file + $(DEMO_BUILD_SRCZIP): $(DEMO_FULL_SOURCES) @$(prep-target) $(CD) $(DEMO_BUILD_AREA)/src && $(ZIPEXE) -q -r ../$(@F) . -# Install the destination src.zip file and create the src tree -$(DEMO_SOURCE_ZIP): $(DEMO_BUILD_SRCZIP) + # Install the destination src.zip file and create the src tree + $(DEMO_SOURCE_ZIP): $(DEMO_BUILD_SRCZIP) $(install-file) +endif # Native library building ifdef DEMO_LIBRARY @@ -362,7 +367,7 @@ $(RM) -r $(DEMO_BUILD_AREA) $(RM) -r $(DEMO_DESTDIR) -# This should not be needed, but some versions of GNU amke have a bug that +# This should not be needed, but some versions of GNU make have a bug that # sometimes deleted these files for some strange and unknown reason # (GNU make version 3.78.1 has the problem, GNU make version 3.80 doesn't?) .PRECIOUS: $(DEMO_FULL_SOURCES) $(DEMO_BUILD_SRCZIP) $(DEMO_SOURCE_ZIP) diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/make/mkdemo/jfc/Makefile --- a/jdk/make/mkdemo/jfc/Makefile Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/make/mkdemo/jfc/Makefile Mon Jan 24 13:21:20 2011 -0800 @@ -43,7 +43,7 @@ # Some demos aren't currently included in OpenJDK ifndef OPENJDK - SUBDIRS += Java2D SwingSet2 Stylepad + SUBDIRS += Java2D SwingSet2 SwingSet3 Stylepad endif include $(BUILDDIR)/common/Subdirs.gmk diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/make/mkdemo/jfc/SwingSet3/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/make/mkdemo/jfc/SwingSet3/Makefile Mon Jan 24 13:21:20 2011 -0800 @@ -0,0 +1,43 @@ +# +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# Makefile to build the SwingSet3 demo. +# + +BUILDDIR = ../../.. +PRODUCT = demo/jfc +DEMONAME = SwingSet3 +include $(BUILDDIR)/common/Defs.gmk + +DEMO_ROOT = $(CLOSED_SRC)/share/demo/jfc/$(DEMONAME) +DEMO_DESTDIR = $(DEMODIR)/jfc/$(DEMONAME) +DEMO_TOPFILES = ./readme.html ./swingset3.png +DEMO_SKIP_SRCZIP = true + +# +# Demo jar building rules. +# +include $(BUILDDIR)/common/Demo.gmk diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/src/share/classes/javax/swing/AbstractButton.java --- a/jdk/src/share/classes/javax/swing/AbstractButton.java Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/src/share/classes/javax/swing/AbstractButton.java Mon Jan 24 13:21:20 2011 -0800 @@ -1335,7 +1335,6 @@ * * @param a the button's action * @since 1.3 - * @see Actions * @see Action * @see #setAction */ diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/src/share/classes/javax/swing/JEditorPane.java --- a/jdk/src/share/classes/javax/swing/JEditorPane.java Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/src/share/classes/javax/swing/JEditorPane.java Mon Jan 24 13:21:20 2011 -0800 @@ -145,8 +145,8 @@ *
  • * One way is to specify the character set as a parameter of the MIME * type. This will be established by a call to the - * setContentType method. If the content - * is loaded by the setPage method the content + * {@link #setContentType setContentType} method. If the content + * is loaded by the {@link #setPage setPage} method the content * type will have been set according to the specification of the URL. * It the file is loaded directly, the content type would be expected to * have been set prior to loading. diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/src/share/classes/javax/swing/JFileChooser.java --- a/jdk/src/share/classes/javax/swing/JFileChooser.java Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/src/share/classes/javax/swing/JFileChooser.java Mon Jan 24 13:21:20 2011 -0800 @@ -256,10 +256,6 @@ private FileView fileView = null; - // uiFileView is not serialized, as it is initialized - // by updateUI() after deserialization - private transient FileView uiFileView = null; - private boolean controlsShown = true; private boolean useFileHiding = true; @@ -1504,6 +1500,9 @@ if(getFileView() != null) { filename = getFileView().getName(f); } + + FileView uiFileView = getUI().getFileView(this); + if(filename == null && uiFileView != null) { filename = uiFileView.getName(f); } @@ -1524,6 +1523,9 @@ if(getFileView() != null) { description = getFileView().getDescription(f); } + + FileView uiFileView = getUI().getFileView(this); + if(description == null && uiFileView != null) { description = uiFileView.getDescription(f); } @@ -1544,6 +1546,9 @@ if(getFileView() != null) { typeDescription = getFileView().getTypeDescription(f); } + + FileView uiFileView = getUI().getFileView(this); + if(typeDescription == null && uiFileView != null) { typeDescription = uiFileView.getTypeDescription(f); } @@ -1564,6 +1569,9 @@ if(getFileView() != null) { icon = getFileView().getIcon(f); } + + FileView uiFileView = getUI().getFileView(this); + if(icon == null && uiFileView != null) { icon = uiFileView.getIcon(f); } @@ -1584,6 +1592,9 @@ if (getFileView() != null) { traversable = getFileView().isTraversable(f); } + + FileView uiFileView = getUI().getFileView(this); + if (traversable == null && uiFileView != null) { traversable = uiFileView.isTraversable(f); } @@ -1791,7 +1802,6 @@ } setUI(ui); - uiFileView = getUI().getFileView(this); if(isAcceptAllFileFilterUsed()) { addChoosableFileFilter(getAcceptAllFileFilter()); } diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/src/share/classes/javax/swing/SizeSequence.java --- a/jdk/src/share/classes/javax/swing/SizeSequence.java Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/src/share/classes/javax/swing/SizeSequence.java Mon Jan 24 13:21:20 2011 -0800 @@ -132,7 +132,7 @@ * can use insertEntries or setSizes. * * @see #insertEntries - * @see #setSizes + * @see #setSizes(int[]) */ public SizeSequence() { a = emptyArray; diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/src/share/classes/javax/swing/TransferHandler.java --- a/jdk/src/share/classes/javax/swing/TransferHandler.java Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/src/share/classes/javax/swing/TransferHandler.java Mon Jan 24 13:21:20 2011 -0800 @@ -344,7 +344,7 @@ * * @return the drop location * @throws IllegalStateException if this is not a drop - * @see #isDrop + * @see #isDrop() */ public DropLocation getDropLocation() { assureIsDrop(); @@ -380,7 +380,7 @@ * * @param showDropLocation whether or not to indicate the drop location * @throws IllegalStateException if this is not a drop - * @see #isDrop + * @see #isDrop() */ public void setShowDropLocation(boolean showDropLocation) { assureIsDrop(); @@ -406,7 +406,7 @@ * @see #getDropAction * @see #getUserDropAction * @see #getSourceDropActions - * @see #isDrop + * @see #isDrop() */ public void setDropAction(int dropAction) { assureIsDrop(); @@ -440,7 +440,7 @@ * @throws IllegalStateException if this is not a drop * @see #setDropAction * @see #getUserDropAction - * @see #isDrop + * @see #isDrop() */ public int getDropAction() { return dropAction == -1 ? getUserDropAction() : dropAction; @@ -468,7 +468,7 @@ * @throws IllegalStateException if this is not a drop * @see #setDropAction * @see #getDropAction - * @see #isDrop + * @see #isDrop() */ public int getUserDropAction() { assureIsDrop(); @@ -501,7 +501,7 @@ * * @return the drag source's supported drop actions * @throws IllegalStateException if this is not a drop - * @see #isDrop + * @see #isDrop() */ public int getSourceDropActions() { assureIsDrop(); diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/src/share/classes/javax/swing/event/InternalFrameAdapter.java --- a/jdk/src/share/classes/javax/swing/event/InternalFrameAdapter.java Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/src/share/classes/javax/swing/event/InternalFrameAdapter.java Mon Jan 24 13:21:20 2011 -0800 @@ -32,8 +32,7 @@ * equivalent to the WindowAdapter class in the AWT. *

    * See How to Write an Internal Frame Listener - * in The Java Tutorial and - * The Java Class Libraries (update) + * in The Java Tutorial * * @see InternalFrameEvent * @see InternalFrameListener diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/src/share/classes/javax/swing/event/InternalFrameListener.java --- a/jdk/src/share/classes/javax/swing/event/InternalFrameListener.java Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/src/share/classes/javax/swing/event/InternalFrameListener.java Mon Jan 24 13:21:20 2011 -0800 @@ -33,9 +33,7 @@ * in the AWT. *

    * See How to Write an Internal Frame Listener - * in The Java Tutorial and - * The Java Class Libraries (update) - * for further documentation. + * in The Java Tutorial for further documentation. * * @see java.awt.event.WindowListener * diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/src/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html --- a/jdk/src/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/src/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html Mon Jan 24 13:21:20 2011 -0800 @@ -66,7 +66,7 @@ Before reading further, you should be familiar with the concept of pluggable look and feels. For basic information, see -Choosing the Look and Feel, +How to Set the Look and Feel, a section in The Java Tutorial. For architectural details, you can read diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/src/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html --- a/jdk/src/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/src/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html Mon Jan 24 13:21:20 2011 -0800 @@ -91,7 +91,7 @@

     <!ELEMENT style (property | defaultsProperty | state | font | graphicsUtils |
    -                 insets | painter | imagePainter | opaque | (%beansPersistance;) |
    +                 insets | painter | imagePainter | opaque | (%beansPersistance;) |
                      imageIcon)*>
     <!ATTLIST style
               id              ID          #IMPLIED
    @@ -250,8 +250,8 @@
         

    Defines the font for the current state, or style. You must - specify either an idref or a - name and size. + specify either an idref or a + name and size.

    The following example creates a style with a Font of @@ -797,7 +797,7 @@ path CDATA #REQUIRED sourceInsets CDATA #IMPLIED destinationInsets CDATA #IMPLIED - paintCenter (true|false) "true" + paintCenter (true|false) "true" stretch (true|false) "true" center (true|false) "false" > diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/src/share/classes/javax/swing/text/AsyncBoxView.java --- a/jdk/src/share/classes/javax/swing/text/AsyncBoxView.java Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/src/share/classes/javax/swing/text/AsyncBoxView.java Mon Jan 24 13:21:20 2011 -0800 @@ -384,7 +384,7 @@ /** * Loads all of the children to initialize the view. - * This is called by the setParent + * This is called by the {@link #setParent setParent} * method. Subclasses can reimplement this to initialize * their child views in a different manner. The default * implementation creates a child view for each diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/src/share/classes/javax/swing/text/DefaultCaret.java --- a/jdk/src/share/classes/javax/swing/text/DefaultCaret.java Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/src/share/classes/javax/swing/text/DefaultCaret.java Mon Jan 24 13:21:20 2011 -0800 @@ -70,7 +70,7 @@ * will render a solid color as specified in the associated text component * in the SelectionColor property. This can easily be changed * by reimplementing the - * getSelectionHighlighter + * {@link #getSelectionPainter getSelectionPainter} * method. *

    * A customized caret appearance can be achieved by reimplementing diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/src/share/classes/javax/swing/text/TableView.java --- a/jdk/src/share/classes/javax/swing/text/TableView.java Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/src/share/classes/javax/swing/text/TableView.java Mon Jan 24 13:21:20 2011 -0800 @@ -315,7 +315,7 @@ * updated along the minor axis. *

    * This is implemented to call the - * layoutColumns method, and then + * {@link #layoutColumns layoutColumns} method, and then * forward to the superclass to actually carry out the layout * of the tables rows. * diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/src/share/classes/javax/swing/text/View.java --- a/jdk/src/share/classes/javax/swing/text/View.java Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/src/share/classes/javax/swing/text/View.java Mon Jan 24 13:21:20 2011 -0800 @@ -117,7 +117,7 @@ what it is prepared to deal with.

  • The coordinate system is the same as the hosting Component (i.e. the Component returned by the - getContainer method). + {@link #getContainer getContainer} method). This means a child view lives in the same coordinate system as the parent view unless the parent has explicitly changed the coordinate system. To schedule itself to be repainted a view can call repaint on the hosting @@ -180,9 +180,9 @@ starting from the root of the view hierarchy. The methods for doing this are:

    @@ -497,6 +497,10 @@ public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a, int direction, Position.Bias[] biasRet) throws BadLocationException { + if (pos < -1) { + // -1 is a reserved value, see the code below + throw new BadLocationException("Invalid position", pos); + } biasRet[0] = Position.Bias.Forward; switch (direction) { @@ -670,15 +674,15 @@ * spread out into the following calls that subclasses can * reimplement: *

      - *
    1. updateChildren is called + *
    2. {@link #updateChildren updateChildren} is called * if there were any changes to the element this view is * responsible for. If this view has child views that are * represent the child elements, then this method should do * whatever is necessary to make sure the child views correctly * represent the model. - *
    3. forwardUpdate is called + *
    4. {@link #forwardUpdate forwardUpdate} is called * to forward the DocumentEvent to the appropriate child views. - *
    5. updateLayout is called to + *
    6. {@link #updateLayout updateLayout} is called to * give the view a chance to either repair its layout, to reschedule * layout, or do nothing. *
    @@ -711,15 +715,15 @@ * spread out into the following calls that subclasses can * reimplement: *
      - *
    1. updateChildren is called + *
    2. {@link #updateChildren updateChildren} is called * if there were any changes to the element this view is * responsible for. If this view has child views that are * represent the child elements, then this method should do * whatever is necessary to make sure the child views correctly * represent the model. - *
    3. forwardUpdate is called + *
    4. {@link #forwardUpdate forwardUpdate} is called * to forward the DocumentEvent to the appropriate child views. - *
    5. updateLayout is called to + *
    6. {@link #updateLayout updateLayout} is called to * give the view a chance to either repair its layout, to reschedule * layout, or do nothing. *
    @@ -752,15 +756,15 @@ * spread out into the following calls that subclasses can * reimplement: *
      - *
    1. updateChildren is called + *
    2. {@link #updateChildren updateChildren} is called * if there were any changes to the element this view is * responsible for. If this view has child views that are * represent the child elements, then this method should do * whatever is necessary to make sure the child views correctly * represent the model. - *
    3. forwardUpdate is called + *
    4. {@link #forwardUpdate forwardUpdate} is called * to forward the DocumentEvent to the appropriate child views. - *
    5. updateLayout is called to + *
    6. {@link #updateLayout updateLayout} is called to * give the view a chance to either repair its layout, to reschedule * layout, or do nothing. *
    @@ -1186,7 +1190,7 @@ * simply messages the view with a call to insertUpdate, * removeUpdate, or changedUpdate depending * upon the type of the event. This is called by - * forwardUpdate to forward + * {@link #forwardUpdate forwardUpdate} to forward * the event to children that need it. * * @param v the child view to forward the event to diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/src/share/classes/javax/swing/text/html/HTMLEditorKit.java --- a/jdk/src/share/classes/javax/swing/text/html/HTMLEditorKit.java Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/src/share/classes/javax/swing/text/html/HTMLEditorKit.java Mon Jan 24 13:21:20 2011 -0800 @@ -123,7 +123,7 @@ * to load. By default, this kit produces documents that will be * loaded asynchronously if loaded using JEditorPane.setPage. * This is controlled by a property on the document. The method - * createDefaultDocument can + * {@link #createDefaultDocument createDefaultDocument} can * be overriden to change this. The batching of work is done * by the HTMLDocument.HTMLReader class. The actual * work is done by the DefaultStyledDocument and @@ -558,7 +558,7 @@ * automatically or only FormSubmitEvent is fired. * By default it is set to true. * - * @see #isAutoFormSubmission + * @see #isAutoFormSubmission() * @see FormSubmitEvent * @since 1.5 */ diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/src/share/classes/javax/swing/text/html/ParagraphView.java --- a/jdk/src/share/classes/javax/swing/text/html/ParagraphView.java Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/src/share/classes/javax/swing/text/html/ParagraphView.java Mon Jan 24 13:21:20 2011 -0800 @@ -61,7 +61,7 @@ *

    * This is implemented * to forward to the superclass as well as call the - * setPropertiesFromAttributes + * {@link #setPropertiesFromAttributes setPropertiesFromAttributes} * method to set the paragraph properties from the css * attributes. The call is made at this time to ensure * the ability to resolve upward through the parents diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/src/share/classes/javax/swing/text/html/StyleSheet.java --- a/jdk/src/share/classes/javax/swing/text/html/StyleSheet.java Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/src/share/classes/javax/swing/text/html/StyleSheet.java Mon Jan 24 13:21:20 2011 -0800 @@ -51,7 +51,7 @@ *

    * The primary entry point for HTML View implementations * to get their attributes is the - * getViewAttributes + * {@link #getViewAttributes getViewAttributes} * method. This should be implemented to establish the * desired policy used to associate attributes with the view. * Each HTMLEditorKit (i.e. and therefore each associated diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/src/share/classes/javax/swing/text/html/parser/ParserDelegator.java --- a/jdk/src/share/classes/javax/swing/text/html/parser/ParserDelegator.java Mon Jan 24 13:20:07 2011 -0800 +++ b/jdk/src/share/classes/javax/swing/text/html/parser/ParserDelegator.java Mon Jan 24 13:21:20 2011 -0800 @@ -48,7 +48,11 @@ private static final Object DTD_KEY = new Object(); - protected static synchronized void setDefaultDTD() { + protected static void setDefaultDTD() { + getDefaultDTD(); + } + + private static synchronized DTD getDefaultDTD() { AppContext appContext = AppContext.getAppContext(); DTD dtd = (DTD) appContext.get(DTD_KEY); @@ -67,6 +71,8 @@ appContext.put(DTD_KEY, dtd); } + + return dtd; } protected static DTD createDTD(DTD dtd, String name) { @@ -92,7 +98,7 @@ } public void parse(Reader r, HTMLEditorKit.ParserCallback cb, boolean ignoreCharSet) throws IOException { - new DocumentParser((DTD) AppContext.getAppContext().get(DTD_KEY)).parse(r, cb, ignoreCharSet); + new DocumentParser(getDefaultDTD()).parse(r, cb, ignoreCharSet); } /** diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/test/javax/swing/JFileChooser/6342301/bug6342301.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/JFileChooser/6342301/bug6342301.java Mon Jan 24 13:21:20 2011 -0800 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2010, 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 6342301 + @summary Bad interaction between setting the ui and file filters in JFileChooser + @author Pavel Porvatov +*/ + +import javax.swing.*; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.metal.MetalFileChooserUI; +import javax.swing.plaf.metal.MetalLookAndFeel; +import java.io.File; + +public class bug6342301 { + private static String tempDir; + + public static void main(String[] args) throws Exception { + tempDir = System.getProperty("java.io.tmpdir"); + + if (tempDir.length() == 0) { //'java.io.tmpdir' isn't guaranteed to be defined + tempDir = System.getProperty("user.home"); + } + + System.out.println("Temp directory: " + tempDir); + + UIManager.setLookAndFeel(new MetalLookAndFeel()); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + HackedFileChooser openChooser = new HackedFileChooser(); + + openChooser.setUI(new MetalFileChooserUI(openChooser)); + openChooser.setCurrentDirectory(new File(tempDir)); + } + }); + } + + private static class HackedFileChooser extends JFileChooser { + public void setUI(ComponentUI newUI) { + super.setUI(newUI); + } + } +} diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/test/javax/swing/JLabel/7004134/bug7004134.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/JLabel/7004134/bug7004134.java Mon Jan 24 13:21:20 2011 -0800 @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2010, 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 7004134 + @summary JLabel containing a ToolTipText does no longer show ToolTip after browser refresh + @author Pavel Porvatov +*/ + +import sun.awt.SunToolkit; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.lang.reflect.Field; + +public class bug7004134 { + private static volatile JFrame frame; + + private static volatile JLabel label; + + private static volatile int toolTipWidth; + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + label = new JLabel("A JLabel used as object for an HTML-formatted tooltip"); + label.setToolTipText("An HTML-formatted ToolTip"); + + frame = new JFrame(); + + frame.add(label); + frame.pack(); + frame.setVisible(true); + + ToolTipManager toolTipManager = ToolTipManager.sharedInstance(); + + toolTipManager.setInitialDelay(0); + toolTipManager.mouseMoved(new MouseEvent(label, 0, 0, 0, 0, 0, 0, false)); + } + }); + + Thread.sleep(500); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + toolTipWidth = getTipWindow().getWidth(); + + frame.dispose(); + } + }); + + Thread thread = new Thread(new ThreadGroup("Some ThreadGroup"), new Runnable() { + public void run() { + SunToolkit.createNewAppContext(); + + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame = new JFrame(); + + frame.add(label); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.pack(); + frame.setVisible(true); + + ToolTipManager toolTipManager = ToolTipManager.sharedInstance(); + + toolTipManager.setInitialDelay(0); + toolTipManager.mouseMoved(new MouseEvent(label, 0, 0, 0, 0, 0, 0, false)); + } + }); + + Thread.sleep(500); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + int newToolTipWidth = getTipWindow().getWidth(); + + frame.dispose(); + + if (toolTipWidth != newToolTipWidth) { + throw new RuntimeException("Tooltip width is different. Initial: " + toolTipWidth + + ", new: " + newToolTipWidth); + } + } + }); + } catch (Exception e) { + throw new RuntimeException(e); + } + + } + }); + + thread.start(); + thread.join(); + } + + private static Component getTipWindow() { + try { + Field tipWindowField = ToolTipManager.class.getDeclaredField("tipWindow"); + + tipWindowField.setAccessible(true); + + Popup value = (Popup) tipWindowField.get(ToolTipManager.sharedInstance()); + + Field componentField = Popup.class.getDeclaredField("component"); + + componentField.setAccessible(true); + + return (Component) componentField.get(value); + } catch (Exception e) { + throw new RuntimeException("getToolTipComponent failed", e); + } + } +} diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/test/javax/swing/text/NavigationFilter/6735293/bug6735293.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/text/NavigationFilter/6735293/bug6735293.java Mon Jan 24 13:21:20 2011 -0800 @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2010, 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 6735293 + * @summary javax.swing.text.NavigationFilter.getNextVisualPositionFrom() not always throws BadLocationException + * @author Pavel Porvatov + */ + +import javax.swing.*; +import javax.swing.text.BadLocationException; +import javax.swing.text.NavigationFilter; +import javax.swing.text.Position; + +public class bug6735293 { + private static volatile JFormattedTextField jtf; + + private static volatile NavigationFilter nf; + + private static volatile JFrame jFrame; + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + jtf = new JFormattedTextField(); + nf = new NavigationFilter(); + jtf.setText("A text message"); + + jFrame = new JFrame(); + jFrame.getContentPane().add(jtf); + jFrame.pack(); + jFrame.setVisible(true); + } + }); + + Thread.sleep(1000); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + Position.Bias[] biasRet = {Position.Bias.Forward}; + + for (int direction : new int[]{ + SwingConstants.EAST, + SwingConstants.WEST, + // the following constants still will lead to "BadLocationException: Length must be positive" + SwingConstants.SOUTH, + SwingConstants.NORTH, + }) { + for (int position : new int[]{-100, Integer.MIN_VALUE}) { + for (Position.Bias bias : new Position.Bias[]{Position.Bias.Backward, Position.Bias.Forward}) { + try { + nf.getNextVisualPositionFrom(jtf, position, bias, direction, biasRet); + + throw new RuntimeException("BadLocationException was not thrown: position = " + + position + ", bias = " + bias + ", direction = " + direction); + } catch (BadLocationException e) { + // Ok + } + } + } + } + + jFrame.dispose(); + } + }); + } +} diff -r 865c081c8372 -r 1f5dc732e4d6 jdk/test/javax/swing/text/html/parser/Parser/6990651/bug6990651.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/text/html/parser/Parser/6990651/bug6990651.java Mon Jan 24 13:21:20 2011 -0800 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2010, 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 6990651 + @summary Regression: NPE when refreshing applet since 6u22-b01 + @author Pavel Porvatov +*/ +import sun.awt.SunToolkit; + +import javax.swing.*; + +public class bug6990651 { + private static volatile JEditorPane editor; + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + editor = new JEditorPane("text/html", "Hello world!"); + } + }); + + Thread thread = new Thread(new ThreadGroup("Some ThreadGroup"), new Runnable() { + public void run() { + SunToolkit.createNewAppContext(); + + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + editor.setText("Hello world!"); + } + }); + } catch (Exception e) { + throw new RuntimeException(e); + } + + } + }); + + thread.start(); + thread.join(); + } +}