當前位置: 首頁>>代碼示例>>Java>>正文


Java Applet類代碼示例

本文整理匯總了Java中java.applet.Applet的典型用法代碼示例。如果您正苦於以下問題:Java Applet類的具體用法?Java Applet怎麽用?Java Applet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Applet類屬於java.applet包,在下文中一共展示了Applet類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: create

import java.applet.Applet; //導入依賴的package包/類
public static DataCollector create( Applet app, Properties props,
    String localHostName )
{
    String appletHost = localHostName ;

    if (app != null) {
        URL appletCodeBase = app.getCodeBase() ;

        if (appletCodeBase != null)
            appletHost = appletCodeBase.getHost() ;
    }

    return new AppletDataCollector( app, props, localHostName,
        appletHost ) ;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:16,代碼來源:DataCollectorFactory.java

示例2: appletLoaded

import java.applet.Applet; //導入依賴的package包/類
private static void appletLoaded(Applet applet, ClassLoader loader,
        String name, BeanContext context, AppletInitializer initializer,
        boolean deserialized) throws ClassNotFoundException {

    // If there is an initializer
    if (initializer != null) {
        initializer.initialize(applet, context);
    } else {
        setStub(applet, loader, deserialized, name);
    }

    if (!deserialized) {
        applet.init();
    }

    if (initializer != null) {
        initializer.activate(applet);
    }
}
 
開發者ID:yippeesoft,項目名稱:NotifyTools,代碼行數:20,代碼來源:Beans.java

示例3: playApplet

import java.applet.Applet; //導入依賴的package包/類
private static void playApplet(String filename) {
	URL url = null;
	try {
		File file = new File(filename);
		if (file.canRead())
			url = file.toURI().toURL();
	} catch (MalformedURLException e) {
		throw new IllegalArgumentException("could not play '" + filename + "'", e);
	}

	// URL url = StdAudio.class.getResource(filename);
	if (url == null) {
		throw new IllegalArgumentException("could not play '" + filename + "'");
	}

	AudioClip clip = Applet.newAudioClip(url);
	clip.play();
}
 
開發者ID:Scoutdrago3,項目名稱:MusicToGraph,代碼行數:19,代碼來源:StdAudio.java

示例4: init

import java.applet.Applet; //導入依賴的package包/類
/**
 * Creates a new <code>ORB</code> instance for an applet.  This
 * method may be called from applets only and returns a new
 * fully-functional <code>ORB</code> object each time it is called.
 * @param app the applet; may be <code>null</code>
 * @param props applet-specific properties; may be <code>null</code>
 * @return the newly-created ORB instance
 */
public static ORB init(Applet app, Properties props) {
    String className;
    ORB orb;

    className = app.getParameter(ORBClassKey);
    if (className == null && props != null)
        className = props.getProperty(ORBClassKey);
    if (className == null)
        className = getSystemProperty(ORBClassKey);
    if (className == null)
        className = getPropertyFromFile(ORBClassKey);
    if ((className == null) ||
                (className.equals("com.sun.corba.se.impl.orb.ORBImpl"))) {
        orb = new com.sun.corba.se.impl.orb.ORBImpl();
    } else {
        orb = create_impl(className);
    }
    orb.set_parameters(app, props);
    return orb;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:29,代碼來源:ORB.java

示例5: propertyChange

import java.applet.Applet; //導入依賴的package包/類
public void propertyChange(PropertyChangeEvent ev) {
    if (!isEditing() || getClientProperty("terminateEditOnFocusLost") != Boolean.TRUE) {
        return;
    }

    Component c = focusManager.getPermanentFocusOwner();
    while (c != null) {
        if (c == JTable.this) {
            // focus remains inside the table
            return;
        } else if ((c instanceof Window) ||
                   (c instanceof Applet && c.getParent() == null)) {
            if (c == SwingUtilities.getRoot(JTable.this)) {
                if (!getCellEditor().stopCellEditing()) {
                    getCellEditor().cancelCellEditing();
                }
            }
            break;
        }
        c = c.getParent();
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:JTable.java

示例6: fetchApplet

import java.applet.Applet; //導入依賴的package包/類
@Override
public Applet fetchApplet() {
    try {
        Hook.getInstance().init();

        final ASMClassLoader    classLoader = Context.getInstance().getASMClassLoader();
        final Class<?>          clientClass = classLoader.loadClass(Context.getInstance().getServerProviderInfo().getClientClass());
        final OSScapeParameters parser      = new OSScapeParameters();
        Object                  instance    = clientClass.newInstance();

        Utilities.handleOSScape(parser, classLoader);

        Applet applet = (Applet) instance;
        applet.setStub(new Stub(parser));

        return applet;
    } catch (Exception e) {
        e.printStackTrace();

        return null;
    }
}
 
開發者ID:Parabot,項目名稱:Parabot-317-API-Minified-OS-Scape,代碼行數:23,代碼來源:Loader.java

示例7: testAppletFindFromApplet

import java.applet.Applet; //導入依賴的package包/類
public void testAppletFindFromApplet() throws Exception {
    defineWebPage( "start", "<applet name=first code='" + SimpleApplet.class.getName() +
                            ".class' codebase=/classes width=100 height=100></applet>" +
                            "<applet name=second code='" + SecondApplet.class.getName() +
                            ".class' codebase=/classes width=100 height=100></applet>");
    mapToClasspath( "/classes" );
    WebConversation wc = new WebConversation();
    WebResponse response = wc.getResponse( getHostPath() + "/start.html" );
    Applet applet = response.getApplets()[0].getApplet();
    Applet applet2 = applet.getAppletContext().getApplet( "second" );
    assertNotNull( "Applet was not loaded", applet2 );
    assertEquals( "Applet class", SecondApplet.class.getName(), applet2.getClass().getName() );

    Enumeration applets = applet2.getAppletContext().getApplets();
    assertNotNull( "No applet enumeration returned", applets );
    assertTrue( "No applets in enumeration", applets.hasMoreElements() );
    assertTrue( "First is not an applet", applets.nextElement() instanceof Applet );
    assertTrue( "Only one applet in enumeration", applets.hasMoreElements() );
    assertTrue( "Second is not an applet", applets.nextElement() instanceof Applet );
    assertFalse( "More than two applets enumerated", applets.hasMoreElements() );
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:22,代碼來源:WebAppletTest.java

示例8: getComponentPopupMenu

import java.applet.Applet; //導入依賴的package包/類
/**
 * Returns <code>JPopupMenu</code> that assigned for this component.
 * If this component does not have a <code>JPopupMenu</code> assigned
 * to it and <code>getInheritsPopupMenu</code> is true, this
 * will return <code>getParent().getComponentPopupMenu()</code> (assuming
 * the parent is valid.)
 *
 * @return <code>JPopupMenu</code> assigned for this component
 *         or <code>null</code> if no popup assigned
 * @see #setComponentPopupMenu
 * @since 1.5
 */
public JPopupMenu getComponentPopupMenu() {

    if(!getInheritsPopupMenu()) {
        return popupMenu;
    }

    if(popupMenu == null) {
        // Search parents for its popup
        Container parent = getParent();
        while (parent != null) {
            if(parent instanceof JComponent) {
                return ((JComponent)parent).getComponentPopupMenu();
            }
            if(parent instanceof Window ||
               parent instanceof Applet) {
                // Reached toplevel, break and return null
                break;
            }
            parent = parent.getParent();
        }
        return null;
    }

    return popupMenu;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:38,代碼來源:JComponent.java

示例9: init

import java.applet.Applet; //導入依賴的package包/類
/**
 * Creates a new {@code ORB} instance for an applet.  This
 * method may be called from applets only and returns a new
 * fully-functional {@code ORB} object each time it is called.
 * @param app the applet; may be {@code null}
 * @param props applet-specific properties; may be {@code null}
 * @return the newly-created ORB instance
 *
 * @implNote
 * When configured via the system property, or orb.properties,
 * the ORB is located via the thread context class loader.
 */
public static ORB init(Applet app, Properties props) {
    String className;
    ORB orb;

    className = app.getParameter(ORBClassKey);
    if (className == null && props != null)
        className = props.getProperty(ORBClassKey);
    if (className == null)
        className = getSystemProperty(ORBClassKey);
    if (className == null)
        className = getPropertyFromFile(ORBClassKey);
    if ((className == null) ||
                (className.equals("com.sun.corba.se.impl.orb.ORBImpl"))) {
        orb = new com.sun.corba.se.impl.orb.ORBImpl();
    } else {
        orb = create_impl(className);
    }
    orb.set_parameters(app, props);
    return orb;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:33,代碼來源:ORB.java

示例10: fetchApplet

import java.applet.Applet; //導入依賴的package包/類
@Override
public Applet fetchApplet() {
    try {
        final Context        context     = Context.getInstance();
        final ASMClassLoader classLoader = context.getASMClassLoader();
        final Class<?>       clientClass = classLoader.loadClass(Context.getInstance().getServerProviderInfo().getClientClass());
        Object               instance    = clientClass.newInstance();

        return (Applet) instance;
    } catch (Exception e) {
        e.printStackTrace();

        return null;
    }
}
 
開發者ID:Parabot,項目名稱:Parabot-317-API-Minified-PkHonor,代碼行數:16,代碼來源:Loader.java

示例11: setStub

import java.applet.Applet; //導入依賴的package包/類
private static void setStub(Applet applet, final ClassLoader loader,
        boolean serialized, String beanName) throws ClassNotFoundException {
    // Get path to the resource representing the applet.
    String pathName = beanName.replace('.', '/');
    final String resourceName = serialized ? pathName.concat(".ser") : pathName.concat(".class"); //$NON-NLS-1$ //$NON-NLS-2$
    URL objectUrl = AccessController
            .doPrivileged(new PrivilegedAction<URL>() {
                public URL run() {
                    if (loader == null) {
                        return ClassLoader.getSystemResource(resourceName);
                    }
                    return loader.getResource(resourceName);
                }
            });

    // If we can't get to the applet itself, the codebase and doc base are
    // left as null.
    if (objectUrl == null) {
        applet.setStub(getAppletStub(getStubAppletContext(applet),
                null, null));
        return;
    }

    // Try to decompose the resource URL to get to the doc/code URL
    String urlString = objectUrl.toExternalForm();

    // This is the URL of the directory that contains the applet.
    int codeURLlength = urlString.length() - resourceName.length();
    URL codeBase = safeURL(urlString.substring(0, codeURLlength));

    // URL of the document containing the applet.
    int docURLlength = urlString.lastIndexOf('/');
    URL docBase = safeURL(urlString.substring(0, docURLlength + 1));

    applet.setStub(getAppletStub(getStubAppletContext(applet),
            codeBase, docBase));
}
 
開發者ID:yippeesoft,項目名稱:NotifyTools,代碼行數:38,代碼來源:Beans.java

示例12: getAudio

import java.applet.Applet; //導入依賴的package包/類
public static AudioClip getAudio(int index) {
	if (audios[index] == null) {
		URL url = null;
		ClassLoader classLoader = FileHelper.class.getClassLoader();
		url = classLoader.getResource("music/" + index + ".wav");
		audios[index] = Applet.newAudioClip(url);
	}
	return audios[index];
}
 
開發者ID:zhangjikai,項目名稱:LinkGame,代碼行數:10,代碼來源:EffectSound.java

示例13: playAudio

import java.applet.Applet; //導入依賴的package包/類
public void playAudio(int tempo, boolean flag) throws UnsupportedAudioFileException, LineUnavailableException, IOException, InterruptedException{
    Clip clip = AudioSystem.getClip();
    URL url = getClass().getResource("/audio/smb_die.wav");
    URL urlToHot = this.getClass().getResource("/audio/smb_die.wav");
    System.out.println(urlToHot);
    this.audio = Applet.newAudioClip(url);
    if(flag) audio.loop();
    else audio.stop();
    
}
 
開發者ID:knowrafa,項目名稱:lembredio,代碼行數:11,代碼來源:Audio.java

示例14: createAudioClipFactory

import java.applet.Applet; //導入依賴的package包/類
protected AudioClipFactory createAudioClipFactory() {
  return new AudioClipFactory() {
    public AudioClip getAudioClip(URL url) {
      return Applet.newAudioClip(url);
    }
  };
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:8,代碼來源:SoundConfigurer.java

示例15: getSound

import java.applet.Applet; //導入依賴的package包/類
public AudioClip getSound(SoundType sound) {
    if (sounds == null) {
        SoundType[] soundsT = SoundType.values();
        sounds = new HashMap<SoundType, AudioClip>();
        String urlSound;
        URL url;
        for (SoundType st : soundsT) {
            urlSound = sounds_path + st.name() + ".wav";
            url = getClass().getResource(urlSound);
            if (url == null) {
                switch (st) {
                case ERROR:
                    urlSound = sounds_path + SoundType.WARNING.name() + ".wav";
                    url = getClass().getResource(urlSound);
                    break;
                case WARNING:
                    urlSound = sounds_path + SoundType.ERROR.name() + ".wav";
                    url = getClass().getResource(urlSound);
                    break;
                default: // do nothing
                }
                if (url == null) {
                    urlSound = sounds_path + SoundType.MESSAGE.name() + ".wav";
                    url = getClass().getResource(urlSound);
                }
            }
            if (url != null) {
                sounds.put(st, Applet.newAudioClip(url));
            }
        }
    }
    return sounds.get(sound);
}
 
開發者ID:adbenitez,項目名稱:jNotifyOSD,代碼行數:34,代碼來源:NotifyConfig.java


注:本文中的java.applet.Applet類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。