Java Code Examples for java.applet.Applet

The following are top voted examples for showing how to use java.applet.Applet. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: NotifyTools   File: Beans.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 2
Project: MusicToGraph   File: StdAudio.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 3
Project: OpenJSharp   File: ORB.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 4
Project: OpenJSharp   File: DataCollectorFactory.java   Source Code and License 6 votes vote down vote up
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 ) ;
}
 
Example 5
Project: OpenJSharp   File: JTable.java   Source Code and License 6 votes vote down vote up
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();
    }
}
 
Example 6
Project: Parabot-317-API-Minified-OS-Scape   File: Loader.java   Source Code and License 6 votes vote down vote up
@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;
    }
}
 
Example 7
Project: parabuild-ci   File: WebAppletTest.java   Source Code and License 6 votes vote down vote up
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() );
}
 
Example 8
Project: jdk8u-jdk   File: JTable.java   Source Code and License 6 votes vote down vote up
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();
    }
}
 
Example 9
Project: jdk8u-jdk   File: JComponent.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 10
Project: openjdk-jdk10   File: ORB.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 11
Project: Parabot-317-API-Minified-PkHonor   File: Loader.java   Source Code and License 5 votes vote down vote up
@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;
    }
}
 
Example 12
Project: NotifyTools   File: Beans.java   Source Code and License 5 votes vote down vote up
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));
}
 
Example 13
Project: LinkGame   File: EffectSound.java   Source Code and License 5 votes vote down vote up
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];
}
 
Example 14
Project: lembredio   File: Audio.java   Source Code and License 5 votes vote down vote up
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();
    
}
 
Example 15
Project: VASSAL-src   File: SoundConfigurer.java   Source Code and License 5 votes vote down vote up
protected AudioClipFactory createAudioClipFactory() {
  return new AudioClipFactory() {
    public AudioClip getAudioClip(URL url) {
      return Applet.newAudioClip(url);
    }
  };
}
 
Example 16
Project: jNotifyOSD   File: NotifyConfig.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 17
Project: lams   File: AppletContextImpl.java   Source Code and License 5 votes vote down vote up
/**
 * 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</code> attribute.
 *
 * @param   name   an applet name.
 * @return  the applet with the given name, or <code>null</code> if
 *          not found.
 */
public Applet getApplet( String name ) {
    try {
        WebApplet[] webApplets = _webApplet.getAppletsInPage();
        for (int i = 0; i < webApplets.length; i++) {
            if (webApplets[i].getName().equals( name )) return webApplets[i].getApplet();
        }
    } catch (Exception e) {
    }
    return null;
}
 
Example 18
Project: Camasia   File: Sound.java   Source Code and License 5 votes vote down vote up
private Sound(String name) {
  try {
		clip = Applet.newAudioClip( Sound.class
				  .getResource( name ) ); //tries to load the audio clip from the name you gave above.
  } catch ( Throwable e ) {
		e.printStackTrace( ); // else it will throw an error
  }
}
 
Example 19
Project: OpenJSharp   File: ORBImpl.java   Source Code and License 5 votes vote down vote up
protected void set_parameters(Applet app, Properties props)
{
    preInit( null, props ) ;
    DataCollector dataCollector =
        DataCollectorFactory.create( app, props, getLocalHostName() ) ;
    postInit( null, dataCollector ) ;
}
 
Example 20
Project: OpenJSharp   File: SpreadSheet.java   Source Code and License 5 votes vote down vote up
public InputField(String initValue, Applet app, int width, int height,
        Color bgColor, Color fgColor) {
    this.width = width;
    this.height = height;
    this.bgColor = bgColor;
    this.fgColor = fgColor;
    this.app = app;
    buffer = new char[maxchars];
    nChars = 0;
    if (initValue != null) {
        initValue.getChars(0, initValue.length(), this.buffer, 0);
        nChars = initValue.length();
    }
    sval = initValue;
}
 
