8359053: Implement JEP 504 - Remove the Applet API

Reviewed-by: aivanov, kizune, kcr, achung, serb
This commit is contained in:
Phil Race 2025-07-14 20:23:38 +00:00
parent a10ee46e6d
commit 5cf672e778
86 changed files with 296 additions and 3138 deletions

View File

@ -362,7 +362,7 @@ public class RunWindow extends JPanel implements Runnable, ActionListener {
/**
* This class contains initial values for instance variables of 'RunWindow' class,
* and its instance is used in creation of 'RunWindow' object. Values parsed from
* certain command line options of the demo or from the demo applet parameters are
* certain command line options of the demo
* set to the fields of this class instance. It is a part of the fix which changed
* static variables for instance variables in certain demo classes.
*

View File

@ -406,13 +406,6 @@ public final class Tools extends JPanel implements ActionListener,
if (pDialogState) {
printJob.print(aset);
}
} catch (@SuppressWarnings("removal") java.security.AccessControlException ace) {
String errmsg = "Applet access control exception; to allow "
+ "access to printer, set\n"
+ "permission for \"queuePrintJob\" in "
+ "RuntimePermission.";
JOptionPane.showMessageDialog(this, errmsg, "Printer Access Error",
JOptionPane.ERROR_MESSAGE);
} catch (Exception ex) {
Logger.getLogger(Tools.class.getName()).log(Level.SEVERE,
null, ex);

View File

@ -131,7 +131,7 @@ public class SwingSet2 extends JPanel {
private JEditorPane demoSrcPane = null;
// contentPane cache, saved from the applet or application frame
// contentPane cache, saved from the application frame
Container contentPane = null;
@ -177,7 +177,7 @@ public class SwingSet2 extends JPanel {
/**
* SwingSet2 Main. Called only if we're an application, not an applet.
* SwingSet2 Main.
*/
public static void main(final String[] args) {
// must run in EDT when constructing the GUI components
@ -716,8 +716,7 @@ public class SwingSet2 extends JPanel {
}
/**
* Returns the content pane whether we're in an applet
* or application
* Returns the content pane
*/
public Container getContentPane() {
if(contentPane == null) {

View File

@ -431,7 +431,6 @@ public class AquaInternalFrameUI extends BasicInternalFrameUI implements SwingCo
}
@Override
@SuppressWarnings("removal")
public void mouseReleased(final MouseEvent e) {
if (didForwardEvent(e)) return;
@ -467,9 +466,6 @@ public class AquaInternalFrameUI extends BasicInternalFrameUI implements SwingCo
((JFrame)frame.getTopLevelAncestor()).getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
((JFrame)frame.getTopLevelAncestor()).getGlassPane().setVisible(false);
} else if (c instanceof JApplet) {
((JApplet)c).getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
((JApplet)c).getGlassPane().setVisible(false);
} else if (c instanceof JWindow) {
((JWindow)c).getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
((JWindow)c).getGlassPane().setVisible(false);

View File

@ -825,7 +825,7 @@ public class LWWindowPeer
topmostPlatformWindow != null ? topmostPlatformWindow.getPeer() : null;
// topmostWindowPeer == null condition is added for the backward
// compatibility with applets. It can be removed when the
// compatibility. It can be removed when the
// getTopmostPlatformWindowUnderMouse() method will be properly
// implemented in CPlatformEmbeddedFrame class
if (topmostWindowPeer == this || topmostWindowPeer == null) {

View File

@ -433,7 +433,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
// If the target is a dialog, popup or tooltip we want it to ignore the brushed metal look.
if (isPopup) {
styleBits = SET(styleBits, TEXTURED, false);
// Popups in applets don't activate applet's process
styleBits = SET(styleBits, NONACTIVATING, true);
styleBits = SET(styleBits, IS_POPUP, true);
}
@ -714,7 +713,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
boolean isPopup = (target.getType() == Window.Type.POPUP);
execute(ptr -> {
if (isPopup) {
// Popups in applets don't activate applet's process
CWrapper.NSWindow.orderFrontRegardless(ptr);
} else {
CWrapper.NSWindow.orderFront(ptr);

View File

@ -49,7 +49,7 @@
* when we get a punctuation char what was the real hardware key was that
* was pressed? Although '&' often comes from Shift-7 the keyboard can be
* remapped! I don't think there really is a good answer, and hopefully
* all good applets are only interested in logical key typed events not
* all good applications are only interested in logical key typed events not
* press/release. Meanwhile, we are hard-coding the shifted punctuation
* to trigger the virtual keys that are the expected ones under a standard
* keymapping. Looking at Windows & Mac, they don't actually do this, the

View File

@ -43,7 +43,6 @@ There are several problems with Drag and Drop - notably, the mismatch between Ja
@implementation DnDUtilities
// Make sure we don't let other apps see local drags by using a process unique pasteboard type.
// This may not work in the Applet case, since they are all running in the same VM
+ (NSString *) javaPboardType {
static NSString *customJavaPboardType = nil;
if (customJavaPboardType == nil)

View File

@ -25,7 +25,6 @@
package com.sun.java.swing;
import java.applet.Applet;
import java.awt.Component;
import java.awt.Container;
import java.awt.Graphics;
@ -53,9 +52,7 @@ import static sun.java2d.pipe.Region.clipRound;
* releases and even patch releases. You should not rely on this class even
* existing.
*
* This is a second part of sun.swing.SwingUtilities2. It is required
* to provide services for JavaFX applets.
*
* This is a second part of sun.swing.SwingUtilities2.
*/
public class SwingUtilities3 {
/**
@ -91,14 +88,12 @@ public class SwingUtilities3 {
* depends on current RepaintManager's RepaintManager.PaintManager
* and on the capabilities of the graphics hardware/software and what not.
*
* @param rootContainer topmost container. Should be either {@code Window}
* or {@code Applet}
* @param rootContainer topmost container. Should be {@code Window}
* @param isRequested the value to set vsyncRequested state to
*/
@SuppressWarnings("removal")
public static void setVsyncRequested(Container rootContainer,
boolean isRequested) {
assert (rootContainer instanceof Applet) || (rootContainer instanceof Window);
assert (rootContainer instanceof Window);
if (isRequested) {
vsyncedMap.put(rootContainer, Boolean.TRUE);
} else {
@ -109,12 +104,11 @@ public class SwingUtilities3 {
/**
* Checks if vsync painting is requested for {@code rootContainer}
*
* @param rootContainer topmost container. Should be either Window or Applet
* @param rootContainer topmost container. Should be Window
* @return {@code true} if vsync painting is requested for {@code rootContainer}
*/
@SuppressWarnings("removal")
public static boolean isVsyncRequested(Container rootContainer) {
assert (rootContainer instanceof Applet) || (rootContainer instanceof Window);
assert (rootContainer instanceof Window);
return Boolean.TRUE == vsyncedMap.get(rootContainer);
}

View File

@ -25,16 +25,17 @@
package com.sun.media.sound;
import java.applet.AudioClip;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import javax.sound.SoundClip;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MetaEventListener;
import javax.sound.midi.MetaMessage;
@ -59,8 +60,7 @@ import javax.sound.sampled.UnsupportedAudioFileException;
* @author Arthur van Hoff, Kara Kytle, Jan Borgersen
* @author Florian Bomers
*/
@SuppressWarnings("removal")
public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, LineListener {
public final class JavaSoundAudioClip implements MetaEventListener, LineListener {
private long lastPlayCall = 0;
private static final int MINIMUM_PLAY_DELAY = 30;
@ -103,24 +103,28 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
return clip;
}
public static JavaSoundAudioClip create(final URLConnection uc) {
JavaSoundAudioClip clip = new JavaSoundAudioClip();
/* Used [only] by sun.awt.www.content.MultiMediaContentHandlers */
public static SoundClip create(final URLConnection uc) {
File tmpFile = null;
try {
clip.init(uc.getInputStream());
} catch (final Exception ignored) {
// Playing the clip will be a no-op if an exception occured in inititialization.
tmpFile = File.createTempFile("javaurl", ".aud");
} catch (IOException e) {
return null;
}
return clip;
}
public static JavaSoundAudioClip create(final URL url) {
JavaSoundAudioClip clip = new JavaSoundAudioClip();
try {
clip.init(url.openStream());
} catch (final Exception ignored) {
// Playing the clip will be a no-op if an exception occurred in inititialization.
try (InputStream in = uc.getInputStream();
FileOutputStream out = new FileOutputStream(tmpFile)) {
in.transferTo(out);
} catch (IOException e) {
}
return clip;
try {
return SoundClip.createSoundClip(tmpFile);
} catch (IOException e) {
} finally {
tmpFile.delete();
}
return null;
}
private void init(InputStream in) throws IOException {
@ -167,7 +171,6 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
return false;
}
@Override
public synchronized void play() {
if (!success) {
return;
@ -175,7 +178,6 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
startImpl(false);
}
@Override
public synchronized void loop() {
if (!success) {
return;
@ -184,7 +186,7 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
}
private synchronized void startImpl(boolean loop) {
// hack for some applets that call the start method very rapidly...
// hack for some applications that call the start method very rapidly...
long currentTime = System.currentTimeMillis();
long diff = currentTime - lastPlayCall;
if (diff < MINIMUM_PLAY_DELAY) {
@ -247,7 +249,6 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
}
}
@Override
public synchronized void stop() {
if (!success) {
return;

View File

@ -1,609 +0,0 @@
/*
* Copyright (c) 1995, 2025, 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.
*/
package java.applet;
import java.awt.Dimension;
import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.Panel;
import java.awt.event.ComponentEvent;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serial;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleState;
import javax.accessibility.AccessibleStateSet;
import com.sun.media.sound.JavaSoundAudioClip;
/**
* An applet is a small program that is intended not to be run on its own, but
* rather to be embedded inside another application.
* <p>
* The {@code Applet} class must be the superclass of any applet that is to be
* embedded in a Web page or viewed by the Java Applet Viewer. The
* {@code Applet} class provides a standard interface between applets and their
* environment.
*
* @author Arthur van Hoff
* @author Chris Warth
* @since 1.0
* @deprecated The Applet API is deprecated, no replacement.
*/
@Deprecated(since = "9", forRemoval = true)
@SuppressWarnings("removal")
public class Applet extends Panel {
/**
* Constructs a new Applet.
* <p>
* Note: Many methods in {@code java.applet.Applet} may be invoked by the
* applet only after the applet is fully constructed; applet should avoid
* calling methods in {@code java.applet.Applet} in the constructor.
*
* @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
* returns {@code true}
* @see java.awt.GraphicsEnvironment#isHeadless
* @since 1.4
*/
public Applet() throws HeadlessException {
if (GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
}
/**
* Applets can be serialized but the following conventions MUST be followed:
* <p>
* Before Serialization: An applet must be in STOPPED state.
* <p>
* After Deserialization: The applet will be restored in STOPPED state (and
* most clients will likely move it into RUNNING state). The stub field will
* be restored by the reader.
*/
private transient AppletStub stub;
/**
* Use serialVersionUID from JDK 1.0 for interoperability.
*/
@Serial
private static final long serialVersionUID = -5836846270535785031L;
/**
* Read an applet from an object input stream.
*
* @param s the {@code ObjectInputStream} to read
* @throws ClassNotFoundException if the class of a serialized object could
* not be found
* @throws IOException if an I/O error occurs
* @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
* returns {@code true}
*
* @see java.awt.GraphicsEnvironment#isHeadless
* @since 1.4
*/
@Serial
private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException, HeadlessException {
if (GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
s.defaultReadObject();
}
/**
* Sets this applet's stub. This is done automatically by the system.
*
* @param stub the new stub
*/
public final void setStub(AppletStub stub) {
this.stub = stub;
}
/**
* Determines if this applet is active. An applet is marked active just
* before its {@code start} method is called. It becomes inactive just
* before its {@code stop} method is called.
*
* @return {@code true} if the applet is active; {@code false} otherwise
* @see java.applet.Applet#start()
* @see java.applet.Applet#stop()
*/
public boolean isActive() {
if (stub != null) {
return stub.isActive();
} else { // If stub field not filled in, applet never active
return false;
}
}
/**
* Gets the {@code URL} of the document in which this applet is embedded.
* For example, suppose an applet is contained within the document:
* <blockquote><pre>
* http://www.oracle.com/technetwork/java/index.html
* </pre></blockquote>
* The document base is:
* <blockquote><pre>
* http://www.oracle.com/technetwork/java/index.html
* </pre></blockquote>
*
* @return the {@link java.net.URL} of the document that contains this
* applet
* @see java.applet.Applet#getCodeBase()
*/
public URL getDocumentBase() {
return stub.getDocumentBase();
}
/**
* Gets the base {@code URL}. This is the {@code URL} of the directory which
* contains this applet.
*
* @return the base {@link java.net.URL} of the directory which contains
* this applet
* @see java.applet.Applet#getDocumentBase()
*/
public URL getCodeBase() {
return stub.getCodeBase();
}
/**
* Returns the value of the named parameter in the HTML tag. For example, if
* this applet is specified as
* <blockquote><pre>
* &lt;applet code="Clock" width=50 height=50&gt;
* &lt;param name=Color value="blue"&gt;
* &lt;/applet&gt;
* </pre></blockquote>
* <p>
* then a call to {@code getParameter("Color")} returns the value
* {@code "blue"}.
* <p>
* The {@code name} argument is case insensitive.
*
* @param name a parameter name
* @return the value of the named parameter, or {@code null} if not set
*/
public String getParameter(String name) {
return stub.getParameter(name);
}
/**
* Determines this applet's context, which allows the applet to query and
* affect the environment in which it runs.
* <p>
* This environment of an applet represents the document that contains the
* applet.
*
* @return the applet's context
*/
public AppletContext getAppletContext() {
return stub.getAppletContext();
}
/**
* Requests that this applet be resized.
*
* @param width the new requested width for the applet
* @param height the new requested height for the applet
*/
@SuppressWarnings("deprecation")
public void resize(int width, int height) {
Dimension d = size();
if ((d.width != width) || (d.height != height)) {
super.resize(width, height);
if (stub != null) {
stub.appletResize(width, height);
}
}
}
/**
* Requests that this applet be resized.
*
* @param d an object giving the new width and height
*/
@SuppressWarnings("deprecation")
public void resize(Dimension d) {
resize(d.width, d.height);
}
/**
* Indicates if this container is a validate root.
* <p>
* {@code Applet} objects are the validate roots, and, therefore, they
* override this method to return {@code true}.
*
* @return {@code true}
* @see java.awt.Container#isValidateRoot
* @since 1.7
*/
@Override
public boolean isValidateRoot() {
return true;
}
/**
* Requests that the argument string be displayed in the "status window".
* Many browsers and applet viewers provide such a window, where the
* application can inform users of its current state.
*
* @param msg a string to display in the status window
*/
public void showStatus(String msg) {
getAppletContext().showStatus(msg);
}
/**
* Returns an {@code Image} object that can then be painted on the screen.
* The {@code url} that is passed as an argument must specify an absolute
* {@code URL}.
* <p>
* This method always returns immediately, whether or not the image exists.
* When this applet attempts to draw the image on the screen, the data will
* be loaded. The graphics primitives that draw the image will incrementally
* paint on the screen.
*
* @param url an absolute {@code URL} giving the location of the image
* @return the image at the specified {@code URL}
* @see java.awt.Image
*/
public Image getImage(URL url) {
return getAppletContext().getImage(url);
}
/**
* Returns an {@code Image} object that can then be painted on the screen.
* The {@code url} argument must specify an absolute {@code URL}. The
* {@code name} argument is a specifier that is relative to the {@code url}
* argument.
* <p>
* This method always returns immediately, whether or not the image exists.
* When this applet attempts to draw the image on the screen, the data will
* be loaded. The graphics primitives that draw the image will incrementally
* paint on the screen.
*
* @param url an absolute URL giving the base location of the image
* @param name the location of the image, relative to the {@code url}
* argument
* @return the image at the specified {@code URL}
* @see java.awt.Image
*/
public Image getImage(URL url, String name) {
try {
@SuppressWarnings("deprecation")
var u = new URL(url, name);
return getImage(u);
} catch (MalformedURLException e) {
return null;
}
}
/**
* Get an audio clip from the given {@code URL}.
*
* @param url points to the audio clip
* @return the audio clip at the specified {@code URL}
* @since 1.2
*/
public static final AudioClip newAudioClip(URL url) {
return JavaSoundAudioClip.create(url);
}
/**
* Returns the {@code AudioClip} object specified by the {@code URL}
* argument.
* <p>
* This method always returns immediately, whether or not the audio clip
* exists. When this applet attempts to play the audio clip, the data will
* be loaded.
*
* @param url an absolute {@code URL} giving the location of the audio clip
* @return the audio clip at the specified {@code URL}
* @see java.applet.AudioClip
*/
public AudioClip getAudioClip(URL url) {
return getAppletContext().getAudioClip(url);
}
/**
* Returns the {@code AudioClip} object specified by the {@code URL} and
* {@code name} arguments.
* <p>
* This method always returns immediately, whether or not the audio clip
* exists. When this applet attempts to play the audio clip, the data will
* be loaded.
*
* @param url an absolute {@code URL} giving the base location of the audio
* clip
* @param name the location of the audio clip, relative to the {@code url}
* argument
* @return the audio clip at the specified {@code URL}
* @see java.applet.AudioClip
*/
public AudioClip getAudioClip(URL url, String name) {
try {
@SuppressWarnings("deprecation")
var u = new URL(url, name);
return getAudioClip(u);
} catch (MalformedURLException e) {
return null;
}
}
/**
* Returns information about this applet. An applet should override this
* method to return a {@code String} containing information about the
* author, version, and copyright of the applet.
* <p>
* The implementation of this method provided by the {@code Applet} class
* returns {@code null}.
*
* @return a string containing information about the author, version, and
* copyright of the applet
*/
public String getAppletInfo() {
return null;
}
/**
* Gets the locale of the applet. It allows the applet to maintain its own
* locale separated from the locale of the browser or appletviewer.
*
* @return the locale of the applet; if no locale has been set, the default
* locale is returned
* @since 1.1
*/
public Locale getLocale() {
Locale locale = super.getLocale();
if (locale == null) {
return Locale.getDefault();
}
return locale;
}
/**
* Returns information about the parameters that are understood by this
* applet. An applet should override this method to return an array of
* strings describing these parameters.
* <p>
* Each element of the array should be a set of three strings containing the
* name, the type, and a description. For example:
* <blockquote><pre>
* String pinfo[][] = {
* {"fps", "1-10", "frames per second"},
* {"repeat", "boolean", "repeat image loop"},
* {"imgs", "url", "images directory"}
* };
* </pre></blockquote>
* <p>
* The implementation of this method provided by the {@code Applet} class
* returns {@code null}.
*
* @return an array describing the parameters this applet looks for
*/
public String[][] getParameterInfo() {
return null;
}
/**
* Plays the audio clip at the specified absolute {@code URL}. Nothing
* happens if the audio clip cannot be found.
*
* @param url an absolute {@code URL} giving the location of the audio clip
*/
public void play(URL url) {
AudioClip clip = getAudioClip(url);
if (clip != null) {
clip.play();
}
}
/**
* Plays the audio clip given the {@code URL} and a specifier that is
* relative to it. Nothing happens if the audio clip cannot be found.
*
* @param url an absolute {@code URL} giving the base location of the audio
* clip
* @param name the location of the audio clip, relative to the {@code url}
* argument
*/
public void play(URL url, String name) {
AudioClip clip = getAudioClip(url, name);
if (clip != null) {
clip.play();
}
}
/**
* Called by the browser or applet viewer to inform this applet that it has
* been loaded into the system. It is always called before the first time
* that the {@code start} method is called.
* <p>
* A subclass of {@code Applet} should override this method if it has
* initialization to perform. For example, an applet with threads would use
* the {@code init} method to create the threads and the {@code destroy}
* method to kill them.
* <p>
* The implementation of this method provided by the {@code Applet} class
* does nothing.
*
* @see java.applet.Applet#destroy()
* @see java.applet.Applet#start()
* @see java.applet.Applet#stop()
*/
public void init() {
}
/**
* Called by the browser or applet viewer to inform this applet that it
* should start its execution. It is called after the {@code init} method
* and each time the applet is revisited in a Web page.
* <p>
* A subclass of {@code Applet} should override this method if it has any
* operation that it wants to perform each time the Web page containing it
* is visited. For example, an applet with animation might want to use the
* {@code start} method to resume animation, and the {@code stop} method to
* suspend the animation.
* <p>
* Note: some methods, such as {@code getLocationOnScreen}, can only provide
* meaningful results if the applet is showing. Because {@code isShowing}
* returns {@code false} when the applet's {@code start} is first called,
* methods requiring {@code isShowing} to return {@code true} should be
* called from a {@code ComponentListener}.
* <p>
* The implementation of this method provided by the {@code Applet} class
* does nothing.
*
* @see java.applet.Applet#destroy()
* @see java.applet.Applet#init()
* @see java.applet.Applet#stop()
* @see java.awt.Component#isShowing()
* @see java.awt.event.ComponentListener#componentShown(ComponentEvent)
*/
public void start() {
}
/**
* Called by the browser or applet viewer to inform this applet that it
* should stop its execution. It is called when the Web page that contains
* this applet has been replaced by another page, and also just before the
* applet is to be destroyed.
* <p>
* A subclass of {@code Applet} should override this method if it has any
* operation that it wants to perform each time the Web page containing it
* is no longer visible. For example, an applet with animation might want to
* use the {@code start} method to resume animation, and the {@code stop}
* method to suspend the animation.
* <p>
* The implementation of this method provided by the {@code Applet} class
* does nothing.
*
* @see java.applet.Applet#destroy()
* @see java.applet.Applet#init()
*/
public void stop() {
}
/**
* Called by the browser or applet viewer to inform this applet that it is
* being reclaimed and that it should destroy any resources that it has
* allocated. The {@code stop} method will always be called before
* {@code destroy}.
* <p>
* A subclass of {@code Applet} should override this method if it has any
* operation that it wants to perform before it is destroyed. For example,
* an applet with threads would use the {@code init} method to create the
* threads and the {@code destroy} method to kill them.
* <p>
* The implementation of this method provided by the {@code Applet} class
* does nothing.
*
* @see java.applet.Applet#init()
* @see java.applet.Applet#start()
* @see java.applet.Applet#stop()
*/
public void destroy() {
}
//
// Accessibility support
//
/**
* @serial The accessible context associated with this {@code Applet}.
*/
@SuppressWarnings("serial") // Not statically typed as Serializable
AccessibleContext accessibleContext = null;
/**
* Gets the {@code AccessibleContext} associated with this {@code Applet}.
* For applets, the {@code AccessibleContext} takes the form of an
* {@code AccessibleApplet}. A new {@code AccessibleApplet} instance is
* created if necessary.
*
* @return an {@code AccessibleApplet} that serves as the
* {@code AccessibleContext} of this {@code Applet}
* @since 1.3
*/
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleApplet();
}
return accessibleContext;
}
/**
* This class implements accessibility support for the {@code Applet} class.
* It provides an implementation of the Java Accessibility API appropriate
* to applet user-interface elements.
*
* @since 1.3
*/
protected class AccessibleApplet extends AccessibleAWTPanel {
/**
* Use serialVersionUID from JDK 1.3 for interoperability.
*/
@Serial
private static final long serialVersionUID = 8127374778187708896L;
/**
* Constructs an {@code AccessibleApplet}.
*/
protected AccessibleApplet() {}
/**
* Get the role of this object.
*
* @return an instance of {@code AccessibleRole} describing the role of
* the object
*/
public AccessibleRole getAccessibleRole() {
return AccessibleRole.FRAME;
}
/**
* Get the state of this object.
*
* @return an instance of {@code AccessibleStateSet} containing the
* current state set of the object
* @see AccessibleState
*/
public AccessibleStateSet getAccessibleStateSet() {
AccessibleStateSet states = super.getAccessibleStateSet();
states.add(AccessibleState.ACTIVE);
return states;
}
}
}

View File

@ -1,200 +0,0 @@
/*
* Copyright (c) 1995, 2021, 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.
*/
package java.applet;
import java.awt.Image;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.Iterator;
/**
* This interface corresponds to an applet's environment: the document
* containing the applet and the other applets in the same document.
* <p>
* The methods in this interface can be used by an applet to obtain information
* about its environment.
*
* @author Arthur van Hoff
* @since 1.0
* @deprecated The Applet API is deprecated, no replacement.
*/
@Deprecated(since = "9", forRemoval = true)
@SuppressWarnings("removal")
public interface AppletContext {
/**
* Creates an audio clip.
*
* @param url an absolute {@code URL} giving the location of the audio clip
* @return the audio clip at the specified {@code URL}
*/
AudioClip getAudioClip(URL url);
/**
* Returns an {@code Image} object that can then be painted on the screen.
* The {@code url} argument that is passed as an argument must specify an
* absolute {@code URL}.
* <p>
* This method always returns immediately, whether or not the image exists.
* When the applet attempts to draw the image on the screen, the data will
* be loaded. The graphics primitives that draw the image will incrementally
* paint on the screen.
*
* @param url an absolute {@code URL} giving the location of the image
* @return the image at the specified {@code URL}
* @see java.awt.Image
*/
Image getImage(URL url);
/**
* Finds and returns the applet in the document represented by this applet
* context with the given name. The name can be set in the HTML tag by
* setting the {@code name} attribute.
*
* @param name an applet name
* @return the applet with the given name, or {@code null} if not found
*/
Applet getApplet(String name);
/**
* Finds all the applets in the document represented by this applet context.
*
* @return an enumeration of all applets in the document represented by this
* applet context
*/
Enumeration<Applet> getApplets();
/**
* Requests that the browser or applet viewer show the Web page indicated by
* the {@code url} argument. The browser or applet viewer determines which
* window or frame to display the Web page. This method may be ignored by
* applet contexts that are not browsers.
*
* @param url an absolute {@code URL} giving the location of the document
*/
void showDocument(URL url);
/**
* Requests that the browser or applet viewer show the Web page indicated by
* the {@code url} argument. The {@code target} argument indicates in which
* HTML frame the document is to be displayed. The target argument is
* interpreted as follows:
*
* <table class="striped">
* <caption>Target arguments and their descriptions</caption>
* <thead>
* <tr>
* <th scope="col">Target Argument
* <th scope="col">Description
* </thead>
* <tbody>
* <tr>
* <th scope="row">{@code "_self"}
* <td>Show in the window and frame that contain the applet.
* <tr>
* <th scope="row">{@code "_parent"}
* <td>Show in the applet's parent frame. If the applet's frame has no
* parent frame, acts the same as "_self".
* <tr>
* <th scope="row">{@code "_top"}
* <td>Show in the top-level frame of the applet's window. If the
* applet's frame is the top-level frame, acts the same as "_self".
* <tr>
* <th scope="row">{@code "_blank"}
* <td>Show in a new, unnamed top-level window.
* <tr>
* <th scope="row"><i>name</i>
* <td>Show in the frame or window named <i>name</i>. If a target named
* <i>name</i> does not already exist, a new top-level window with the
* specified name is created, and the document is shown there.
* </tbody>
* </table>
* <p>
* An applet viewer or browser is free to ignore {@code showDocument}.
*
* @param url an absolute {@code URL} giving the location of the document
* @param target a {@code String} indicating where to display the page
*/
public void showDocument(URL url, String target);
/**
* Requests that the argument string be displayed in the "status window".
* Many browsers and applet viewers provide such a window, where the
* application can inform users of its current state.
*
* @param status a string to display in the status window
*/
void showStatus(String status);
/**
* Associates the specified stream with the specified key in this applet
* context. If the applet context previously contained a mapping for this
* key, the old value is replaced.
* <p>
* For security reasons, mapping of streams and keys exists for each
* codebase. In other words, applet from one codebase cannot access the
* streams created by an applet from a different codebase
*
* @param key key with which the specified value is to be associated
* @param stream stream to be associated with the specified key. If this
* parameter is {@code null}, the specified key is removed in this
* applet context.
* @throws IOException if the stream size exceeds a certain size limit. Size
* limit is decided by the implementor of this interface.
* @since 1.4
*/
public void setStream(String key, InputStream stream) throws IOException;
/**
* Returns the stream to which specified key is associated within this
* applet context. Returns {@code null} if the applet context contains no
* stream for this key.
* <p>
* For security reasons, mapping of streams and keys exists for each
* codebase. In other words, applet from one codebase cannot access the
* streams created by an applet from a different codebase.
*
* @param key key whose associated stream is to be returned
* @return the stream to which this applet context maps the key
* @since 1.4
*/
public InputStream getStream(String key);
/**
* Finds all the keys of the streams in this applet context.
* <p>
* For security reasons, mapping of streams and keys exists for each
* codebase. In other words, applet from one codebase cannot access the
* streams created by an applet from a different codebase.
*
* @return an {@code Iterator} of all the names of the streams in this
* applet context
* @since 1.4
*/
public Iterator<String> getStreamKeys();
}

View File

@ -1,111 +0,0 @@
/*
* Copyright (c) 1995, 2021, 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.
*/
package java.applet;
import java.net.URL;
/**
* When an applet is first created, an applet stub is attached to it using the
* applet's {@code setStub} method. This stub serves as the interface between
* the applet and the browser environment or applet viewer environment in which
* the application is running.
*
* @author Arthur van Hoff
* @see java.applet.Applet#setStub(java.applet.AppletStub)
* @since 1.0
* @deprecated The Applet API is deprecated, no replacement.
*/
@Deprecated(since = "9", forRemoval = true)
@SuppressWarnings("removal")
public interface AppletStub {
/**
* Determines if the applet is active. An applet is active just before its
* {@code start} method is called. It becomes inactive just before its
* {@code stop} method is called.
*
* @return {@code true} if the applet is active; {@code false} otherwise
*/
boolean isActive();
/**
* Gets the {@code URL} of the document in which the applet is embedded. For
* example, suppose an applet is contained within the document:
* <blockquote><pre>
* http://www.oracle.com/technetwork/java/index.html
* </pre></blockquote>
* The document base is:
* <blockquote><pre>
* http://www.oracle.com/technetwork/java/index.html
* </pre></blockquote>
*
* @return the {@link java.net.URL} of the document that contains the applet
* @see java.applet.AppletStub#getCodeBase()
*/
URL getDocumentBase();
/**
* Gets the base {@code URL}. This is the {@code URL} of the directory which
* contains the applet.
*
* @return the base {@link java.net.URL} of the directory which contains the
* applet
* @see java.applet.AppletStub#getDocumentBase()
*/
URL getCodeBase();
/**
* Returns the value of the named parameter in the HTML tag. For example, if
* an applet is specified as
* <blockquote><pre>
* &lt;applet code="Clock" width=50 height=50&gt;
* &lt;param name=Color value="blue"&gt;
* &lt;/applet&gt;
* </pre></blockquote>
* <p>
* then a call to {@code getParameter("Color")} returns the value
* {@code "blue"}.
*
* @param name a parameter name
* @return the value of the named parameter, or {@code null} if not set
*/
String getParameter(String name);
/**
* Returns the applet's context.
*
* @return the applet's context
*/
AppletContext getAppletContext();
/**
* Called when the applet wants to be resized.
*
* @param width the new requested width for the applet
* @param height the new requested height for the applet
*/
void appletResize(int width, int height);
}

View File

@ -1,55 +0,0 @@
/*
* Copyright (c) 1995, 2021, 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.
*/
package java.applet;
/**
* The {@code AudioClip} interface is a simple abstraction for playing a sound
* clip. Multiple {@code AudioClip} items can be playing at the same time, and
* the resulting sound is mixed together to produce a composite.
*
* @author Arthur van Hoff
* @since 1.0
* @deprecated The Applet API is deprecated, no replacement.
*/
@Deprecated(since = "9", forRemoval = true)
public interface AudioClip {
/**
* Starts playing this audio clip. Each time this method is called, the clip
* is restarted from the beginning.
*/
void play();
/**
* Starts playing this audio clip in a loop.
*/
void loop();
/**
* Stops playing this audio clip.
*/
void stop();
}

View File

@ -1,47 +0,0 @@
/*
* Copyright (c) 1998, 2021, 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.
*/
/**
* Provides the classes necessary to create an applet and the classes an applet
* uses to communicate with its applet context.
* <p>
* The applet framework involves two entities: the <i>applet</i> and the
* <i>applet context</i>. An applet is an embeddable window (see the Panel
* class) with a few extra methods that the applet context can use to
* initialize, start, and stop the applet.
* <p>
* The applet context is an application that is responsible for loading and
* running applets. For example, the applet context could be a Web browser or an
* applet development environment.
* <p>
* This package has been deprecated and may be removed in
* a future version of the Java Platform. There is no replacement.
* All of the classes and interfaces in this package have been terminally
* deprecated.
* Users are advised to migrate their applications to other technologies.
*
* @since 1.0
*/
package java.applet;

View File

@ -25,7 +25,6 @@
package java.awt;
import java.applet.Applet;
import java.awt.dnd.DropTarget;
import java.awt.event.ActionEvent;
import java.awt.event.AdjustmentEvent;
@ -237,8 +236,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
transient Container parent;
/**
* The {@code AppContext} of the component. Applets/Plugin may
* change the AppContext.
* The {@code AppContext} of the component.
*/
transient AppContext appContext;
@ -3937,10 +3935,9 @@ public abstract class Component implements ImageObserver, MenuContainer,
/**
* Inner class for flipping buffers on a component. That component must
* be a {@code Canvas} or {@code Window} or {@code Applet}.
* be a {@code Canvas} or {@code Window}.
* @see Canvas
* @see Window
* @see Applet
* @see java.awt.image.BufferStrategy
* @author Michael Martak
* @since 1.4
@ -3988,11 +3985,9 @@ public abstract class Component implements ImageObserver, MenuContainer,
/**
* Creates a new flipping buffer strategy for this component.
* The component must be a {@code Canvas} or {@code Window} or
* {@code Applet}.
* The component must be a {@code Canvas} or {@code Window}.
* @see Canvas
* @see Window
* @see Applet
* @param numBuffers the number of buffers
* @param caps the capabilities of the buffers
* @throws AWTException if the capabilities supplied could not be
@ -4010,11 +4005,10 @@ public abstract class Component implements ImageObserver, MenuContainer,
throws AWTException
{
if (!(Component.this instanceof Window) &&
!(Component.this instanceof Canvas) &&
!(Component.this instanceof Applet))
!(Component.this instanceof Canvas))
{
throw new ClassCastException(
"Component must be a Canvas or Window or Applet");
"Component must be a Canvas or Window");
}
this.numBuffers = numBuffers;
this.caps = caps;
@ -8161,12 +8155,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
focusLog.finer("default component is " + toFocus);
}
}
if (toFocus == null) {
Applet applet = EmbeddedFrame.getAppletIfAncestorOf(this);
if (applet != null) {
toFocus = applet;
}
}
candidate = toFocus;
}
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {

View File

@ -1557,8 +1557,8 @@ public class Container extends Component {
* as a {@code Frame} object) should be used to restore the validity of the
* component hierarchy.
* <p>
* The {@code Window} class and the {@code Applet} class are the validate
* roots in AWT. Swing introduces more validate roots.
* The {@code Window} class is the validate root in AWT.
* Swing introduces more validate roots.
*
* @return whether this container is a validate root
* @see #invalidate

View File

@ -165,18 +165,11 @@ public class Dialog extends Window {
/**
* An {@code APPLICATION_MODAL} dialog blocks all top-level windows
* from the same Java application except those from its own child hierarchy.
* If there are several applets launched in a browser, they can be
* treated either as separate applications or a single one. This behavior
* is implementation-dependent.
*/
APPLICATION_MODAL,
/**
* A {@code TOOLKIT_MODAL} dialog blocks all top-level windows run
* from the same toolkit except those from its own child hierarchy. If there
* are several applets launched in a browser, all of them run with the same
* toolkit; thus, a toolkit-modal dialog displayed by an applet may affect
* other applets and all windows of the browser instance which embeds the
* Java runtime environment for this toolkit.
* from the same toolkit except those from its own child hierarchy.
*/
TOOLKIT_MODAL
}

View File

@ -67,15 +67,6 @@ import java.util.concurrent.atomic.AtomicInteger;
* dispatched before event A.
* </dl>
* <p>
* Some browsers partition applets in different code bases into
* separate contexts, and establish walls between these contexts.
* In such a scenario, there will be one {@code EventQueue}
* per context. Other browsers place all applets into the same
* context, implying that there will be only a single, global
* {@code EventQueue} for all applets. This behavior is
* implementation-dependent. Consult your browser's documentation
* for more information.
* <p>
* For information on the threading issues of the event dispatch
* machinery, see <a href="doc-files/AWTThreadIssues.html#Autoshutdown"
* >AWT Threading Issues</a>.

View File

@ -1123,8 +1123,6 @@ public class Frame extends Window implements MenuContainer {
/**
* Returns an array of all {@code Frame}s created by this application.
* If called from an applet, the array includes only the {@code Frame}s
* accessible by that applet.
* <p>
* <b>Warning:</b> this method may return system created frames, such
* as a shared, hidden frame which is used by Swing. Applications

View File

@ -292,8 +292,7 @@ public abstract class GraphicsEnvironment {
* be used in constructing new {@code Font}s by name or family name,
* and is enumerated by {@link #getAvailableFontFamilyNames} and
* {@link #getAllFonts} within the execution context of this
* application or applet. This means applets cannot register fonts in
* a way that they are visible to other applets.
* application.
* <p>
* Reasons that this method might not register the font and therefore
* return {@code false} are:

View File

@ -71,16 +71,6 @@ import sun.awt.AWTAccessor;
* dispatcher for all FocusEvents, WindowEvents related to focus, and
* KeyEvents.
* <p>
* Some browsers partition applets in different code bases into separate
* contexts, and establish walls between these contexts. In such a scenario,
* there will be one KeyboardFocusManager per context. Other browsers place all
* applets into the same context, implying that there will be only a single,
* global KeyboardFocusManager for all applets. This behavior is
* implementation-dependent. Consult your browser's documentation for more
* information. No matter how many contexts there may be, however, there can
* never be more than one focus owner, focused Window, or active Window, per
* ClassLoader.
* <p>
* Please see
* <a href="https://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
@ -1177,7 +1167,7 @@ public abstract class KeyboardFocusManager
* following:
* <ul>
* <li>whether the KeyboardFocusManager is currently managing focus
* for this application or applet's browser context
* for this application
* ("managingFocus")</li>
* <li>the focus owner ("focusOwner")</li>
* <li>the permanent focus owner ("permanentFocusOwner")</li>
@ -1262,7 +1252,7 @@ public abstract class KeyboardFocusManager
* following:
* <ul>
* <li>whether the KeyboardFocusManager is currently managing focus
* for this application or applet's browser context
* for this application
* ("managingFocus")</li>
* <li>the focus owner ("focusOwner")</li>
* <li>the permanent focus owner ("permanentFocusOwner")</li>

View File

@ -160,7 +160,7 @@ public class Polygon implements Shape, java.io.Serializable {
if (npoints < 0) {
throw new NegativeArraySizeException("npoints < 0");
}
// Fix 6343431: Applet compatibility problems if arrays are not
// Fix 6343431: compatibility problems if arrays are not
// exactly npoints in length
this.npoints = npoints;
this.xpoints = Arrays.copyOf(xpoints, npoints);

View File

@ -306,10 +306,7 @@ public class SystemTray {
/**
* Returns an array of all icons added to the tray by this
* application. You can't access the icons added by another
* application. Some browsers partition applets in different
* code bases into separate contexts, and establish walls between
* these contexts. In such a scenario, only the tray icons added
* from this context will be returned.
* application.
*
* <p> The returned array is a copy of the actual array and may be
* modified in any way without affecting the system tray. To

View File

@ -1350,22 +1350,16 @@ public abstract class Toolkit {
}
/**
* Get the application's or applet's EventQueue instance.
* Depending on the Toolkit implementation, different EventQueues
* may be returned for different applets. Applets should
* therefore not assume that the EventQueue instance returned
* by this method will be shared by other applets or the system.
*
* @return the {@code EventQueue} object
* {@return the {@code EventQueue} for this application}
*/
public final EventQueue getSystemEventQueue() {
return getSystemEventQueueImpl();
}
/**
* Gets the application's or applet's {@code EventQueue}
* instance, without checking access. For security reasons,
* this can only be called from a {@code Toolkit} subclass.
* A method used by toolkit subclasses to get the {@code EventQueue}.
* This may be more direct or more efficient than calling
* {@code getSystemEventQueue()}.
* @return the {@code EventQueue} object
*/
protected abstract EventQueue getSystemEventQueueImpl();

View File

@ -1520,8 +1520,6 @@ public class Window extends Container implements Accessible {
/**
* Returns an array of all {@code Window}s, both owned and ownerless,
* created by this application.
* If called from an applet, the array includes only the {@code Window}s
* accessible by that applet.
* <p>
* <b>Warning:</b> this method may return system created windows, such
* as a print dialog. Applications should not assume the existence of
@ -1543,8 +1541,6 @@ public class Window extends Container implements Accessible {
* Returns an array of all {@code Window}s created by this application
* that have no owner. They include {@code Frame}s and ownerless
* {@code Dialog}s and {@code Window}s.
* If called from an applet, the array includes only the {@code Window}s
* accessible by that applet.
* <p>
* <b>Warning:</b> this method may return system created windows, such
* as a print dialog. Applications should not assume the existence of
@ -3865,7 +3861,7 @@ public class Window extends Container implements Accessible {
if (content != null) {
content.setOpaque(isOpaque);
// Iterate down one level to see whether we have a JApplet
// Iterate down one level to see whether we have (eg) a JInternalFrame
// (which is also a RootPaneContainer) which requires processing
int numChildren = content.getComponentCount();
if (numChildren > 0) {

View File

@ -81,7 +81,6 @@
across platforms. This document has the following sections:
<ul>
<li><a href=#Overview>Overview of KeyboardFocusManager</a>
<li><a href=#BrowserContexts>KeyboardFocusManager and Browser Contexts</a>
<li><a href=#KeyEventDispatcher>KeyEventDispatcher</a>
<li><a href=#FocusEventAndWindowEvent>FocusEvent and WindowEvent</a>
<li><a href=#EventDelivery>Event Delivery</a>
@ -213,22 +212,6 @@
implementation in the <code>DefaultKeyboardFocusManager</code> class.
<a id="BrowserContexts"></a>
<h2>KeyboardFocusManager and Browser Contexts</h2>
<p>
Some browsers partition applets in different code bases into separate
contexts, and establish walls between these contexts. Each thread and
each Component is associated with a particular context and cannot
interfere with threads or access Components in other contexts. In such
a scenario, there will be one KeyboardFocusManager per context. Other
browsers place all applets into the same context, implying that there
will be only a single, global KeyboardFocusManager for all
applets. This behavior is implementation-dependent. Consult your
browser's documentation for more information. No matter how many
contexts there may be, however, there can never be more than one focus
owner, focused Window, or active Window, per ClassLoader.
<a id="KeyEventDispatcher"></a>
<h2>KeyEventDispatcher and KeyEventPostProcessor</h2>
<p>

View File

@ -117,16 +117,9 @@
</li><li>Application-modal dialogs<br>
An application-modal dialog blocks all windows from the same
application except for those from its child hierarchy.
If there are several applets launched in a browser, they can be
treated either as separate applications or a single application.
This behavior is implementation-dependent.
</li><li>Toolkit-modal dialogs<br>
A toolkit-modal dialog blocks all windows that run in the same
toolkit except those from its child hierarchy. If there
are several applets launched all of them run with the same toolkit,
so a toolkit-modal dialog shown from an applet may affect other
applets and all windows of the browser instance which embeds the
Java runtime environment for this toolkit.
toolkit except those from its child hierarchy.
</li></ol>
<p>
Modality priority is arranged by the strength of blocking: modeless,
@ -356,8 +349,8 @@
calls: <code>Dialog.setModal(true)</code>,
<code>Dialog(owner, true)</code>, etc. Prior to JDK 6
the default type was toolkit-modal,
but the only distinction between application- and toolkit-modality is for
applets and applications launched from Java Web Start.
and now with single application per-VM there is no
distinction between application- and toolkit-modality.
<a id="Examples"></a>
</p><h2>Examples</h2>

View File

@ -1,90 +0,0 @@
/*
* Copyright (c) 1997, 2021, 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.
*/
package java.beans;
import java.applet.Applet;
import java.beans.beancontext.BeanContext;
/**
* This interface is designed to work in collusion with java.beans.Beans.instantiate.
* The interface is intended to provide mechanism to allow the proper
* initialization of JavaBeans that are also Applets, during their
* instantiation by java.beans.Beans.instantiate().
*
* @see java.beans.Beans#instantiate
*
* @since 1.2
*
* @deprecated The Applet API is deprecated. See the
* <a href="../applet/package-summary.html"> java.applet package
* documentation</a> for further information.
*/
@Deprecated(since = "9", forRemoval = true)
public interface AppletInitializer {
/**
* <p>
* If passed to the appropriate variant of java.beans.Beans.instantiate
* this method will be called in order to associate the newly instantiated
* Applet (JavaBean) with its AppletContext, AppletStub, and Container.
* </p>
* <p>
* Conformant implementations shall:
* <ol>
* <li> Associate the newly instantiated Applet with the appropriate
* AppletContext.
*
* <li> Instantiate an AppletStub() and associate that AppletStub with
* the Applet via an invocation of setStub().
*
* <li> If BeanContext parameter is null, then it shall associate the
* Applet with its appropriate Container by adding that Applet to its
* Container via an invocation of add(). If the BeanContext parameter is
* non-null, then it is the responsibility of the BeanContext to associate
* the Applet with its Container during the subsequent invocation of its
* addChildren() method.
* </ol>
*
* @param newAppletBean The newly instantiated JavaBean
* @param bCtxt The BeanContext intended for this Applet, or
* null.
*/
@SuppressWarnings("removal")
void initialize(Applet newAppletBean, BeanContext bCtxt);
/**
* <p>
* Activate, and/or mark Applet active. Implementors of this interface
* shall mark this Applet as active, and optionally invoke its start()
* method.
* </p>
*
* @param newApplet The newly instantiated JavaBean
*/
@SuppressWarnings("removal")
void activate(Applet newApplet);
}

View File

@ -27,11 +27,6 @@ package java.beans;
import com.sun.beans.finder.ClassFinder;
import java.applet.Applet;
import java.applet.AppletContext;
import java.applet.AppletStub;
import java.applet.AudioClip;
import java.awt.Image;
import java.beans.beancontext.BeanContext;
@ -82,7 +77,7 @@ public class Beans {
*/
public static Object instantiate(ClassLoader cls, String beanName) throws IOException, ClassNotFoundException {
return Beans.instantiate(cls, beanName, null, null);
return Beans.instantiate(cls, beanName, null);
}
/**
@ -109,73 +104,6 @@ public class Beans {
public static Object instantiate(ClassLoader cls, String beanName,
BeanContext beanContext)
throws IOException, ClassNotFoundException {
return Beans.instantiate(cls, beanName, beanContext, null);
}
/**
* Instantiate a bean.
* <p>
* The bean is created based on a name relative to a class-loader.
* This name should be a dot-separated name such as "a.b.c".
* <p>
* In Beans 1.0 the given name can indicate either a serialized object
* or a class. Other mechanisms may be added in the future. In
* beans 1.0 we first try to treat the beanName as a serialized object
* name then as a class name.
* <p>
* When using the beanName as a serialized object name we convert the
* given beanName to a resource pathname and add a trailing ".ser" suffix.
* We then try to load a serialized object from that resource.
* <p>
* For example, given a beanName of "x.y", Beans.instantiate would first
* try to read a serialized object from the resource "x/y.ser" and if
* that failed it would try to load the class "x.y" and create an
* instance of that class.
* <p>
* If the bean is a subtype of java.applet.Applet, then it is given
* some special initialization. First, it is supplied with a default
* AppletStub and AppletContext. Second, if it was instantiated from
* a classname the applet's "init" method is called. (If the bean was
* deserialized this step is skipped.)
* <p>
* Note that for beans which are applets, it is the caller's responsibility
* to call "start" on the applet. For correct behaviour, this should be done
* after the applet has been added into a visible AWT container.
* <p>
* Note that applets created via beans.instantiate run in a slightly
* different environment than applets running inside browsers. In
* particular, bean applets have no access to "parameters", so they may
* wish to provide property get/set methods to set parameter values. We
* advise bean-applet developers to test their bean-applets against both
* the JDK appletviewer (for a reference browser environment) and the
* BDK BeanBox (for a reference bean container).
*
* @return a JavaBean
* @param cls the class-loader from which we should create
* the bean. If this is null, then the system
* class-loader is used.
* @param beanName the name of the bean within the class-loader.
* For example "sun.beanbox.foobah"
* @param beanContext The BeanContext in which to nest the new bean
* @param initializer The AppletInitializer for the new bean
*
* @throws ClassNotFoundException if the class of a serialized
* object could not be found.
* @throws IOException if an I/O error occurs.
* @since 1.2
*
* @deprecated It is recommended to use
* {@link #instantiate(ClassLoader, String, BeanContext)},
* because the Applet API is deprecated. See the
* <a href="../../java/applet/package-summary.html"> java.applet package
* documentation</a> for further information.
*/
@Deprecated(since = "9", forRemoval = true)
@SuppressWarnings("removal")
public static Object instantiate(ClassLoader cls, String beanName,
BeanContext beanContext,
AppletInitializer initializer)
throws IOException, ClassNotFoundException {
InputStream ins;
ObjectInputStream oins = null;
@ -249,101 +177,7 @@ public class Beans {
}
if (result != null) {
// Ok, if the result is an applet initialize it.
AppletStub stub = null;
if (result instanceof Applet) {
Applet applet = (Applet) result;
boolean needDummies = initializer == null;
if (needDummies) {
// Figure our the codebase and docbase URLs. We do this
// by locating the URL for a known resource, and then
// massaging the URL.
// First find the "resource name" corresponding to the bean
// itself. So a serialized bean "a.b.c" would imply a
// resource name of "a/b/c.ser" and a classname of "x.y"
// would imply a resource name of "x/y.class".
final String resourceName;
if (serialized) {
// Serialized bean
resourceName = beanName.replace('.','/').concat(".ser");
} else {
// Regular class
resourceName = beanName.replace('.','/').concat(".class");
}
URL objectUrl = null;
URL codeBase = null;
URL docBase = null;
// Now get the URL corresponding to the resource name.
if (cls == null) {
objectUrl = ClassLoader.getSystemResource(resourceName);
} else
objectUrl = cls.getResource(resourceName);
// If we found a URL, we try to locate the docbase by taking
// of the final path name component, and the code base by taking
// of the complete resourceName.
// So if we had a resourceName of "a/b/c.class" and we got an
// objectURL of "file://bert/classes/a/b/c.class" then we would
// want to set the codebase to "file://bert/classes/" and the
// docbase to "file://bert/classes/a/b/"
if (objectUrl != null) {
String s = objectUrl.toExternalForm();
if (s.endsWith(resourceName)) {
int ix = s.length() - resourceName.length();
codeBase = newURL(s.substring(0,ix));
docBase = codeBase;
ix = s.lastIndexOf('/');
if (ix >= 0) {
docBase = newURL(s.substring(0,ix+1));
}
}
}
// Setup a default context and stub.
BeansAppletContext context = new BeansAppletContext(applet);
stub = (AppletStub)new BeansAppletStub(applet, context, codeBase, docBase);
applet.setStub(stub);
} else {
initializer.initialize(applet, beanContext);
}
// now, if there is a BeanContext, add the bean, if applicable.
if (beanContext != null) {
unsafeBeanContextAdd(beanContext, result);
}
// If it was deserialized then it was already init-ed.
// Otherwise we need to initialize it.
if (!serialized) {
// We need to set a reasonable initial size, as many
// applets are unhappy if they are started without
// having been explicitly sized.
applet.setSize(100,100);
applet.init();
}
if (needDummies) {
((BeansAppletStub)stub).active = true;
} else initializer.activate(applet);
} else if (beanContext != null) unsafeBeanContextAdd(beanContext, result);
if (beanContext != null) unsafeBeanContextAdd(beanContext, result);
}
return result;
@ -482,138 +316,3 @@ class ObjectInputStreamWithLoader extends ObjectInputStream
return ClassFinder.resolveClass(cname, this.loader);
}
}
/**
* Package private support class. This provides a default AppletContext
* for beans which are applets.
*/
@Deprecated(since = "9", forRemoval = true)
@SuppressWarnings("removal")
class BeansAppletContext implements AppletContext {
Applet target;
Hashtable<URL,Object> imageCache = new Hashtable<>();
BeansAppletContext(Applet target) {
this.target = target;
}
public AudioClip getAudioClip(URL url) {
// We don't currently support audio clips in the Beans.instantiate
// applet context, unless by some luck there exists a URL content
// class that can generate an AudioClip from the audio URL.
try {
return (AudioClip) url.getContent();
} catch (Exception ex) {
return null;
}
}
public synchronized Image getImage(URL url) {
Object o = imageCache.get(url);
if (o != null) {
return (Image)o;
}
try {
o = url.getContent();
if (o == null) {
return null;
}
if (o instanceof Image) {
imageCache.put(url, o);
return (Image) o;
}
// Otherwise it must be an ImageProducer.
Image img = target.createImage((java.awt.image.ImageProducer)o);
imageCache.put(url, img);
return img;
} catch (Exception ex) {
return null;
}
}
public Applet getApplet(String name) {
return null;
}
public Enumeration<Applet> getApplets() {
Vector<Applet> applets = new Vector<>();
applets.addElement(target);
return applets.elements();
}
public void showDocument(URL url) {
// We do nothing.
}
public void showDocument(URL url, String target) {
// We do nothing.
}
public void showStatus(String status) {
// We do nothing.
}
public void setStream(String key, InputStream stream)throws IOException{
// We do nothing.
}
public InputStream getStream(String key){
// We do nothing.
return null;
}
public Iterator<String> getStreamKeys(){
// We do nothing.
return null;
}
}
/**
* Package private support class. This provides an AppletStub
* for beans which are applets.
*/
@Deprecated(since = "9", forRemoval = true)
@SuppressWarnings("removal")
class BeansAppletStub implements AppletStub {
transient boolean active;
transient Applet target;
transient AppletContext context;
transient URL codeBase;
transient URL docBase;
BeansAppletStub(Applet target,
AppletContext context, URL codeBase,
URL docBase) {
this.target = target;
this.context = context;
this.codeBase = codeBase;
this.docBase = docBase;
}
public boolean isActive() {
return active;
}
public URL getDocumentBase() {
// use the root directory of the applet's class-loader
return docBase;
}
public URL getCodeBase() {
// use the directory where we found the class or serialized object.
return codeBase;
}
public String getParameter(String name) {
return null;
}
public AppletContext getAppletContext() {
return context;
}
public void appletResize(int width, int height) {
// we do nothing.
}
}

View File

@ -34,7 +34,7 @@ package java.beans;
* The JavaBeans specification defines the notion of design time as is a
* mode in which JavaBeans instances should function during their composition
* and customization in a interactive design, composition or construction tool,
* as opposed to runtime when the JavaBean is part of an applet, application,
* as opposed to runtime when the JavaBean is part of an application,
* or other live Java executable abstraction.
*
* @author Laurence P. G. Cable

View File

@ -952,7 +952,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
* are intended to be delivered by the subclasser - ie supplier of the
* metadataformat. For the standard format and all standard plugins that
* is the JDK. For 3rd party plugins that they will supply their own.
* This includes plugins bundled with applets/applications.
* This includes plugins bundled with applications.
* In all cases this means it is sufficient to search for those resource
* in the module that is providing the MetadataFormatImpl subclass.
*/

View File

@ -110,9 +110,7 @@ public final class IIORegistry extends ServiceRegistry {
* the Image I/O API. This instance should be used for all
* registry functions.
*
* <p> Each {@code ThreadGroup} will receive its own
* instance; this allows different {@code Applet}s in the
* same browser (for example) to each have their own registry.
* <p> Each {@code ThreadGroup} will receive its own instance.
*
* @return the default registry for the current
* {@code ThreadGroup}.

View File

@ -534,8 +534,7 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
Container root = c;
xOffset = yOffset = 0;
while (root != null &&
(!(root instanceof Window) &&
!SunToolkit.isInstanceOf(root, "java.applet.Applet"))) {
(!(root instanceof Window))) {
xOffset += root.getX();
yOffset += root.getY();
root = root.getParent();
@ -687,7 +686,7 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
}
/**
* Returns the Root (Window or Applet) that this BufferInfo references.
* Returns the Root (Window) that this BufferInfo references.
*/
public Container getRoot() {
return (root == null) ? null : root.get();
@ -793,30 +792,14 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
null);
}
BufferStrategy bs = null;
if (SunToolkit.isInstanceOf(root, "java.applet.Applet")) {
try {
AWTAccessor.ComponentAccessor componentAccessor
= AWTAccessor.getComponentAccessor();
componentAccessor.createBufferStrategy(root, 2, caps);
bs = componentAccessor.getBufferStrategy(root);
} catch (AWTException e) {
// Type is not supported
if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) {
LOGGER.finer("createBufferStrategy failed",
e);
}
}
}
else {
try {
((Window)root).createBufferStrategy(2, caps);
bs = ((Window)root).getBufferStrategy();
} catch (AWTException e) {
// Type not supported
if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) {
LOGGER.finer("createBufferStrategy failed",
e);
}
try {
((Window)root).createBufferStrategy(2, caps);
bs = ((Window)root).getBufferStrategy();
} catch (AWTException e) {
// Type not supported
if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) {
LOGGER.finer("createBufferStrategy failed",
e);
}
}
return bs;

View File

@ -1,580 +0,0 @@
/*
* Copyright (c) 1997, 2021, 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.
*/
package javax.swing;
import java.applet.Applet;
import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.HeadlessException;
import java.awt.LayoutManager;
import java.beans.BeanProperty;
import java.beans.JavaBean;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
/**
* An extended version of <code>java.applet.Applet</code> that adds support for
* the JFC/Swing component architecture.
* You can find task-oriented documentation about using <code>JApplet</code>
* in <em>The Java Tutorial</em>,
* in the section
* <a
href="https://docs.oracle.com/javase/tutorial/uiswing/components/applet.html">How to Make Applets</a>.
* <p>
* The <code>JApplet</code> class is slightly incompatible with
* <code>java.applet.Applet</code>. <code>JApplet</code> contains a
* <code>JRootPane</code> as its only child. The <code>contentPane</code>
* should be the parent of any children of the <code>JApplet</code>.
* As a convenience, the {@code add}, {@code remove}, and {@code setLayout}
* methods of this class are overridden, so that they delegate calls
* to the corresponding methods of the {@code ContentPane}.
* For example, you can add a child component to an applet as follows:
* <pre>
* applet.add(child);
* </pre>
*
* And the child will be added to the <code>contentPane</code>.
* The <code>contentPane</code> will always be non-<code>null</code>.
* Attempting to set it to <code>null</code> will cause the
* <code>JApplet</code> to throw an exception. The default
* <code>contentPane</code> will have a <code>BorderLayout</code>
* manager set on it.
* Refer to {@link javax.swing.RootPaneContainer}
* for details on adding, removing and setting the <code>LayoutManager</code>
* of a <code>JApplet</code>.
* <p>
* Please see the <code>JRootPane</code> documentation for a
* complete description of the <code>contentPane</code>, <code>glassPane</code>,
* and <code>layeredPane</code> properties.
* <p>
* <strong>Warning:</strong> Swing is not thread safe. For more
* information see <a
* href="package-summary.html#threading">Swing's Threading
* Policy</a>.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see javax.swing.RootPaneContainer
*
* @author Arnaud Weber
* @since 1.2
*
* @deprecated The Applet API is deprecated, no replacement.
*/
@Deprecated(since = "9", forRemoval = true)
@JavaBean(defaultProperty = "JMenuBar", description = "Swing's Applet subclass.")
@SwingContainer(delegate = "getContentPane")
@SuppressWarnings({"serial", "removal"}) // Same-version serialization only
public class JApplet extends Applet implements Accessible,
RootPaneContainer,
TransferHandler.HasGetTransferHandler
{
/**
* The <code>JRootPane</code> instance that manages the
* <code>contentPane</code>.
*
* @see #getRootPane
* @see #setRootPane
*/
protected JRootPane rootPane;
/**
* If true then calls to <code>add</code> and <code>setLayout</code>
* will be forwarded to the <code>contentPane</code>. This is initially
* false, but is set to true when the <code>JApplet</code> is constructed.
*
* @see #isRootPaneCheckingEnabled
* @see #setRootPaneCheckingEnabled
* @see javax.swing.RootPaneContainer
*/
protected boolean rootPaneCheckingEnabled = false;
/**
* The <code>TransferHandler</code> for this applet.
*/
private TransferHandler transferHandler;
/**
* Creates a swing applet instance.
* <p>
* This constructor sets the component's locale property to the value
* returned by <code>JComponent.getDefaultLocale</code>.
*
* @throws HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
* @see JComponent#getDefaultLocale
*/
public JApplet() throws HeadlessException {
super();
// Check the timerQ and restart if necessary.
TimerQueue q = TimerQueue.sharedInstance();
if(q != null) {
q.startIfNeeded();
}
/* Workaround for bug 4155072. The shared double buffer image
* may hang on to a reference to this applet; unfortunately
* Image.getGraphics() will continue to call JApplet.getForeground()
* and getBackground() even after this applet has been destroyed.
* So we ensure that these properties are non-null here.
*/
setForeground(Color.black);
setBackground(Color.white);
setLocale( JComponent.getDefaultLocale() );
setLayout(new BorderLayout());
setRootPane(createRootPane());
setRootPaneCheckingEnabled(true);
setFocusTraversalPolicyProvider(true);
sun.awt.SunToolkit.checkAndSetPolicy(this);
enableEvents(AWTEvent.KEY_EVENT_MASK);
}
/**
* Called by the constructor methods to create the default rootPane.
*
* @return a new {@code JRootPane}
*/
protected JRootPane createRootPane() {
JRootPane rp = new JRootPane();
// NOTE: this uses setOpaque vs LookAndFeel.installProperty as there
// is NO reason for the RootPane not to be opaque. For painting to
// work the contentPane must be opaque, therefore the RootPane can
// also be opaque.
rp.setOpaque(true);
return rp;
}
/**
* Sets the {@code transferHandler} property, which is a mechanism to
* support transfer of data into this component. Use {@code null}
* if the component does not support data transfer operations.
* <p>
* If the system property {@code suppressSwingDropSupport} is {@code false}
* (the default) and the current drop target on this component is either
* {@code null} or not a user-set drop target, this method will change the
* drop target as follows: If {@code newHandler} is {@code null} it will
* clear the drop target. If not {@code null} it will install a new
* {@code DropTarget}.
* <p>
* Note: When used with {@code JApplet}, {@code TransferHandler} only
* provides data import capability, as the data export related methods
* are currently typed to {@code JComponent}.
* <p>
* Please see
* <a href="https://docs.oracle.com/javase/tutorial/uiswing/dnd/index.html">
* How to Use Drag and Drop and Data Transfer</a>, a section in
* <em>The Java Tutorial</em>, for more information.
*
* @param newHandler the new {@code TransferHandler}
*
* @see TransferHandler
* @see #getTransferHandler
* @see java.awt.Component#setDropTarget
* @since 1.6
*/
@BeanProperty(hidden = true, description
= "Mechanism for transfer of data into the component")
public void setTransferHandler(TransferHandler newHandler) {
TransferHandler oldHandler = transferHandler;
transferHandler = newHandler;
SwingUtilities.installSwingDropTargetAsNecessary(this, transferHandler);
firePropertyChange("transferHandler", oldHandler, newHandler);
}
/**
* Gets the <code>transferHandler</code> property.
*
* @return the value of the <code>transferHandler</code> property
*
* @see TransferHandler
* @see #setTransferHandler
* @since 1.6
*/
public TransferHandler getTransferHandler() {
return transferHandler;
}
/**
* Just calls <code>paint(g)</code>. This method was overridden to
* prevent an unnecessary call to clear the background.
*/
public void update(Graphics g) {
paint(g);
}
/**
* Sets the menubar for this applet.
* @param menuBar the menubar being placed in the applet
*
* @see #getJMenuBar
*/
@BeanProperty(bound = false, hidden = true, description
= "The menubar for accessing pulldown menus from this applet.")
public void setJMenuBar(final JMenuBar menuBar) {
getRootPane().setJMenuBar(menuBar);
}
/**
* Returns the menubar set on this applet.
*
* @return the menubar set on this applet
* @see #setJMenuBar
*/
public JMenuBar getJMenuBar() {
return getRootPane().getJMenuBar();
}
/**
* Returns whether calls to <code>add</code> and
* <code>setLayout</code> are forwarded to the <code>contentPane</code>.
*
* @return true if <code>add</code> and <code>setLayout</code>
* are forwarded; false otherwise
*
* @see #addImpl
* @see #setLayout
* @see #setRootPaneCheckingEnabled
* @see javax.swing.RootPaneContainer
*/
protected boolean isRootPaneCheckingEnabled() {
return rootPaneCheckingEnabled;
}
/**
* Sets whether calls to <code>add</code> and
* <code>setLayout</code> are forwarded to the <code>contentPane</code>.
*
* @param enabled true if <code>add</code> and <code>setLayout</code>
* are forwarded, false if they should operate directly on the
* <code>JApplet</code>.
*
* @see #addImpl
* @see #setLayout
* @see #isRootPaneCheckingEnabled
* @see javax.swing.RootPaneContainer
*/
@BeanProperty(hidden = true, description
= "Whether the add and setLayout methods are forwarded")
protected void setRootPaneCheckingEnabled(boolean enabled) {
rootPaneCheckingEnabled = enabled;
}
/**
* Adds the specified child <code>Component</code>.
* This method is overridden to conditionally forward calls to the
* <code>contentPane</code>.
* By default, children are added to the <code>contentPane</code> instead
* of the frame, refer to {@link javax.swing.RootPaneContainer} for
* details.
*
* @param comp the component to be enhanced
* @param constraints the constraints to be respected
* @param index the index
* @throws IllegalArgumentException if <code>index</code> is invalid
* @throws IllegalArgumentException if adding the container's parent
* to itself
* @throws IllegalArgumentException if adding a window to a container
*
* @see #setRootPaneCheckingEnabled
* @see javax.swing.RootPaneContainer
*/
protected void addImpl(Component comp, Object constraints, int index)
{
if(isRootPaneCheckingEnabled()) {
getContentPane().add(comp, constraints, index);
}
else {
super.addImpl(comp, constraints, index);
}
}
/**
* Removes the specified component from the container. If
* <code>comp</code> is not the <code>rootPane</code>, this will forward
* the call to the <code>contentPane</code>. This will do nothing if
* <code>comp</code> is not a child of the <code>JFrame</code> or
* <code>contentPane</code>.
*
* @param comp the component to be removed
* @throws NullPointerException if <code>comp</code> is null
* @see #add
* @see javax.swing.RootPaneContainer
*/
public void remove(Component comp) {
if (comp == rootPane) {
super.remove(comp);
} else {
getContentPane().remove(comp);
}
}
/**
* Sets the <code>LayoutManager</code>.
* Overridden to conditionally forward the call to the
* <code>contentPane</code>.
* Refer to {@link javax.swing.RootPaneContainer} for
* more information.
*
* @param manager the <code>LayoutManager</code>
* @see #setRootPaneCheckingEnabled
* @see javax.swing.RootPaneContainer
*/
public void setLayout(LayoutManager manager) {
if(isRootPaneCheckingEnabled()) {
getContentPane().setLayout(manager);
}
else {
super.setLayout(manager);
}
}
/**
* Returns the rootPane object for this applet.
*
* @see #setRootPane
* @see RootPaneContainer#getRootPane
*/
@BeanProperty(bound = false, hidden = true, description
= "the RootPane object for this applet.")
public JRootPane getRootPane() {
return rootPane;
}
/**
* Sets the rootPane property. This method is called by the constructor.
* @param root the rootPane object for this applet
*
* @see #getRootPane
*/
protected void setRootPane(JRootPane root) {
if(rootPane != null) {
remove(rootPane);
}
rootPane = root;
if(rootPane != null) {
boolean checkingEnabled = isRootPaneCheckingEnabled();
try {
setRootPaneCheckingEnabled(false);
add(rootPane, BorderLayout.CENTER);
}
finally {
setRootPaneCheckingEnabled(checkingEnabled);
}
}
}
/**
* Returns the contentPane object for this applet.
*
* @see #setContentPane
* @see RootPaneContainer#getContentPane
*/
public Container getContentPane() {
return getRootPane().getContentPane();
}
/**
* Sets the contentPane property. This method is called by the constructor.
* @param contentPane the contentPane object for this applet
*
* @throws java.awt.IllegalComponentStateException (a runtime
* exception) if the content pane parameter is null
* @see #getContentPane
* @see RootPaneContainer#setContentPane
*/
@BeanProperty(bound = false, hidden = true, description
= "The client area of the applet where child components are normally inserted.")
public void setContentPane(Container contentPane) {
getRootPane().setContentPane(contentPane);
}
/**
* Returns the layeredPane object for this applet.
*
* @throws java.awt.IllegalComponentStateException (a runtime
* exception) if the layered pane parameter is null
* @see #setLayeredPane
* @see RootPaneContainer#getLayeredPane
*/
public JLayeredPane getLayeredPane() {
return getRootPane().getLayeredPane();
}
/**
* Sets the layeredPane property. This method is called by the constructor.
* @param layeredPane the layeredPane object for this applet
*
* @see #getLayeredPane
* @see RootPaneContainer#setLayeredPane
*/
@BeanProperty(bound = false, hidden = true, description
= "The pane which holds the various applet layers.")
public void setLayeredPane(JLayeredPane layeredPane) {
getRootPane().setLayeredPane(layeredPane);
}
/**
* Returns the glassPane object for this applet.
*
* @see #setGlassPane
* @see RootPaneContainer#getGlassPane
*/
public Component getGlassPane() {
return getRootPane().getGlassPane();
}
/**
* Sets the glassPane property.
* This method is called by the constructor.
* @param glassPane the glassPane object for this applet
*
* @see #getGlassPane
* @see RootPaneContainer#setGlassPane
*/
@BeanProperty(bound = false, hidden = true, description
= "A transparent pane used for menu rendering.")
public void setGlassPane(Component glassPane) {
getRootPane().setGlassPane(glassPane);
}
/**
* {@inheritDoc}
*
* @since 1.6
*/
@BeanProperty(bound = false)
public Graphics getGraphics() {
JComponent.getGraphicsInvoked(this);
return super.getGraphics();
}
/**
* Repaints the specified rectangle of this component within
* <code>time</code> milliseconds. Refer to <code>RepaintManager</code>
* for details on how the repaint is handled.
*
* @param time maximum time in milliseconds before update
* @param x the <i>x</i> coordinate
* @param y the <i>y</i> coordinate
* @param width the width
* @param height the height
* @see RepaintManager
* @since 1.6
*/
public void repaint(long time, int x, int y, int width, int height) {
if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
RepaintManager.currentManager(this).addDirtyRegion(
this, x, y, width, height);
}
else {
super.repaint(time, x, y, width, height);
}
}
/**
* Returns a string representation of this JApplet. This method
* is intended to be used only for debugging purposes, and the
* content and format of the returned string may vary between
* implementations. The returned string may be empty but may not
* be <code>null</code>.
*
* @return a string representation of this JApplet.
*/
protected String paramString() {
String rootPaneString = (rootPane != null ?
rootPane.toString() : "");
String rootPaneCheckingEnabledString = (rootPaneCheckingEnabled ?
"true" : "false");
return super.paramString() +
",rootPane=" + rootPaneString +
",rootPaneCheckingEnabled=" + rootPaneCheckingEnabledString;
}
/////////////////
// Accessibility support
////////////////
/**
* {@code AccessibleContext} associated with this {@code JApplet}
*/
protected AccessibleContext accessibleContext = null;
/**
* Gets the AccessibleContext associated with this JApplet.
* For JApplets, the AccessibleContext takes the form of an
* AccessibleJApplet.
* A new AccessibleJApplet instance is created if necessary.
*
* @return an AccessibleJApplet that serves as the
* AccessibleContext of this JApplet
*/
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJApplet();
}
return accessibleContext;
}
/**
* This class implements accessibility support for the
* <code>JApplet</code> class.
*/
protected class AccessibleJApplet extends AccessibleApplet {
/**
* Constructs an {@code AccessibleJApplet}.
*/
protected AccessibleJApplet() {}
// everything moved to new parent, AccessibleApplet
}
}

View File

@ -25,7 +25,6 @@
package javax.swing;
import java.applet.Applet;
import java.awt.AWTEvent;
import java.awt.AWTKeyStroke;
import java.awt.Color;
@ -106,8 +105,7 @@ import static javax.swing.ClientPropertyKey.JComponent_TRANSFER_HANDLER;
* you must place the component in a containment hierarchy
* whose root is a top-level Swing container.
* Top-level Swing containers --
* such as <code>JFrame</code>, <code>JDialog</code>,
* and <code>JApplet</code> --
* such as <code>JFrame</code> and <code>JDialog</code> --
* are specialized components
* that provide a place for other Swing components to paint themselves.
* For an explanation of containment hierarchies, see
@ -609,7 +607,6 @@ public abstract class JComponent extends Container implements Serializable,
* @see #setComponentPopupMenu
* @since 1.5
*/
@SuppressWarnings("removal")
public JPopupMenu getComponentPopupMenu() {
if(!getInheritsPopupMenu()) {
@ -623,8 +620,7 @@ public abstract class JComponent extends Container implements Serializable,
if(parent instanceof JComponent) {
return ((JComponent)parent).getComponentPopupMenu();
}
if(parent instanceof Window ||
parent instanceof Applet) {
if(parent instanceof Window) {
// Reached toplevel, break and return null
break;
}
@ -2838,11 +2834,6 @@ public abstract class JComponent extends Container implements Serializable,
* Returns the default locale used to initialize each JComponent's
* locale property upon creation.
*
* The default locale has "AppContext" scope so that applets (and
* potentially multiple lightweight applications running in a single VM)
* can have their own setting. An applet can safely alter its default
* locale because it will have no affect on other applets (or the browser).
*
* @return the default <code>Locale</code>.
* @see #setDefaultLocale
* @see java.awt.Component#getLocale
@ -2865,10 +2856,6 @@ public abstract class JComponent extends Container implements Serializable,
* Sets the default locale used to initialize each JComponent's locale
* property upon creation. The initial value is the VM's default locale.
*
* The default locale has "AppContext" scope so that applets (and
* potentially multiple lightweight applications running in a single VM)
* can have their own setting. An applet can safely alter its default
* locale because it will have no affect on other applets (or the browser).
* Passing {@code null} will reset the current locale back
* to VM's default locale.
*
@ -2978,7 +2965,7 @@ public abstract class JComponent extends Container implements Serializable,
* @param pressed true if the key is pressed
* @return true if there is a key binding for <code>e</code>
*/
@SuppressWarnings({"deprecation", "removal"})
@SuppressWarnings("deprecation")
boolean processKeyBindings(KeyEvent e, boolean pressed) {
if (!SwingUtilities.isValidKeyEventForKeyBindings(e)) {
return false;
@ -3015,8 +3002,7 @@ public abstract class JComponent extends Container implements Serializable,
* asking the same component twice.
*/
Container parent = this;
while (parent != null && !(parent instanceof Window) &&
!(parent instanceof Applet)) {
while (parent != null && !(parent instanceof Window)) {
if(parent instanceof JComponent) {
if(ksE != null && ((JComponent)parent).processKeyBinding(ksE, e,
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, pressed))
@ -4534,12 +4520,11 @@ public abstract class JComponent extends Container implements Serializable,
* return value for this method
* @see #getVisibleRect
*/
@SuppressWarnings("removal")
static final void computeVisibleRect(Component c, Rectangle visibleRect) {
Container p = c.getParent();
Rectangle bounds = c.getBounds();
if (p == null || p instanceof Window || p instanceof Applet) {
if (p == null || p instanceof Window) {
visibleRect.setBounds(0, 0, bounds.width, bounds.height);
} else {
computeVisibleRect(p, visibleRect);
@ -4694,8 +4679,8 @@ public abstract class JComponent extends Container implements Serializable,
/**
* Returns the top-level ancestor of this component (either the
* containing <code>Window</code> or <code>Applet</code>),
* Returns the top-level ancestor of this component (the
* containing <code>Window</code>)
* or <code>null</code> if this component has not
* been added to any container.
*
@ -4703,10 +4688,9 @@ public abstract class JComponent extends Container implements Serializable,
* or <code>null</code> if not in any container
*/
@BeanProperty(bound = false)
@SuppressWarnings("removal")
public Container getTopLevelAncestor() {
for(Container p = this; p != null; p = p.getParent()) {
if(p instanceof Window || p instanceof Applet) {
if(p instanceof Window) {
return p;
}
}
@ -5126,7 +5110,7 @@ public abstract class JComponent extends Container implements Serializable,
JComponent paintingComponent = this;
RepaintManager repaintManager = RepaintManager.currentManager(this);
// parent Container's up to Window or Applet. First container is
// parent Container's up to Window. First container is
// the direct parent. Note that in testing it was faster to
// alloc a new Vector vs keeping a stack of them around, and gc
// seemed to have a minimal effect on this.
@ -5156,7 +5140,7 @@ public abstract class JComponent extends Container implements Serializable,
}
Component child;
for (c = this, child = null;
c != null && !(c instanceof Window) && !(c instanceof Applet);
c != null && !(c instanceof Window);
child = c, c = c.getParent()) {
JComponent jc = (c instanceof JComponent) ? (JComponent)c :
null;

View File

@ -1339,8 +1339,7 @@ public class JEditorPane extends JTextComponent {
/**
* This is invoked every time the registries are accessed. Loading
* is done this way instead of via a static as the static is only
* called once when running in plugin resulting in the entries only
* appearing in the first applet.
* called once when running in an AppContext.
*/
private static void loadDefaultKitsIfNecessary() {
if (SwingUtilities.appContextGet(kitTypeRegistryKey) == null) {

View File

@ -1316,11 +1316,7 @@ public class JOptionPane extends JComponent implements Accessible
/* Since all input will be blocked until this dialog is dismissed,
* make sure its parent containers are visible first (this component
* is tested below). This is necessary for JApplets, because
* because an applet normally isn't made visible until after its
* start() method returns -- if this method is called from start(),
* the applet will appear to hang while an invisible modal frame
* waits for input.
* is tested below).
*/
if (dialog.isVisible() && !dialog.isShowing()) {
Container parent = dialog.getParent();
@ -1460,11 +1456,7 @@ public class JOptionPane extends JComponent implements Accessible
/* Since all input will be blocked until this dialog is dismissed,
* make sure its parent containers are visible first (this component
* is tested below). This is necessary for JApplets, because
* because an applet normally isn't made visible until after its
* start() method returns -- if this method is called from start(),
* the applet will appear to hang while an invisible modal frame
* waits for input.
* is tested below).
*/
if (dialog.isVisible() && !dialog.isShowing()) {
Container parent = dialog.getParent();

View File

@ -34,7 +34,7 @@ import java.io.Serializable;
/**
* A lightweight container used behind the scenes by
* <code>JFrame</code>, <code>JDialog</code>, <code>JWindow</code>,
* <code>JApplet</code>, and <code>JInternalFrame</code>.
* and <code>JInternalFrame</code>.
* For task-oriented information on functionality provided by root panes
* see <a href="https://docs.oracle.com/javase/tutorial/uiswing/components/rootpane.html">How to Use Root Panes</a>,
* a section in <em>The Java Tutorial</em>.
@ -42,21 +42,18 @@ import java.io.Serializable;
* <p>
* The following image shows the relationships between
* the classes that use root panes.
* <p style="text-align:center"><img src="doc-files/JRootPane-1.gif"
* <p style="text-align:center"><img src="doc-files/JRootPane-1.svg"
* alt="The following text describes this graphic."
* HEIGHT=484 WIDTH=629></p>
* HEIGHT=600 WIDTH=850></p>
* The &quot;heavyweight&quot; components (those that delegate to a peer, or native
* component on the host system) are shown with a darker, heavier box. The four
* heavyweight JFC/Swing containers (<code>JFrame</code>, <code>JDialog</code>,
* <code>JWindow</code>, and <code>JApplet</code>) are
* shown in relation to the AWT classes they extend.
* These four components are the
* only heavyweight containers in the Swing library. The lightweight container
* <code>JInternalFrame</code> is also shown.
* All five of these JFC/Swing containers implement the
* <code>RootPaneContainer</code> interface,
* and they all delegate their operations to a
* <code>JRootPane</code> (shown with a little "handle" on top).
* component on the host system) are shown with a heavier box. AWT components in red,
* Swing heavyweights in blue.
* The three heavyweight JFC/Swing containers ({@code JFrame}, {@code JDialog}, and
* {@code JWindow}) are shown in relation to the AWT classes they extend.
* These three components are the only heavyweight containers in the Swing library.
* The lightweight container {@code JInternalFrame} is also shown in green with thin outline.
* All four of these JFC/Swing containers implement the {@code RootPaneContainer} interface,
* and they all delegate their operations to a {@code JRootPane}.
* <blockquote>
* <b>Note:</b> The <code>JComponent</code> method <code>getRootPane</code>
* can be used to obtain the <code>JRootPane</code> that contains
@ -179,7 +176,6 @@ import java.io.Serializable;
* @see JWindow
* @see JFrame
* @see JDialog
* @see JApplet
* @see JInternalFrame
* @see JComponent
* @see BoxLayout

View File

@ -25,7 +25,6 @@
package javax.swing;
import java.applet.Applet;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
@ -6122,7 +6121,6 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
this.focusManager = fm;
}
@SuppressWarnings("removal")
public void propertyChange(PropertyChangeEvent ev) {
if (!isEditing() || getClientProperty("terminateEditOnFocusLost") != Boolean.TRUE) {
return;
@ -6133,8 +6131,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
if (c == JTable.this) {
// focus remains inside the table
return;
} else if ((c instanceof Window) ||
(c instanceof Applet && c.getParent() == null)) {
} else if (c instanceof Window) {
if (c == SwingUtilities.getRoot(JTable.this)) {
if (!getCellEditor().stopCellEditing()) {
getCellEditor().cancelCellEditing();

View File

@ -378,7 +378,7 @@ public class JViewport extends JComponent implements Accessible
* To avoid excessive validation when the containment hierarchy is
* being created this will not validate if one of the ancestors does not
* have a peer, or there is no validate root ancestor, or one of the
* ancestors is not a <code>Window</code> or <code>Applet</code>.
* ancestors is not a <code>Window</code>.
* <p>
* Note that this method will not scroll outside of the
* valid viewport; for example, if <code>contentRect</code> is larger

View File

@ -28,7 +28,6 @@ package javax.swing;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import sun.awt.EmbeddedFrame;
/**
@ -130,13 +129,12 @@ class KeyboardManager {
}
/**
* Find the top focusable Window, Applet, or InternalFrame
* Find the top focusable Window, or InternalFrame
*/
@SuppressWarnings("removal")
private static Container getTopAncestor(JComponent c) {
for(Container p = c.getParent(); p != null; p = p.getParent()) {
if (p instanceof Window && ((Window)p).isFocusableWindow() ||
p instanceof Applet || p instanceof JInternalFrame) {
p instanceof JInternalFrame) {
return p;
}

View File

@ -25,7 +25,6 @@
package javax.swing;
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
@ -274,7 +273,6 @@ public class PopupFactory {
* Obtains the appropriate <code>Popup</code> based on
* <code>popupType</code>.
*/
@SuppressWarnings("removal")
private Popup getPopup(Component owner, Component contents,
int ownerX, int ownerY, int popupType) {
if (GraphicsEnvironment.isHeadless()) {
@ -288,10 +286,6 @@ public class PopupFactory {
return getMediumWeightPopup(owner, contents, ownerX, ownerY);
case HEAVY_WEIGHT_POPUP:
Popup popup = getHeavyWeightPopup(owner, contents, ownerX, ownerY);
if ((OSInfo.getOSType() == OSInfo.OSType.MACOSX) && (owner != null) &&
(EmbeddedFrame.getAppletIfAncestorOf(owner) != null)) {
((HeavyWeightPopup)popup).setCacheEnabled(false);
}
return popup;
}
return null;
@ -626,7 +620,6 @@ public class PopupFactory {
* Returns true if popup can fit the screen and the owner's top parent.
* It determines can popup be lightweight or mediumweight.
*/
@SuppressWarnings("removal")
boolean fitsOnScreen() {
boolean result = false;
Component component = getComponent();
@ -656,12 +649,6 @@ public class PopupFactory {
result = parentBounds
.contains(x, y, popupWidth, popupHeight);
}
} else if (parent instanceof JApplet) {
Rectangle parentBounds = parent.getBounds();
Point p = parent.getLocationOnScreen();
parentBounds.x = p.x;
parentBounds.y = p.y;
result = parentBounds.contains(x, y, popupWidth, popupHeight);
}
}
return result;
@ -795,7 +782,6 @@ public class PopupFactory {
recycleLightWeightPopup(this);
}
@SuppressWarnings("removal")
public void show() {
Container parent = null;
@ -817,11 +803,6 @@ public class PopupFactory {
parent = p;
}
break;
} else if (p instanceof JApplet) {
// Painting code stops at Applets, we don't want
// to add to a Component above an Applet otherwise
// you'll never see it painted.
break;
}
}
@ -948,7 +929,6 @@ public class PopupFactory {
recycleMediumWeightPopup(this);
}
@SuppressWarnings("removal")
public void show() {
Component component = getComponent();
Container parent = null;
@ -961,7 +941,7 @@ public class PopupFactory {
if it has a layered pane,
add to that, otherwise
add to the window. */
while (!(parent instanceof Window || parent instanceof Applet) &&
while (!(parent instanceof Window) &&
(parent!=null)) {
parent = parent.getParent();
}

View File

@ -30,7 +30,6 @@ import java.awt.event.*;
import java.awt.image.VolatileImage;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.applet.*;
import sun.awt.AWTAccessor;
import sun.awt.AppContext;
@ -52,8 +51,8 @@ import sun.swing.SwingUtilities2.RepaintListener;
* requests into a single repaint for members of a component tree.
* <p>
* As of 1.6 <code>RepaintManager</code> handles repaint requests
* for Swing's top level components (<code>JApplet</code>,
* <code>JWindow</code>, <code>JFrame</code> and <code>JDialog</code>).
* for Swing's top level components
* (<code>JWindow</code>, <code>JFrame</code> and <code>JDialog</code>).
* Any calls to <code>repaint</code> on one of these will call into the
* appropriate <code>addDirtyRegion</code> method.
*
@ -406,7 +405,6 @@ public class RepaintManager
*
* @see JComponent#repaint
*/
@SuppressWarnings("removal")
private void addDirtyRegion0(Container c, int x, int y, int w, int h) {
/* Special cases we don't have to bother with.
*/
@ -424,7 +422,7 @@ public class RepaintManager
return;
}
/* Make sure that c and all it ancestors (up to an Applet or
/* Make sure that c and all it ancestors (up to a
* Window) are visible. This loop has the same effect as
* checking c.isShowing() (and note that it's still possible
* that c is completely obscured by an opaque ancestor in
@ -440,7 +438,7 @@ public class RepaintManager
if (!p.isVisible() || !p.isDisplayable()) {
return;
}
if ((p instanceof Window) || (p instanceof Applet)) {
if (p instanceof Window) {
// Iconified frames are still visible!
if (p instanceof Frame &&
(((Frame)p).getExtendedState() & Frame.ICONIFIED) ==
@ -508,29 +506,6 @@ public class RepaintManager
addDirtyRegion0(window, x, y, w, h);
}
/**
* Adds <code>applet</code> to the list of <code>Component</code>s that
* need to be repainted.
*
* @param applet Applet to repaint, null results in nothing happening.
* @param x X coordinate of the region to repaint
* @param y Y coordinate of the region to repaint
* @param w Width of the region to repaint
* @param h Height of the region to repaint
* @see JApplet#repaint
* @since 1.6
*
* @deprecated The Applet API is deprecated. See the
* <a href="../../java/applet/package-summary.html"> java.applet package
* documentation</a> for further information.
*/
@Deprecated(since = "9", forRemoval = true)
@SuppressWarnings("removal")
public void addDirtyRegion(Applet applet, int x, int y, int w, int h) {
addDirtyRegion0(applet, x, y, w, h);
}
@SuppressWarnings("removal")
void scheduleHeavyWeightPaints() {
Map<Container,Rectangle> hws;
@ -547,10 +522,6 @@ public class RepaintManager
addDirtyRegion((Window)hw, dirty.x, dirty.y,
dirty.width, dirty.height);
}
else if (hw instanceof Applet) {
addDirtyRegion((Applet)hw, dirty.x, dirty.y,
dirty.width, dirty.height);
}
else { // SwingHeavyWeight
addDirtyRegion0(hw, dirty.x, dirty.y,
dirty.width, dirty.height);

View File

@ -31,7 +31,7 @@ import java.awt.Container;
/**
* This interface is implemented by components that have a single
* JRootPane child: JDialog, JFrame, JWindow, JApplet, JInternalFrame.
* JRootPane child: JDialog, JFrame, JWindow, JInternalFrame.
* The methods in this interface are just <i>covers</i> for the JRootPane
* properties, e.g. <code>getContentPane()</code> is generally implemented
* like this:<pre>
@ -46,7 +46,7 @@ import java.awt.Container;
* as <code>frame.getContentPane().add(child)</code>.
* <p>
* As a convenience, the standard classes that implement this interface
* (such as {@code JFrame}, {@code JDialog}, {@code JWindow}, {@code JApplet},
* (such as {@code JFrame}, {@code JDialog}, {@code JWindow},
* and {@code JInternalFrame}) have their {@code add}, {@code remove},
* and {@code setLayout} methods overridden, so that they delegate calls
* to the corresponding methods of the {@code ContentPane}.
@ -62,7 +62,7 @@ import java.awt.Container;
* The behavior of the <code>add</code> and
* <code>setLayout</code> methods for
* <code>JFrame</code>, <code>JDialog</code>, <code>JWindow</code>,
* <code>JApplet</code> and <code>JInternalFrame</code> is controlled by
* and <code>JInternalFrame</code> is controlled by
* the <code>rootPaneCheckingEnabled</code> property. If this property is
* true (the default), then calls to these methods are
* forwarded to the <code>contentPane</code>; if false, these
@ -73,7 +73,6 @@ import java.awt.Container;
* @see JFrame
* @see JDialog
* @see JWindow
* @see JApplet
* @see JInternalFrame
*
* @author Hans Muller

View File

@ -34,7 +34,7 @@ import sun.awt.event.IgnorePaintEvent;
/**
* Swing's PaintEventDispatcher. If the component specified by the PaintEvent
* is a top level Swing component (JFrame, JWindow, JDialog, JApplet), this
* is a top level Swing component (JFrame, JWindow, JDialog), this
* will forward the request to the RepaintManager for eventual painting.
*
*/

View File

@ -27,8 +27,6 @@ package javax.swing;
import sun.swing.SwingUtilities2;
import sun.swing.UIAction;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.dnd.DropTarget;
@ -416,7 +414,6 @@ public class SwingUtilities implements SwingConstants
* @param p a Point object (converted to the new coordinate system)
* @param c a Component object
*/
@SuppressWarnings("removal")
public static void convertPointToScreen(Point p,Component c) {
Rectangle b;
int x,y;
@ -425,8 +422,7 @@ public class SwingUtilities implements SwingConstants
if(c instanceof JComponent) {
x = c.getX();
y = c.getY();
} else if(c instanceof java.applet.Applet ||
c instanceof java.awt.Window) {
} else if(c instanceof java.awt.Window) {
try {
Point pp = c.getLocationOnScreen();
x = pp.x;
@ -443,7 +439,7 @@ public class SwingUtilities implements SwingConstants
p.x += x;
p.y += y;
if(c instanceof java.awt.Window || c instanceof java.applet.Applet)
if(c instanceof java.awt.Window)
break;
c = c.getParent();
} while(c != null);
@ -456,7 +452,6 @@ public class SwingUtilities implements SwingConstants
* @param p a Point object (converted to the new coordinate system)
* @param c a Component object
*/
@SuppressWarnings("removal")
public static void convertPointFromScreen(Point p,Component c) {
Rectangle b;
int x,y;
@ -465,8 +460,7 @@ public class SwingUtilities implements SwingConstants
if(c instanceof JComponent) {
x = c.getX();
y = c.getY();
} else if(c instanceof java.applet.Applet ||
c instanceof java.awt.Window) {
} else if (c instanceof java.awt.Window) {
try {
Point pp = c.getLocationOnScreen();
x = pp.x;
@ -483,7 +477,7 @@ public class SwingUtilities implements SwingConstants
p.x -= x;
p.y -= y;
if(c instanceof java.awt.Window || c instanceof java.applet.Applet)
if(c instanceof java.awt.Window)
break;
c = c.getParent();
} while(c != null);
@ -1655,20 +1649,15 @@ public class SwingUtilities implements SwingConstants
* Returns the root component for the current component tree.
*
* @param c the component
* @return the first ancestor of c that's a Window or the last Applet ancestor
* @return the first ancestor of c that's a Window
*/
@SuppressWarnings("removal")
public static Component getRoot(Component c) {
Component applet = null;
for(Component p = c; p != null; p = p.getParent()) {
if (p instanceof Window) {
return p;
}
if (p instanceof Applet) {
applet = p;
}
}
return applet;
return null;
}
static JComponent getPaintingOrigin(JComponent c) {
@ -1698,7 +1687,6 @@ public class SwingUtilities implements SwingConstants
* @return true if a binding has found and processed
* @since 1.4
*/
@SuppressWarnings("removal")
public static boolean processKeyBindings(KeyEvent event) {
if (event != null) {
if (event.isConsumed()) {
@ -1718,9 +1706,8 @@ public class SwingUtilities implements SwingConstants
return ((JComponent)component).processKeyBindings(
event, pressed);
}
if ((component instanceof Applet) ||
(component instanceof Window)) {
// No JComponents, if Window or Applet parent, process
if (component instanceof Window) {
// No JComponents, if Window parent, process
// WHEN_IN_FOCUSED_WINDOW bindings.
return JComponent.processKeyBindingsForAllComponents(
event, (Container)component, pressed);
@ -2202,8 +2189,7 @@ public class SwingUtilities implements SwingConstants
* CellRendererPane}.
* <p>
* The component hierarchy must be displayable up to the toplevel component
* (either a {@code Frame} or an {@code Applet} object.) Otherwise this
* method returns {@code null}.
* (a {@code Frame}). Otherwise this method returns {@code null}.
* <p>
* If the {@code visibleOnly} argument is {@code true}, the found validate
* root and all its parents up to the toplevel component must also be
@ -2214,7 +2200,6 @@ public class SwingUtilities implements SwingConstants
* @see java.awt.Component#isVisible()
* @since 1.7
*/
@SuppressWarnings("removal")
static Container getValidateRoot(Container c, boolean visibleOnly) {
Container root = null;
@ -2237,7 +2222,7 @@ public class SwingUtilities implements SwingConstants
if (!c.isDisplayable() || (visibleOnly && !c.isVisible())) {
return null;
}
if (c instanceof Window || c instanceof Applet) {
if (c instanceof Window) {
return root;
}
}

View File

@ -174,7 +174,7 @@ public class Timer implements Serializable
// This field is maintained by TimerQueue.
// eventQueued can also be reset by the TimerQueue, but will only ever
// happen in applet case when TimerQueues thread is destroyed.
// happen in an AppContext case when TimerQueues thread is destroyed.
// access to this field is synchronized on getLock() lock.
transient TimerQueue.DelayedTimer delayedTimer = null;

View File

@ -794,7 +794,6 @@ public final class ToolTipManager extends MouseAdapter implements MouseMotionLis
// Returns: 0 no adjust
// -1 can't fit
// >0 adjust value by amount returned
@SuppressWarnings("removal")
private int getPopupFitWidth(Rectangle popupRectInScreen, Component invoker){
if (invoker != null){
Container parent;
@ -803,7 +802,7 @@ public final class ToolTipManager extends MouseAdapter implements MouseMotionLis
if(parent instanceof JFrame || parent instanceof JDialog ||
parent instanceof JWindow) { // no check for awt.Frame since we use Heavy tips
return getWidthAdjust(parent.getBounds(),popupRectInScreen);
} else if (parent instanceof JApplet || parent instanceof JInternalFrame) {
} else if (parent instanceof JInternalFrame) {
if (popupFrameRect == null){
popupFrameRect = new Rectangle();
}
@ -828,7 +827,7 @@ public final class ToolTipManager extends MouseAdapter implements MouseMotionLis
if(parent instanceof JFrame || parent instanceof JDialog ||
parent instanceof JWindow) {
return getHeightAdjust(parent.getBounds(),popupRectInScreen);
} else if (parent instanceof JApplet || parent instanceof JInternalFrame) {
} else if (parent instanceof JInternalFrame) {
if (popupFrameRect == null){
popupFrameRect = new Rectangle();
}

View File

@ -180,10 +180,8 @@ public class UIManager implements Serializable
* Swing applications the fields in this class could just as well
* be static members of <code>UIManager</code> however we give them
* "AppContext"
* scope instead so that applets (and potentially multiple lightweight
* applications running in a single VM) have their own state. For example,
* an applet can alter its look and feel, see <code>setLookAndFeel</code>.
* Doing so has no affect on other applets (or the browser).
* scope instead so that potentially multiple lightweight
* applications running in a single VM have their own state.
*/
private static class LAFState
{
@ -1455,8 +1453,8 @@ public class UIManager implements Serializable
/*
* This method is called before any code that depends on the
* <code>AppContext</code> specific LAFState object runs. When the AppContext
* corresponds to a set of applets it's possible for this method
* <code>AppContext</code> specific LAFState object runs.
* In some AppContext cases, it's possible for this method
* to be re-entered, which is why we grab a lock before calling
* initialize().
*/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2025, 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.
-->
<svg version="1.1"
width="850" height="600"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<style><![CDATA[
text {
font: 20px 'DejaVu Sans', Verdana, Arial, sans-serif;
fill: #000000;
}
text.centered {
text-anchor: middle;
dominant-baseline: middle;
}
]]></style>
<defs>
<g id="window">
<rect id="w1" x="10" y="10" width="100" height="60" fill="none" stroke="#ff0000" stroke-width="5" />
<text id="t1" x="60" y="40" class="centered">Window</text>
</g>
<g id="frame">
<rect id="w2" x="10" y="10" width="100" height="60" fill="none" stroke="#ff0000" stroke-width="5" />
<text id="t2" x="60" y="40" class="centered">Frame</text>
</g>
<g id="dialog">
<rect id="w1" x="10" y="10" width="100" height="60" fill="none" stroke="#ff0000" stroke-width="5" />
<text id="t1" x="60" y="40" class="centered">Dialog</text>
</g>
<g id="jframe">
<rect id="w1" x="10" y="10" width="100" height="60" fill="none" stroke="#0000ff" stroke-width="5" />
<text id="t1" x="60" y="40" class="centered">JFrame</text>
</g>
<g id="jdialog">
<rect id="w1" x="10" y="10" width="100" height="60" fill="none" stroke="#0000ff" stroke-width="5" />
<text id="t1" x="60" y="40" class="centered">JDialog</text>
</g>
<g id="jwindow">
<rect id="w1" x="10" y="10" width="100" height="60" fill="none" stroke="#0000ff" stroke-width="5" />
<text id="t1" x="60" y="40" class="centered">JWindow</text>
</g>
<g id="jinternalframe">
<rect id="w1" x="10" y="10" width="160" height="60" fill="none" stroke="#00ff00" stroke-width="2" />
<text id="t1" x="90" y="40" class="centered">JInternalFrame</text>
</g>
<g id="jrootpane">
<rect id="w1" x="10" y="10" width="120" height="60" fill="none" stroke="#00ff00" stroke-width="2" />
<text id="t1" x="70" y="40" class="centered">JRootPane</text>
</g>
</defs>
<use x="300" y="10" xlink:href="#window"/>
<use x="300" y="300" xlink:href="#jwindow"/>
<use x="10" y="150" xlink:href="#frame"/>
<use x="10" y="300" xlink:href="#jframe"/>
<use x="150" y="150" xlink:href="#dialog"/>
<use x="150" y="300" xlink:href="#jdialog"/>
<use x="450" y="300" xlink:href="#jinternalframe"/>
<use x="270" y="450" xlink:href="#jrootpane"/>
<line x1="10" y1="260" x2="640" y2="260" stroke="#000000" stroke-width="2" />
<line x1="10" y1="410" x2="640" y2="410" stroke="#000000" stroke-width="5" />
<line x1="70" y1="120" x2="360" y2="120" stroke="#000000" stroke-width="2" />
<line x1="70" y1="120" x2="70" y2="160" stroke="#000000" stroke-width="2" />
<line x1="210" y1="120" x2="210" y2="160" stroke="#000000" stroke-width="2" />
<line x1="70" y1="220" x2="70" y2="310" stroke="#000000" stroke-width="2" />
<line x1="210" y1="220" x2="210" y2="310" stroke="#000000" stroke-width="2" />
<line x1="360" y1="80" x2="360" y2="310" stroke="#000000" stroke-width="2" />
<line x1="340" y1="410" x2="340" y2="460" stroke="#000000" stroke-width="2" />
<text x="650" y="150">AWT classes</text>
<text x="650" y="300">Swing classes</text>
<text x="650" y="330">implementing the</text>
<text x="650" y="360">RootPaneContainer</text>
<text x="650" y="390">interface</text>
</svg>

View File

@ -44,10 +44,10 @@
* developers are not impacted by the restriction.
* <p>
* Where the impact lies, however, is in constructing and showing a Swing
* application. Calls to an application's {@code main} method, or methods in
* {@code Applet}, are not invoked on the event dispatching thread. As such,
* application. Calls to an application's {@code main} method,
* are not invoked on the event dispatching thread. As such,
* care must be taken to transfer control to the event dispatching thread when
* constructing and showing an application or applet. The preferred way to
* constructing and showing an application. The preferred way to
* transfer control and begin working with Swing is to use {@code invokeLater}.
* The {@code invokeLater} method schedules a {@code Runnable} to be processed
* on the event dispatching thread. The following two examples work equally well

View File

@ -29,8 +29,6 @@ import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import java.applet.Applet;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.KeyboardFocusManager;
@ -916,10 +914,9 @@ public class BasicPopupMenuUI extends PopupMenuUI {
}
}
@SuppressWarnings("removal")
boolean isInPopup(Component src) {
for (Component c=src; c!=null; c=c.getParent()) {
if (c instanceof Applet || c instanceof Window) {
if (c instanceof Window) {
break;
} else if (c instanceof JPopupMenu) {
return true;
@ -1131,7 +1128,6 @@ public class BasicPopupMenuUI extends PopupMenuUI {
}
}
@SuppressWarnings("removal")
public void stateChanged(ChangeEvent ev) {
if (!(UIManager.getLookAndFeel() instanceof BasicLookAndFeel)) {
uninstall();
@ -1171,8 +1167,6 @@ public class BasicPopupMenuUI extends PopupMenuUI {
invoker = ((JFrame)c).getRootPane();
} else if(c instanceof JDialog) {
invoker = ((JDialog)c).getRootPane();
} else if(c instanceof JApplet) {
invoker = ((JApplet)c).getRootPane();
} else {
while (!(c instanceof JComponent)) {
if (c == null) {

View File

@ -61,7 +61,6 @@ module java.desktop {
requires transitive java.datatransfer;
requires transitive java.xml;
exports java.applet;
exports java.awt;
exports java.awt.color;
exports java.awt.desktop;

View File

@ -53,7 +53,7 @@ import java.util.function.Supplier;
* The AppContext is a table referenced by ThreadGroup which stores
* application service instances. (If you are not writing an application
* service, or don't know what one is, please do not use this class.)
* The AppContext allows applet access to what would otherwise be
* The AppContext allows a context access to what would otherwise be
* potentially dangerous services, such as the ability to peek at
* EventQueues or change the look-and-feel of a Swing application.<p>
*
@ -79,7 +79,7 @@ import java.util.function.Supplier;
* }</pre><p>
*
* The problem with the above is that the Foo service is global in scope,
* so that applets and other untrusted code can execute methods on the
* so that untrusted code can execute methods on the
* single, shared Foo instance. The Foo service therefore either needs
* to block its use by untrusted code using a SecurityManager test, or
* restrict its capabilities so that it doesn't matter if untrusted code
@ -104,20 +104,14 @@ import java.util.function.Supplier;
* Since a separate AppContext can exist for each ThreadGroup, trusted
* and untrusted code have access to different Foo instances. This allows
* untrusted code access to "system-wide" services -- the service remains
* within the AppContext "sandbox". For example, say a malicious applet
* within the AppContext "sandbox". For example, say malicious code
* wants to peek all of the key events on the EventQueue to listen for
* passwords; if separate EventQueues are used for each ThreadGroup
* using AppContexts, the only key events that applet will be able to
* listen to are its own. A more reasonable applet request would be to
* using AppContexts, the only key events that code will be able to
* listen to are its own. A more reasonable request would be to
* change the Swing default look-and-feel; with that default stored in
* an AppContext, the applet's look-and-feel will change without
* disrupting other applets or potentially the browser itself.<p>
*
* Because the AppContext is a facility for safely extending application
* service support to applets, none of its methods may be blocked by a
* a SecurityManager check in a valid Java implementation. Applets may
* therefore safely invoke any of its methods without worry of being
* blocked.
* an AppContext, the look-and-feel will change without
* disrupting other contexts.
*
* @author Thomas Ball
* @author Fred Ecks
@ -155,7 +149,7 @@ public final class AppContext {
/* The main "system" AppContext, used by everything not otherwise
contained in another AppContext. It is implicitly created for
standalone apps only (i.e. not applets)
standalone apps only.
*/
private static volatile AppContext mainAppContext;
@ -283,9 +277,7 @@ public final class AppContext {
ThreadGroup threadGroup = currentThreadGroup;
// Special case: we implicitly create the main app context
// if no contexts have been created yet. This covers standalone apps
// and excludes applets because by the time applet starts
// a number of contexts have already been created by the plugin.
// if no contexts have been created yet.
synchronized (getAppContextLock) {
if (numAppContexts.get() == 0) {
if (System.getProperty("javaplugin.version") == null &&

View File

@ -25,7 +25,6 @@
package sun.awt;
import java.applet.Applet;
import java.awt.AWTKeyStroke;
import java.awt.Component;
import java.awt.Container;
@ -49,11 +48,11 @@ import java.io.Serial;
import java.util.Set;
/**
* A generic container used for embedding Java components, usually applets.
* A generic container used for embedding Java components.
* An EmbeddedFrame has two related uses:
*
* . Within a Java-based application, an EmbeddedFrame serves as a sort of
* firewall, preventing the contained components or applets from using
* firewall, preventing the contained components from using
* getParent() to find parent components, such as menubars.
*
* . Within a C-based application, an EmbeddedFrame contains a window handle
@ -71,7 +70,7 @@ public abstract class EmbeddedFrame extends Frame
private boolean isCursorAllowed = true;
private boolean supportsXEmbed = false;
@SuppressWarnings("serial") // Not statically typed as Serializable
private KeyboardFocusManager appletKFM;
private KeyboardFocusManager appKFM;
/**
* Use serialVersionUID from JDK 1.1 for interoperability.
@ -139,12 +138,12 @@ public abstract class EmbeddedFrame extends Frame
return;
}
// should be the same as appletKFM
// should be the same as appKFM
removeTraversingOutListeners((KeyboardFocusManager)evt.getSource());
appletKFM = KeyboardFocusManager.getCurrentKeyboardFocusManager();
appKFM = KeyboardFocusManager.getCurrentKeyboardFocusManager();
if (isVisible()) {
addTraversingOutListeners(appletKFM);
addTraversingOutListeners(appKFM);
}
}
@ -169,44 +168,44 @@ public abstract class EmbeddedFrame extends Frame
* EmbeddedFrame is first created or shown, we can't automatically determine
* the correct KeyboardFocusManager to attach to as KeyEventDispatcher.
* Those who want to use the functionality of traversing out of the EmbeddedFrame
* must call this method on the Applet's AppContext. After that, all the changes
* must call this method on the AppContext. After that, all the changes
* can be handled automatically, including possible replacement of
* KeyboardFocusManager.
*/
public void registerListeners() {
if (appletKFM != null) {
removeTraversingOutListeners(appletKFM);
if (appKFM != null) {
removeTraversingOutListeners(appKFM);
}
appletKFM = KeyboardFocusManager.getCurrentKeyboardFocusManager();
appKFM = KeyboardFocusManager.getCurrentKeyboardFocusManager();
if (isVisible()) {
addTraversingOutListeners(appletKFM);
addTraversingOutListeners(appKFM);
}
}
/**
* Needed to avoid memory leak: we register this EmbeddedFrame as a listener with
* KeyboardFocusManager of applet's AppContext. We don't want the KFM to keep
* KeyboardFocusManager of an AppContext. We don't want the KFM to keep
* reference to our EmbeddedFrame forever if the Frame is no longer in use, so we
* add listeners in show() and remove them in hide().
*/
@SuppressWarnings("deprecation")
public void show() {
if (appletKFM != null) {
addTraversingOutListeners(appletKFM);
if (appKFM != null) {
addTraversingOutListeners(appKFM);
}
super.show();
}
/**
* Needed to avoid memory leak: we register this EmbeddedFrame as a listener with
* KeyboardFocusManager of applet's AppContext. We don't want the KFM to keep
* KeyboardFocusManager of an AppContext. We don't want the KFM to keep
* reference to our EmbeddedFrame forever if the Frame is no longer in use, so we
* add listeners in show() and remove them in hide().
*/
@SuppressWarnings("deprecation")
public void hide() {
if (appletKFM != null) {
removeTraversingOutListeners(appletKFM);
if (appKFM != null) {
removeTraversingOutListeners(appKFM);
}
super.hide();
}
@ -511,31 +510,6 @@ public abstract class EmbeddedFrame extends Frame
public abstract void registerAccelerator(AWTKeyStroke stroke);
public abstract void unregisterAccelerator(AWTKeyStroke stroke);
/**
* Checks if the component is in an EmbeddedFrame. If so,
* returns the applet found in the hierarchy or null if
* not found.
* @return the parent applet or {@code null}
* @since 1.6
*
* @deprecated The Applet API is deprecated. See the
* <a href="../../java/applet/package-summary.html"> java.applet package
* documentation</a> for further information.
*/
@Deprecated(since = "9", forRemoval = true)
@SuppressWarnings("removal")
public static Applet getAppletIfAncestorOf(Component comp) {
Container parent = comp.getParent();
Applet applet = null;
while (parent != null && !(parent instanceof EmbeddedFrame)) {
if (parent instanceof Applet) {
applet = (Applet)parent;
}
parent = parent.getParent();
}
return parent == null ? null : applet;
}
/**
* This method should be overridden in subclasses. It is
* called when window this frame is within should be blocked

View File

@ -267,8 +267,7 @@ public abstract class SunToolkit extends Toolkit
/*
* Create a new AppContext, along with its EventQueue, for a
* new ThreadGroup. Browser code, for example, would use this
* method to create an AppContext & EventQueue for an Applet.
* new ThreadGroup.
*/
public static AppContext createNewAppContext() {
ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
@ -1635,9 +1634,6 @@ public abstract class SunToolkit extends Toolkit
* But GTK currently has an additional test based on locale which is
* not applied by Metal. So mixing GTK in a few locales with Metal
* would mean the last one wins.
* This could be stored per-app context which would work
* for different applets, but wouldn't help for a single application
* using GTK and some other L&F concurrently.
* But it is expected this will be addressed within GTK and the font
* system so is a temporary and somewhat unlikely harmless corner case.
*/

View File

@ -44,12 +44,12 @@ import java.io.Writer;
* analysis is interesting; this class is merely a central container
* for those timing values.
* Note that, due to the variables in this class being static,
* use of particular time values by multiple applets will cause
* confusing results. For example, if plugin runs two applets
* simultaneously, the initTime for those applets will collide
* use of particular time values by multiple AppContexts will cause
* confusing results. For example, if two contexts run
* simultaneously, the initTime for those will collide
* and the results may be undefined.
* <P>
* To automatically track startup performance in an app or applet,
* To automatically track startup performance in an app
* use the command-line parameter sun.perflog as follows:<BR>
* <pre>{@code
* -Dsun.perflog[=file:<filename>]
@ -167,9 +167,9 @@ public class PerformanceLogger {
/**
* Sets the start time. Ideally, this is the earliest time available
* during the startup of a Java applet or application. This time is
* during the startup of an application. This time is
* later used to analyze the difference between the initial startup
* time and other events in the system (such as an applet's init time).
* time and other events in the system.
*/
public static void setStartTime(String message) {
if (loggingEnabled()) {

View File

@ -2481,7 +2481,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
* performed normally. There may be some duplication of effort, but
* that code is already written to be able to perform properly if called
* to duplicate work. The main difference is that if we detect we are
* running in an applet/browser/Java plugin environment these new fonts
* in an AppContext environment these new fonts
* are not placed in the "default" maps but into an AppContext instance.
* The font lookup mechanism in java.awt.Font.getFont2D() is also updated
* so that look-up for composite fonts will in that case always
@ -2502,7 +2502,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
* Calling the methods below is "heavyweight" but it is expected that
* these methods will be called very rarely.
*
* If _usingAlternateComposites is true, we are not in an "applet"
* If _usingAlternateComposites is true, we are not in an "AppContext"
* environment and the (single) application has selected
* an alternate composite font behaviour.
*

View File

@ -1441,7 +1441,7 @@ class XWindow extends XBaseWindow implements X11ComponentPeer {
comp = AWTAccessor.getComponentAccessor().getParent(comp);
}
// applets, embedded, etc - translate directly
// embedded, etc - translate directly
// XXX: override in subclass?
if (comp == null || comp instanceof sun.awt.EmbeddedFrame) {
return toGlobal(0, 0);

View File

@ -253,8 +253,8 @@ public final class WEmbeddedFrame extends EmbeddedFrame {
* super.notifyModalBlocked(blocker, blocked) must be present
* when overriding.
* It may occur that embedded frame is not put into its
* container at the moment when it is blocked, for example,
* when running an applet in IE. Then the call to this method
* container at the moment when it is blocked.
* Then the call to this method
* should be delayed until embedded frame is reparented.
*
* NOTE: This method may be called by privileged threads.

View File

@ -128,8 +128,7 @@ public:
static LRESULT CALLBACK MouseHookProc(int code,
WPARAM wParam, LPARAM lParam);
// WM_MOUSE hook procedure used in modality, similar to
// MouseHookProc but installed on non-toolkit threads, for
// example on browser's thread when running in Java Plugin
// MouseHookProc but installed on non-toolkit threads
static LRESULT CALLBACK MouseHookProc_NonTT(int code,
WPARAM wParam, LPARAM lParam);

View File

@ -49,7 +49,6 @@
* Set our limit much lower than that to allow a buffer for objects
* created beyond the per-thread HDC/Brush/Pen objects we are
* counting here, including objects created by the overall process
* (which could include the browser, in the case of applets)
*/
#define MAX_GDI_OBJECTS 9000

View File

@ -1786,8 +1786,8 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WEmbeddedFrame_printBand
// ::PatBlt(hDC, destX+1, destY+1, destWidth-2, destHeight-2, PATCOPY);
// ::SelectObject(hDC, oldBrush);
/* This code is rarely used now. It used to be invoked by Java plugin browser
* printing. Today embedded frames are used only when a toolkit such as SWT
/* This code is rarely used now.
* Today embedded frames are used only when a toolkit such as SWT
* needs to embed
*/
TRY;

View File

@ -1603,7 +1603,6 @@ vmTestbase_vm_compiler_quick = \
vmTestbase/jit/misctests/JitBug1/JitBug1.java \
vmTestbase/jit/misctests/Pi/Pi.java \
vmTestbase/jit/misctests/clss14702/clss14702.java \
vmTestbase/jit/misctests/fpustack/GraphApplet.java \
vmTestbase/jit/misctests/putfield00802/putfield00802.java \
vmTestbase/jit/misctests/t5/t5.java \
vmTestbase/jit/overflow/overflow.java \

View File

@ -1,156 +0,0 @@
/*
* Copyright (c) 2008, 2020, 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
* @key headful
*
* @summary converted from VM Testbase jit/misctests/fpustack.
* VM Testbase keywords: [jit, desktop, jdk_desktop, quick]
*
* @library /vmTestbase
* /test/lib
* @run main/othervm jit.misctests.fpustack.GraphApplet
*/
package jit.misctests.fpustack;
import java.util.*;
import java.awt.*;
import java.applet.Applet;
import nsk.share.TestFailure;
public class GraphApplet extends Applet {
private GraphPanel panel;
private boolean isApplet = true;
private boolean initialized = false;
/**
** main method for testing that class
**
**/
public static void main( String[] args ) {
Frame f = new Frame("GraphApplet");
GraphApplet app = new GraphApplet();
app.isApplet = false;
app.setSize(600,400);
f.setLayout( new BorderLayout() );
f.add("Center",app);
f.setSize(600,400);
app.init();
// f.pack();
f.show(true);
app.start();
try {
Thread.currentThread().sleep(5*1000);
} catch (InterruptedException e) {
}
f.show(false);
app.stop();
f.dispose();
return;
}
/**
** init-Method in applet's lifecycle.
** the graphic panel is build up and the date is filled.
**/
public synchronized void init() {
System.out.println( "GraphApplet : init");
setLayout(new BorderLayout());
panel = new GraphPanel(this, new layout() );
fill( panel );
add("Center", panel);
Panel p = new Panel();
add("South", p);
initialized = true;
}
public synchronized void start() {
System.out.println( "GraphApplet : start");
panel.formatNodes();
}
public synchronized void stop() {
initialized = false;
System.out.println( "GraphApplet : stop");
}
public synchronized void destroy() {
System.out.println( "GraphApplet : destroy");
}
/**
** paint the Applet
**/
public synchronized void paint(Graphics g) {
try {
while ( ! initialized )
Thread.currentThread().sleep(5);
} catch (InterruptedException e) {}
if (g instanceof PrintGraphics )
System.out.println( "printing GraphApplet ...");
}
public synchronized void print(Graphics g) {
try {
while ( ! initialized )
Thread.currentThread().sleep(5);
} catch (InterruptedException e) {}
System.out.println( "Print Applet " + g);
panel.print(g);
}
public void print() {
// System.out.println( "Print Applet");
Toolkit kit = getToolkit();
try {
PrintJob job = kit.getPrintJob( new Frame("x"), "PrintableFrame print job",
null);
// do the printing if the user didn't cancel the print job
if (job != null) {
Graphics g = job.getGraphics();
printAll(g); // not paint(g)
g.dispose(); // finish with this page
job.end(); // finish with the PrintJob
}
} catch (Exception ex) {
System.out.println( "print exception " + ex);
}
}
/**
**
** @param panel the container for nodes
**
**/
private void
fill( GraphPanel panel ) {
panel.addNodes("Node1", "Node2", "Node3" );
}
}

View File

@ -1,111 +0,0 @@
/*
* Copyright (c) 2008, 2018, 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.
*/
package jit.misctests.fpustack;
import java.util.*;
import java.awt.*;
import java.applet.Applet;
import nsk.share.TestFailure;
public class GraphPanel extends Panel {
private Panel graph; // the container
private ilayout layout = null; // the strategy
private int nodesN; // number of nodes
private Node nodes[] = new Node[200]; // nodes container
/**
** constructor
**
** @param Panel the container
** @param layout a strategy to layout the nodes
**
**/
GraphPanel(Panel graph, layout ls ) {
this.graph = graph;
layout = ls;
}
/**
** add a node via label text.
**
** @param lbl the label
** @return the index of the node in array nodes[]
**
**/
public int addNode(String lbl) {
Node n = new Node();
if (nodesN > 0) {
n.x = nodes[nodesN-1].x + 30;
n.y = nodes[nodesN-1].y + 30;
}
n.lbl = lbl;
nodes[nodesN] = n;
return nodesN++;
}
/**
** add a node via label text.
**
** @param lbl the label
** @return the index of the node in array nodes[]
**
**/
public void addNodes(String lb1, String lb2, String lb3) {
addNode(lb1);
addNode(lb2);
addNode(lb3);
}
/**
** layout the nodes on the panel. the layout is used
**
**
**/
public synchronized void formatNodes( ) {
// format nodes
FontMetrics fm = getFontMetrics(getFont());
Dimension d = getSize();
Node[] ns = new Node[ nodesN ];
System.arraycopy(nodes, 0, ns, 0, nodesN);
layout.formatNodes( ns, d, fm );
}
}

View File

@ -1,34 +0,0 @@
/*
* Copyright (c) 2008, 2018, 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.
*/
package jit.misctests.fpustack;
import nsk.share.TestFailure;
public class Node {
double x = 0.0;
double y = 0.0;
String lbl;
}

View File

@ -1,33 +0,0 @@
/*
* Copyright (c) 2008, 2018, 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.
*/
package jit.misctests.fpustack;
import java.util.*;
import java.awt.*;
import nsk.share.TestFailure;
interface ilayout {
public void formatNodes( Node[] n, Dimension d, FontMetrics fm );
}

View File

@ -1,46 +0,0 @@
/*
* Copyright (c) 2008, 2018, 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.
*/
package jit.misctests.fpustack;
import java.util.*;
import java.awt.*;
import java.applet.Applet;
import nsk.share.TestFailure;
public class layout implements ilayout {
public void formatNodes( Node[] nodes, Dimension d, FontMetrics fm ) {
int h = d.height/2 - 10 ;
double alpha = -Math.PI/2;
for ( int j = 0; j < nodes.length; j++) {
Node n = nodes[j];
int w = d.width/2 - fm.stringWidth( n.lbl )/2;
n.x = d.width/2 + (int)(w*Math.cos( alpha ));
n.y = d.height/2 + (int)(h*Math.sin( alpha ));
alpha += 2*Math.PI/nodes.length;
}
}
}

View File

@ -27,7 +27,6 @@ questions.
* common/misctests/classes
* common/misctests/FileViewer
* common/misctests/Foo
* common/misctests/fpustack
* common/misctests/NoHeader
* common/misctests/noop
* common/misctests/Pi

View File

@ -1,123 +0,0 @@
/*
* Copyright (c) 2008, 2021, 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
* @key headful
* @bug 6683728
* @summary Tests that a JApplet in a translucent JFrame works properly
* @compile -XDignore.symbol.file=true TranslucentJAppletTest.java
* @run main/othervm -Dsun.java2d.uiScale=1 TranslucentJAppletTest
*/
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
public class TranslucentJAppletTest {
private static volatile GraphicsConfiguration graphicsConfig = null;
private static JFrame frame;
private static volatile boolean paintComponentCalled = false;
private static void initAndShowGUI() {
frame = new JFrame(graphicsConfig);
JApplet applet = new JApplet();
applet.setBackground(new Color(0, 0, 0, 0));
JPanel panel = new JPanel() {
protected void paintComponent(Graphics g) {
paintComponentCalled = true;
g.setColor(Color.RED);
g.fillOval(0, 0, getWidth(), getHeight());
}
};
panel.setDoubleBuffered(false);
panel.setOpaque(false);
applet.add(panel);
frame.add(applet);
frame.setBounds(100, 100, 200, 200);
frame.setUndecorated(true);
frame.setBackground(new Color(0, 0, 0, 0));
frame.setVisible(true);
}
public static void main(String[] args)
throws Exception
{
final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
for (GraphicsDevice gd : ge.getScreenDevices()) {
if (gd.isWindowTranslucencySupported(
GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT))
{
for (GraphicsConfiguration gc : gd.getConfigurations()) {
if (gc.isTranslucencyCapable()) {
graphicsConfig = gc;
break;
}
}
}
if (graphicsConfig != null) {
break;
}
}
if (graphicsConfig == null) {
System.out.println("The system does not support translucency. Consider the test passed.");
return;
}
Robot r = new Robot();
Color color1 = r.getPixelColor(100, 100); // (0, 0) in frame coordinates
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
initAndShowGUI();
}
});
r.waitForIdle();
if (!paintComponentCalled) {
throw new RuntimeException("Test FAILED: panel's paintComponent() method is not called");
}
Thread.sleep(1500);
Color newColor1 = r.getPixelColor(100, 100);
Color newColor2 = r.getPixelColor(200, 200);
// Frame must be transparent at (100, 100) in screen coords
if (!color1.equals(newColor1)) {
System.err.println("color1 = " + color1);
System.err.println("newColor1 = " + newColor1);
throw new RuntimeException("Test FAILED: frame pixel at (0, 0) is not transparent");
}
// Frame must be RED at (200, 200) in screen coords
if (!newColor2.equals(Color.RED)) {
System.err.println("newColor2 = " + newColor2);
throw new RuntimeException("Test FAILED: frame pixel at (100, 100) is not red (transparent?)");
}
System.out.println("Test PASSED");
}
}

View File

@ -1,93 +0,0 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.applet.Applet;
import java.awt.AWTException;
import java.awt.BufferCapabilities;
import java.awt.BufferCapabilities.FlipContents;
import java.awt.Frame;
import java.awt.ImageCapabilities;
import java.util.HashSet;
import java.util.Set;
import sun.awt.AWTAccessor;
import sun.awt.AWTAccessor.ComponentAccessor;
import static java.awt.BufferCapabilities.FlipContents.BACKGROUND;
import static java.awt.BufferCapabilities.FlipContents.COPIED;
import static java.awt.BufferCapabilities.FlipContents.PRIOR;
import static java.awt.BufferCapabilities.FlipContents.UNDEFINED;
/**
* @test
* @key headful
* @bug 8130390 8134732
* @summary Applet fails to launch on virtual desktop
* @modules java.desktop/sun.awt
* @author Semyon Sadetsky
*/
public final class AppletFlipBuffer {
static final ImageCapabilities[] ics = {new ImageCapabilities(true),
new ImageCapabilities(false)};
static final FlipContents[] cntx = {UNDEFINED, BACKGROUND, PRIOR, COPIED};
static final Set<BufferCapabilities> bcs = new HashSet<>();
static {
for (final ImageCapabilities icFront : ics) {
for (final ImageCapabilities icBack : ics) {
for (final FlipContents cnt : cntx) {
bcs.add(new BufferCapabilities(icFront, icBack, cnt));
}
}
}
}
public static void main(final String[] args) throws Exception {
Applet applet = new Applet();
Frame frame = new Frame();
try {
frame.setSize(10, 10);
frame.add(applet);
frame.setUndecorated(true);
frame.setVisible(true);
test(applet);
System.out.println("ok");
} finally {
frame.dispose();
}
}
private static void test(final Applet applet) {
ComponentAccessor acc = AWTAccessor.getComponentAccessor();
for (int i = 1; i < 10; ++i) {
for (final BufferCapabilities caps : bcs) {
try {
acc.createBufferStrategy(applet, i, caps);
} catch (final AWTException ignored) {
// this kind of buffer strategy is not supported
}
}
}
}
}

View File

@ -1,49 +0,0 @@
/*
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.applet.Applet;
import java.awt.HeadlessException;
/*
* @test
* @summary Check HeadlessException occurrence when trying to create Applet
* in headless mode
* @run main/othervm -Djava.awt.headless=true HeadlessApplet
*/
public class HeadlessApplet {
public static void main(String args[]) {
boolean noExceptions = true;
try {
Applet a = new Applet();
} catch (HeadlessException e) {
noExceptions = false;
}
if (noExceptions) {
throw new RuntimeException("No HeadlessException occured when creating Applet in headless mode");
}
}
}

View File

@ -41,7 +41,6 @@ import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JCheckBox;
@ -61,7 +60,7 @@ public class Test4520754 {
// AWT classes (com.sun.beans.infos.ComponentBeanInfo)
test(null, Button.class, Component.class, List.class, Menu.class, Panel.class);
// Swing classes (dt.jar)
test(null, JApplet.class, JButton.class, JCheckBox.class);
test(null, JButton.class, JCheckBox.class);
// user defined classes
test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class);
}

View File

@ -25,7 +25,7 @@
* @test
* @summary Tests just a benchmark of introspector performance
* @author Mark Davidson
* @run main/manual TestIntrospector
* @run main TestIntrospector
*/
import java.beans.BeanInfo;
@ -43,7 +43,6 @@ public class TestIntrospector {
javax.swing.DefaultComboBoxModel.class,
javax.swing.DefaultListModel.class,
javax.swing.ImageIcon.class,
javax.swing.JApplet.class,
javax.swing.JButton.class,
javax.swing.JCheckBox.class,
javax.swing.JColorChooser.class,

View File

@ -38,7 +38,6 @@ import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
@ -70,7 +69,6 @@ public class Test4682386 {
private static final boolean DEBUG = true;
private static final Class[] TYPES = {
JApplet.class,
JButton.class,
JCheckBox.class,
JComboBox.class,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2025, 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
@ -21,7 +21,6 @@
* questions.
*/
import java.applet.AudioClip;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
@ -31,6 +30,7 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import javax.sound.SoundClip;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
@ -44,8 +44,8 @@ import static javax.sound.sampled.AudioFileFormat.Type.WAVE;
/**
* @test
* @bug 8204454
* @summary URL.getContent() should return AudioClip for supported formats
* @bug 8204454 8359053
* @summary URL.getContent() should return SoundClip for supported formats
* @run main/othervm -Xmx128m AudioContentHandlers
*/
public final class AudioContentHandlers {
@ -77,10 +77,10 @@ public final class AudioContentHandlers {
} catch (IOException | IllegalArgumentException ignored) {
continue;
}
AudioClip content;
SoundClip content;
try {
content = (AudioClip) file.toURL().getContent();
// We need to generate OOM because the stream in AudioClip
content = (SoundClip) file.toURL().getContent();
// We need to generate OOM because the stream in SoundClip
// will be closed in finalize().
generateOOME();
} finally {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2025, 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
@ -21,7 +21,6 @@
* questions.
*/
import java.applet.AudioClip;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
@ -29,6 +28,7 @@ import java.io.InputStream;
import java.nio.file.Files;
import java.util.concurrent.TimeUnit;
import javax.sound.SoundClip;
import javax.sound.sampled.AudioFileFormat.Type;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
@ -66,7 +66,7 @@ public final class AutoCloseTimeCheck {
* and the "Direct Clip" thread will stop.
*/
private static void testBigDelay(final File file) throws Exception {
AudioClip clip = (AudioClip) file.toURL().getContent();
SoundClip clip = SoundClip.createSoundClip(file);
clip.loop();
clip.stop();
sleep(20000); // 20 sec for slow systems
@ -80,7 +80,7 @@ public final class AutoCloseTimeCheck {
* closed and the "Direct Clip" thread will alive.
*/
private static void testSmallDelay(final File file) throws IOException {
AudioClip clip = (AudioClip) file.toURL().getContent();
SoundClip clip = SoundClip.createSoundClip(file);
long threadID = 0;
// Will run the test no more than 15 seconds
long endtime = System.nanoTime() + TimeUnit.SECONDS.toNanos(15);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2025, 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
@ -30,7 +30,7 @@ import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import java.applet.AudioClip;
import javax.sound.SoundClip;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
@ -70,7 +70,7 @@ public class DataPusherThreadCheck {
}
private static void checkThread(File file) throws Exception {
AudioClip clip = (AudioClip) file.toURL().getContent();
SoundClip clip = SoundClip.createSoundClip(file);
clip.loop();
try {
Thread.sleep(2000);

View File

@ -1,44 +0,0 @@
/*
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import javax.swing.JApplet;
import java.awt.HeadlessException;
/*
* @test
* @summary Check that JApplet constructor throws HeadlessException in headless mode
* @run main/othervm -Djava.awt.headless=true HeadlessJApplet
*/
public class HeadlessJApplet {
public static void main(String args[]) {
boolean exceptions = false;
try {
new JApplet();
} catch (HeadlessException e) {
exceptions = true;
}
if (!exceptions)
throw new RuntimeException("HeadlessException did not occur when expected");
}
}