Search in sources :

Example 1 with Applet

use of java.applet.Applet in project jdk8u_jdk by JetBrains.

the class AppletFrame method startApplet.

public static void startApplet(String className, String title, String[] args) {
    // local variables
    Applet a;
    Dimension appletSize;
    try {
        // create an instance of your applet class
        a = (Applet) Class.forName(className).newInstance();
    } catch (ClassNotFoundException e) {
        return;
    } catch (InstantiationException e) {
        return;
    } catch (IllegalAccessException e) {
        return;
    }
    // initialize the applet
    a.init();
    a.start();
    // create new application frame window
    AppletFrame f = new AppletFrame(title);
    // add applet to frame window
    f.add("Center", a);
    // resize frame window to fit applet
    // assumes that the applet sets its own size
    // otherwise, you should set a specific size here.
    appletSize = a.getSize();
    f.pack();
    f.setSize(appletSize);
    // show the window
    f.setVisible(true);
}
Also used : Applet(java.applet.Applet) Dimension(java.awt.Dimension)

Example 2 with Applet

use of java.applet.Applet in project jdk8u_jdk by JetBrains.

the class EmbeddedFrame method getAppletIfAncestorOf.

/**
     * 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 {@ null}
     * @since 1.6
     */
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;
}
Also used : Applet(java.applet.Applet)

Example 3 with Applet

use of java.applet.Applet in project imagej1 by imagej.

the class Commands method openStartupMacros.

// Plugins>Macros>Open Startup Macros command
void openStartupMacros() {
    Applet applet = IJ.getApplet();
    if (applet != null)
        IJ.run("URL...", "url=" + IJ.URL + "/applet/StartupMacros.txt");
    else {
        String path = IJ.getDirectory("macros") + "StartupMacros.txt";
        File f = new File(path);
        if (!f.exists()) {
            path = IJ.getDirectory("macros") + "StartupMacros.ijm";
            f = new File(path);
        }
        if (!f.exists()) {
            path = IJ.getDirectory("macros") + "StartupMacros.fiji.ijm";
            f = new File(path);
        }
        if (!f.exists())
            IJ.error("\"StartupMacros.txt\" not found in ImageJ/macros/");
        else
            IJ.open(path);
    }
}
Also used : Applet(java.applet.Applet) File(java.io.File)

Example 4 with Applet

use of java.applet.Applet in project runelite by runelite.

the class RuneLite method start.

public void start() throws Exception {
    // Load RuneLite or Vanilla client
    final boolean hasRs = !getOptions().has("no-rs");
    final Optional<Applet> optionalClient = hasRs ? new ClientLoader().loadRs() : Optional.empty();
    if (!optionalClient.isPresent() && hasRs) {
        System.exit(-1);
        return;
    }
    final Applet client = optionalClient.orElse(null);
    final boolean isOutdated = client == null || !(client instanceof Client);
    if (!isOutdated) {
        this.client = (Client) client;
    }
    // Initialize UI
    clientUI.init(client);
    // Initialize Discord service
    discordService.init();
    // Register event listeners
    eventBus.register(clientUI);
    eventBus.register(overlayRenderer);
    eventBus.register(menuManager);
    eventBus.register(chatMessageManager);
    eventBus.register(pluginManager);
    eventBus.register(itemManager);
    eventBus.register(clanManager);
    // Load user configuration
    configManager.load();
    // Tell the plugin manager if client is outdated or not
    pluginManager.setOutdated(isOutdated);
    // Load the plugins, but does not start them yet.
    // This will initialize configuration
    pluginManager.loadCorePlugins();
    // Plugins have provided their config, so set default config
    // to main settings
    pluginManager.loadDefaultPluginConfiguration();
    // Start client session
    clientSessionManager.start();
    // Load the session, including saved configuration
    sessionManager.loadSession();
    // Start plugins
    pluginManager.startCorePlugins();
    // Refresh title toolbar
    titleToolbar.refresh();
    // Show UI after all plugins are loaded
    clientUI.show();
}
Also used : Applet(java.applet.Applet) Client(net.runelite.api.Client)

Example 5 with Applet

use of java.applet.Applet in project SKMCLauncher by SKCraft.

the class GameLauncher method launch.

private void launch() throws LaunchException {
    final GameLauncher self = this;
    setupEnvironment();
    setupClassLoader();
    logger.info("Now launching...");
    try {
        LoaderCompat loaderCompat = new LoaderCompat(self);
        loaderCompat.installHooks();
        Class<?> cls = classLoader.loadClass("net.minecraft.client.MinecraftApplet");
        Applet game = (Applet) cls.newInstance();
        GameFrame frame = new GameFrame(windowDim);
        frame.setVisible(true);
        GameAppletContainer container = new GameAppletContainer(parameters, game, loaderCompat);
        frame.start(container);
    } catch (Throwable e) {
        logger.log(Level.SEVERE, "Failed to launch", e);
        SwingHelper.showError(null, "Launch error", "An error occurred while launching: " + e.getMessage() + "\n\n" + LauncherUtils.getStackTrace(e));
    }
}
Also used : Applet(java.applet.Applet)

Aggregations

Applet (java.applet.Applet)10 URL (java.net.URL)2 AppletStub (java.applet.AppletStub)1 Dimension (java.awt.Dimension)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 StreamCorruptedException (java.io.StreamCorruptedException)1 URLClassLoader (java.net.URLClassLoader)1 Client (net.runelite.api.Client)1