Example 21
Project: OpenJSharp   File: Component.java   Source Code and License 5 votes vote down vote up
final Component getNextFocusCandidate() {
    Container rootAncestor = getTraversalRoot();
    Component comp = this;
    while (rootAncestor != null &&
           !(rootAncestor.isShowing() && rootAncestor.canBeFocusOwner()))
    {
        comp = rootAncestor;
        rootAncestor = comp.getFocusCycleRootAncestor();
    }
    if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
        focusLog.finer("comp = " + comp + ", root = " + rootAncestor);
    }
    Component candidate = null;
    if (rootAncestor != null) {
        FocusTraversalPolicy policy = rootAncestor.getFocusTraversalPolicy();
        Component toFocus = policy.getComponentAfter(rootAncestor, comp);
        if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
            focusLog.finer("component after is " + toFocus);
        }
        if (toFocus == null) {
            toFocus = policy.getDefaultComponent(rootAncestor);
            if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
                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)) {
        focusLog.finer("Focus transfer candidate: " + candidate);
    }
    return candidate;
}
 
Example 22
Project: OpenJSharp   File: Beans.java   Source Code and License 5 votes vote down vote up
BeansAppletStub(Applet target,
            AppletContext context, URL codeBase,
                            URL docBase) {
    this.target = target;
    this.context = context;
    this.codeBase = codeBase;
    this.docBase = docBase;
}
 
Example 23
Project: OpenJSharp   File: JComponent.java   Source Code and License 5 votes vote down vote up
/**
 * Returns the <code>Component</code>'s "visible rect rectangle" -  the
 * intersection of the visible rectangles for the component <code>c</code>
 * and all of its ancestors.  The return value is stored in
 * <code>visibleRect</code>.
 *
 * @param c  the component
 * @param visibleRect  a <code>Rectangle</code> computed as the
 *          intersection of all visible rectangles for the component
 *          <code>c</code> and all of its ancestors -- this is the
 *          return value for this method
 * @see #getVisibleRect
 */
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) {
        visibleRect.setBounds(0, 0, bounds.width, bounds.height);
    } else {
        computeVisibleRect(p, visibleRect);
        visibleRect.x -= bounds.x;
        visibleRect.y -= bounds.y;
        SwingUtilities.computeIntersection(0,0,bounds.width,bounds.height,visibleRect);
    }
}
 
Example 24
Project: OpenJSharp   File: BasicPopupMenuUI.java   Source Code and License 5 votes vote down vote up
boolean isInPopup(Component src) {
    for (Component c=src; c!=null; c=c.getParent()) {
        if (c instanceof Applet || c instanceof Window) {
            break;
        } else if (c instanceof JPopupMenu) {
            return true;
        }
    }
    return false;
}
 
Example 25
Project: Star-Ride--RiverRaid   File: EfectosSonido.java   Source Code and License 5 votes vote down vote up
public EfectosSonido(){
    URL url = getClass().getResource("laser.WAV");
    clipShoot = Applet.newAudioClip(url);
    url = getClass().getResource("explosion.wav");
    clipExplosion = Applet.newAudioClip(url);
    url = getClass().getResource("Beep.WAV");
    clipClick = Applet.newAudioClip(url);
}
 
Example 26
Project: parabuild-ci   File: AppletContextImpl.java   Source Code and License 5 votes vote down vote up
/**
 * 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</code> attribute.
 *
 * @param   name   an applet name.
 * @return  the applet with the given name, or <code>null</code> if
 *          not found.
 */
public Applet getApplet( String name ) {
    try {
        WebApplet[] webApplets = _webApplet.getAppletsInPage();
        for (int i = 0; i < webApplets.length; i++) {
            if (webApplets[i].getName().equals( name )) return webApplets[i].getApplet();
        }
    } catch (Exception e) {
    }
    return null;
}
 
