提交 6ab8cb3e 编写于 作者: L lana

Merge

......@@ -73,8 +73,11 @@ DEMO_BUILD_AREA = $(DEMOCLASSDIR)/$(PRODUCT)/$(DEMONAME)
# 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 @@ $(DEMO_JAR): \
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 @@ clean clobber:
$(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)
......
......@@ -43,7 +43,7 @@ SUBDIRS = \
# 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
......
#
# 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
......@@ -1335,7 +1335,6 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl
*
* @param a the button's action
* @since 1.3
* @see <a href="#actions">Actions</a>
* @see Action
* @see #setAction
*/
......
......@@ -145,8 +145,8 @@ import javax.accessibility.*;
* <li>
* One way is to specify the character set as a parameter of the MIME
* type. This will be established by a call to the
* <a href="#setContentType">setContentType</a> method. If the content
* is loaded by the <a href="#setPage">setPage</a> 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.
......
......@@ -256,10 +256,6 @@ public class JFileChooser extends JComponent implements Accessible {
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 @@ public class JFileChooser extends JComponent implements Accessible {
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 @@ public class JFileChooser extends JComponent implements Accessible {
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 @@ public class JFileChooser extends JComponent implements Accessible {
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 @@ public class JFileChooser extends JComponent implements Accessible {
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 @@ public class JFileChooser extends JComponent implements Accessible {
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 @@ public class JFileChooser extends JComponent implements Accessible {
}
setUI(ui);
uiFileView = getUI().getFileView(this);
if(isAcceptAllFileFilterUsed()) {
addChoosableFileFilter(getAcceptAllFileFilter());
}
......
......@@ -132,7 +132,7 @@ public class SizeSequence {
* can use <code>insertEntries</code> or <code>setSizes</code>.
*
* @see #insertEntries
* @see #setSizes
* @see #setSizes(int[])
*/
public SizeSequence() {
a = emptyArray;
......
......@@ -344,7 +344,7 @@ public class TransferHandler implements Serializable {
*
* @return the drop location
* @throws IllegalStateException if this is not a drop
* @see #isDrop
* @see #isDrop()
*/
public DropLocation getDropLocation() {
assureIsDrop();
......@@ -380,7 +380,7 @@ public class TransferHandler implements Serializable {
*
* @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 @@ public class TransferHandler implements Serializable {
* @see #getDropAction
* @see #getUserDropAction
* @see #getSourceDropActions
* @see #isDrop
* @see #isDrop()
*/
public void setDropAction(int dropAction) {
assureIsDrop();
......@@ -440,7 +440,7 @@ public class TransferHandler implements Serializable {
* @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 @@ public class TransferHandler implements Serializable {
* @throws IllegalStateException if this is not a drop
* @see #setDropAction
* @see #getDropAction
* @see #isDrop
* @see #isDrop()
*/
public int getUserDropAction() {
assureIsDrop();
......@@ -501,7 +501,7 @@ public class TransferHandler implements Serializable {
*
* @return the drag source's supported drop actions
* @throws IllegalStateException if this is not a drop
* @see #isDrop
* @see #isDrop()
*/
public int getSourceDropActions() {
assureIsDrop();
......
......@@ -32,8 +32,7 @@ package javax.swing.event;
* equivalent to the WindowAdapter class in the AWT.
* <p>
* See <a href="http://java.sun.com/docs/books/tutorial/uiswing/events/internalframelistener.html">How to Write an Internal Frame Listener</a>
* in <em>The Java Tutorial</em> and
* <a href="http://www.awl.com/cp/javaseries/jcl1_2.html">The Java Class Libraries (update)</a>
* in <em>The Java Tutorial</em>
*
* @see InternalFrameEvent
* @see InternalFrameListener
......
......@@ -33,9 +33,7 @@ import java.util.EventListener;
* in the AWT.
* <p>
* See <a href="http://java.sun.com/docs/books/tutorial/uiswing/events/internalframelistener.html">How to Write an Internal Frame Listener</a>
* in <em>The Java Tutorial</em> and
* <a href="http://www.awl.com/cp/javaseries/jcl1_2.html">The Java Class Libraries (update)</a>
* for further documentation.
* in <em>The Java Tutorial</em> for further documentation.
*
* @see java.awt.event.WindowListener
*
......
......@@ -66,7 +66,7 @@ This document has the following sections:
Before reading further, you should be familiar
with the concept of pluggable look and feels.
For basic information, see
<a href="http://java.sun.com/docs/books/tutorial/uiswing/start/swingTour.html#plaf">Choosing the Look and Feel</a>,
<a href="http://java.sun.com/docs/books/tutorial/uiswing/lookandfeel/plaf.html">How to Set the Look and Feel</a>,
a section in
<em>The Java Tutorial</em>.
For architectural details, you can read
......
......@@ -91,7 +91,7 @@ div.example {
<div class="dtd-fragment">
<pre class="dtd-fragment">
&lt;!ELEMENT <a name="e.style">style</a> (<a href="#e.property">property</a> | <a href="#e.defaultsProperty">defaultsProperty</a> | <a href="#e.state">state</a> | <a href="#e.font">font</a> | <a href="#e.graphicsUtils">graphicsUtils</a> |
<a href="#e.insets">insets</a> | <a href="#e.painter">painter</a> | <a href="#e.imagePainter">imagePainter</a> | <a href="#e.opaque">opaque</a> | (<a href="#beansPersistance">%beansPersistance;</a>) |
<a href="#e.insets">insets</a> | <a href="#e.painter">painter</a> | <a href="#e.imagePainter">imagePainter</a> | <a href="#e.opaque">opaque</a> | (<a href="#ee.beansPersistance">%beansPersistance;</a>) |
<a href="#e.imageIcon">imageIcon</a>)*>
&lt;!ATTLIST style
<a href="#style.id">id</a> ID #IMPLIED
......@@ -250,8 +250,8 @@ div.example {
<p>
Defines the font for the current <a href="#e.state">state</a>,
or <a href="#e.style">style</a>. You must
specify either an <a href="#state.idref">idref</a> or a
<a href="#state.name">name</a> and <a href="#state.size">size</a>.
specify either an <a href="#font.idref">idref</a> or a
<a href="#font.name">name</a> and <a href="#font.size">size</a>.
</p>
<p>
The following example creates a style with a Font of
......@@ -797,7 +797,7 @@ div.example {
<a href="#imagePainter.path">path</a> CDATA #REQUIRED
<a href="#imagePainter.sourceInsets">sourceInsets</a> CDATA #IMPLIED
<a href="#imagePainter.destinationInsets">destinationInsets</a> CDATA #IMPLIED
<a href="#imagePainter.paintCenter">paintCenter</a> (true|false) "true"
<a href="#imagePainter.painterCenter">paintCenter</a> (true|false) "true"
<a href="#imagePainter.stretch">stretch</a> (true|false) "true"
<a href="#imagePainter.center">center</a> (true|false) "false"
&gt;
......
......@@ -384,7 +384,7 @@ public class AsyncBoxView extends View {
/**
* Loads all of the children to initialize the view.
* This is called by the <a href="#setParent">setParent</a>
* 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
......
......@@ -70,7 +70,7 @@ import sun.swing.SwingUtilities2;
* will render a solid color as specified in the associated text component
* in the <code>SelectionColor</code> property. This can easily be changed
* by reimplementing the
* <a href="#getSelectionHighlighter">getSelectionHighlighter</a>
* {@link #getSelectionPainter getSelectionPainter}
* method.
* <p>
* A customized caret appearance can be achieved by reimplementing
......
......@@ -315,7 +315,7 @@ public abstract class TableView extends BoxView {
* updated along the minor axis.
* <p>
* This is implemented to call the
* <a href="#layoutColumns">layoutColumns</a> method, and then
* {@link #layoutColumns layoutColumns} method, and then
* forward to the superclass to actually carry out the layout
* of the tables rows.
*
......
......@@ -117,7 +117,7 @@ A view has the following responsibilities:
what it is prepared to deal with.
<li>The coordinate system is the same as the hosting <code>Component</code>
(i.e. the <code>Component</code> returned by the
<a href="#getContainer">getContainer</a> 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 @@ A view has the following responsibilities:
starting from the root of the view hierarchy.
The methods for doing this are:
<ul>
<li><a href="#insertUpdate">insertUpdate</a>
<li><a href="#removeUpdate">removeUpdate</a>
<li><a href="#changedUpdate">changedUpdate</a>
<li>{@link #insertUpdate insertUpdate}
<li>{@link #removeUpdate removeUpdate}
<li>{@link #changedUpdate changedUpdate}
</ul>
<p>
</dl>
......@@ -497,6 +497,10 @@ public abstract class View implements SwingConstants {
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 @@ public abstract class View implements SwingConstants {
* spread out into the following calls that subclasses can
* reimplement:
* <ol>
* <li><a href="#updateChildren">updateChildren</a> is called
* <li>{@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.
* <li><a href="#forwardUpdate">forwardUpdate</a> is called
* <li>{@link #forwardUpdate forwardUpdate} is called
* to forward the DocumentEvent to the appropriate child views.
* <li><a href="#updateLayout">updateLayout</a> is called to
* <li>{@link #updateLayout updateLayout} is called to
* give the view a chance to either repair its layout, to reschedule
* layout, or do nothing.
* </ol>
......@@ -711,15 +715,15 @@ public abstract class View implements SwingConstants {
* spread out into the following calls that subclasses can
* reimplement:
* <ol>
* <li><a href="#updateChildren">updateChildren</a> is called
* <li>{@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.
* <li><a href="#forwardUpdate">forwardUpdate</a> is called
* <li>{@link #forwardUpdate forwardUpdate} is called
* to forward the DocumentEvent to the appropriate child views.
* <li><a href="#updateLayout">updateLayout</a> is called to
* <li>{@link #updateLayout updateLayout} is called to
* give the view a chance to either repair its layout, to reschedule
* layout, or do nothing.
* </ol>
......@@ -752,15 +756,15 @@ public abstract class View implements SwingConstants {
* spread out into the following calls that subclasses can
* reimplement:
* <ol>
* <li><a href="#updateChildren">updateChildren</a> is called
* <li>{@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.
* <li><a href="#forwardUpdate">forwardUpdate</a> is called
* <li>{@link #forwardUpdate forwardUpdate} is called
* to forward the DocumentEvent to the appropriate child views.
* <li><a href="#updateLayout">updateLayout</a> is called to
* <li>{@link #updateLayout updateLayout} is called to
* give the view a chance to either repair its layout, to reschedule
* layout, or do nothing.
* </ol>
......@@ -1186,7 +1190,7 @@ public abstract class View implements SwingConstants {
* simply messages the view with a call to <code>insertUpdate</code>,
* <code>removeUpdate</code>, or <code>changedUpdate</code> depending
* upon the type of the event. This is called by
* <a href="#forwardUpdate">forwardUpdate</a> to forward
* {@link #forwardUpdate forwardUpdate} to forward
* the event to children that need it.
*
* @param v the child view to forward the event to
......
......@@ -123,7 +123,7 @@ import java.lang.ref.*;
* to load. By default, this kit produces documents that will be
* loaded asynchronously if loaded using <code>JEditorPane.setPage</code>.
* This is controlled by a property on the document. The method
* <a href="#createDefaultDocument">createDefaultDocument</a> can
* {@link #createDefaultDocument createDefaultDocument} can
* be overriden to change this. The batching of work is done
* by the <code>HTMLDocument.HTMLReader</code> class. The actual
* work is done by the <code>DefaultStyledDocument</code> and
......@@ -558,7 +558,7 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible {
* automatically or only <code>FormSubmitEvent</code> is fired.
* By default it is set to true.
*
* @see #isAutoFormSubmission
* @see #isAutoFormSubmission()
* @see FormSubmitEvent
* @since 1.5
*/
......
......@@ -61,7 +61,7 @@ public class ParagraphView extends javax.swing.text.ParagraphView {
* <p>
* This is implemented
* to forward to the superclass as well as call the
* <a href="#setPropertiesFromAttributes">setPropertiesFromAttributes</a>
* {@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
......
......@@ -51,7 +51,7 @@ import javax.swing.text.*;
* <p>
* The primary entry point for HTML View implementations
* to get their attributes is the
* <a href="#getViewAttributes">getViewAttributes</a>
* {@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
......
......@@ -48,7 +48,11 @@ public class ParserDelegator extends HTMLEditorKit.Parser implements Serializabl
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 @@ public class ParserDelegator extends HTMLEditorKit.Parser implements Serializabl
appContext.put(DTD_KEY, dtd);
}
return dtd;
}
protected static DTD createDTD(DTD dtd, String name) {
......@@ -92,7 +98,7 @@ public class ParserDelegator extends HTMLEditorKit.Parser implements Serializabl
}
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);
}
/**
......
/*
* 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);
}
}
}
/*
* 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("<html><body bgcolor=FFFFE1>An HTML-formatted ToolTip</body></html>");
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);
}
}
}
/*
* 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();
}
});
}
}
/*
* 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();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册