当前位置: 首页>>代码示例>>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;未经允许,请勿转载。