Example 27
Project: parabuild-ci   File: WebAppletTest.java   Source Code and License 5 votes vote down vote up
public void testAppletLoading() throws Exception {
    defineWebPage( "start", "<applet code='" + SimpleApplet.class.getName() +
                            ".class' codebase=/classes width=100 height=100></applet>");
    mapToClasspath( "/classes" );
    WebConversation wc = new WebConversation();
    WebResponse response = wc.getResponse( getHostPath() + "/start.html" );
    WebApplet wa = response.getApplets()[0];
    Applet applet = wa.getApplet();
    assertNotNull( "Applet was not loaded", applet );
    assertEquals( "Applet class", SimpleApplet.class.getName(), applet.getClass().getName() );
}
 
Example 28
Project: parabuild-ci   File: WebAppletTest.java   Source Code and License 5 votes vote down vote up
public void notestAppletArchive() throws Exception {
    defineWebPage( "start", "<applet archive='/lib/xercesImpl.jar,/lib/xmlParserAPIs.jar'" +
                            " code='" + XMLApplet.class.getName() + ".class'" +
                            " codebase=/classes width=100 height=100></applet>");
    mapToClasspath( "/classes" );
    mapToClasspath( "/lib" );
    WebConversation wc = new WebConversation();
    WebResponse response = wc.getResponse( getHostPath() + "/start.html" );
    Applet applet = response.getApplets()[0].getApplet();
    Method testMethod = applet.getClass().getMethod( "getDocumentBuilder", new Class[0] );
    Object result = testMethod.invoke( applet, new Object[0] );
    assertEquals( "Superclass name", DocumentBuilder.class.getName(), result.getClass().getSuperclass().getName() );
}
 
Example 29
Project: parabuild-ci   File: WebAppletTest.java   Source Code and License 5 votes vote down vote up
public void testAppletParameterAccess() throws Exception {
    defineWebPage( "start", "<applet code='" + SimpleApplet.class.getName() +
                            ".class' codebase=/classes width=100 height=100>" +
                            "  <param name='color' value='ffff00'>" +
                            "  <param name='age' value='12'>" +
                            "</applet>");
    mapToClasspath( "/classes" );
    WebConversation wc = new WebConversation();
    WebResponse response = wc.getResponse( getHostPath() + "/start.html" );
    Applet applet = response.getApplets()[0].getApplet();
    assertNull( "Applet parameter 'hue' should be null", applet.getParameter( "hue" ) );
    assertEquals( "Applet parameter 'color'", "ffff00", applet.getParameter( "color" ) );
    assertEquals( "Applet parameter 'age'", "12", applet.getParameter( "age" ) );
}
 
Example 30
Project: parabuild-ci   File: WebAppletTest.java   Source Code and License 5 votes vote down vote up
public void testShowDocument() throws Exception {
    defineResource( "next.html", "You made it!" );
    defineWebPage( "start", "<applet code='" + SimpleApplet.class.getName() +
                            ".class' codebase=/classes width=100 height=100></applet>");
    mapToClasspath( "/classes" );
    WebConversation wc = new WebConversation();
    WebResponse response = wc.getResponse( getHostPath() + "/start.html" );
    WebApplet wa = response.getApplets()[0];
    Applet applet = wa.getApplet();
    applet.getAppletContext().showDocument( new URL( getHostPath() + "/next.html" ) );
    assertEquals( "current page URL", getHostPath() + "/next.html", wc.getCurrentPage().getURL().toExternalForm() );
}
 
Example 31
Project: jdk8u-jdk   File: SpreadSheet.java   Source Code and License 5 votes vote down vote up
public InputField(String initValue, Applet app, int width, int height,
        Color bgColor, Color fgColor) {
    this.width = width;
    this.height = height;
    this.bgColor = bgColor;
    this.fgColor = fgColor;
    this.app = app;
    buffer = new char[maxchars];
    nChars = 0;
    if (initValue != null) {
        initValue.getChars(0, initValue.length(), this.buffer, 0);
        nChars = initValue.length();
    }
    sval = initValue;
}
 
Example 32
Project: openjdk-jdk10   File: AppletFlipBuffer.java   Source Code and License 5 votes vote down vote up
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();
    }
}
 
Example 33
Project: jdk8u-jdk   File: Beans.java   Source Code and License 5 votes vote down vote up
BeansAppletStub(Applet target,
            AppletContext context, URL codeBase,
                            URL docBase) {
    this.target = target;
    this.context = context;
    this.codeBase = codeBase;
    this.docBase = docBase;
}
 
Example 34
Project: jdk8u-jdk   File: JComponent.java   Source Code and License 5 votes vote down vote up
/**
 * Returns the <code>Component</code>'s "visible rect rectangle" -  the
 * intersection of the visible rectangles for the component <code>c</code>
 * and all of its ancestors.  The return value is stored in
 * <code>visibleRect</code>.
 *
 * @param c  the component
 * @param visibleRect  a <code>Rectangle</code> computed as the
 *          intersection of all visible rectangles for the component
 *          <code>c</code> and all of its ancestors -- this is the
 *          return value for this method
 * @see #getVisibleRect
 */
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) {
        visibleRect.setBounds(0, 0, bounds.width, bounds.height);
    } else {
        computeVisibleRect(p, visibleRect);
        visibleRect.x -= bounds.x;
        visibleRect.y -= bounds.y;
        SwingUtilities.computeIntersection(0,0,bounds.width,bounds.height,visibleRect);
    }
}
 
Example 35
Project: jdk8u-jdk   File: BasicPopupMenuUI.java   Source Code and License 5 votes vote down vote up
boolean isInPopup(Component src) {
    for (Component c=src; c!=null; c=c.getParent()) {
        if (c instanceof Applet || c instanceof Window) {
            break;
        } else if (c instanceof JPopupMenu) {
            return true;
        }
    }
    return false;
}
 
Example 36
Project: openjdk-jdk10   File: DataCollectorFactory.java   Source Code and License 5 votes vote down vote up
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 ) ;
}
 
Example 37
Project: openjdk-jdk10   File: ORBImpl.java   Source Code and License 5 votes vote down vote up
protected void set_parameters(Applet app, Properties props)
{
    preInit( null, props ) ;
    DataCollector dataCollector =
        DataCollectorFactory.create( app, props, getLocalHostName() ) ;
    postInit( null, dataCollector ) ;
}
 
Example 38
Project: openjdk-jdk10   File: SpreadSheet.java   Source Code and License 5 votes vote down vote up
public InputField(String initValue, Applet app, int width, int height,
        Color bgColor, Color fgColor) {
    this.width = width;
    this.height = height;
    this.bgColor = bgColor;
    this.fgColor = fgColor;
    this.app = app;
    buffer = new char[maxchars];
    nChars = 0;
    if (initValue != null) {
        initValue.getChars(0, initValue.length(), this.buffer, 0);
        nChars = initValue.length();
    }
    sval = initValue;
}
 
Example 39
Project: openjdk-jdk10   File: Component.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("deprecation")
final Component getNextFocusCandidate() {
    Container rootAncestor = getTraversalRoot();
    Component comp = this;
    while (rootAncestor != null &&
           !(rootAncestor.isShowing() && rootAncestor.canBeFocusOwner()))
    {
        comp = rootAncestor;
        rootAncestor = comp.getFocusCycleRootAncestor();
    }
    if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
        focusLog.finer("comp = " + comp + ", root = " + rootAncestor);
    }
    Component candidate = null;
    if (rootAncestor != null) {
        FocusTraversalPolicy policy = rootAncestor.getFocusTraversalPolicy();
        Component toFocus = policy.getComponentAfter(rootAncestor, comp);
        if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
            focusLog.finer("component after is " + toFocus);
        }
        if (toFocus == null) {
            toFocus = policy.getDefaultComponent(rootAncestor);
            if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
                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)) {
        focusLog.finer("Focus transfer candidate: " + candidate);
    }
    return candidate;
}
 
Example 40
Project: openjdk-jdk10   File: Beans.java   Source Code and License 5 votes vote down vote up
BeansAppletStub(Applet target,
            AppletContext context, URL codeBase,
                            URL docBase) {
    this.target = target;
    this.context = context;
    this.codeBase = codeBase;
    this.docBase = docBase;
}