Package java.applet

Examples of java.applet.Applet$URLAudioClip


     * @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();
View Full Code Here


                if (focusLog.isLoggable(PlatformLogger.FINER)) {
                    focusLog.finer("default component is " + toFocus);
                }
            }
            if (toFocus == null) {
                Applet applet = EmbeddedFrame.getAppletIfAncestorOf(this);
                if (applet != null) {
                    toFocus = applet;
                }
            }
            candidate = toFocus;
View Full Code Here

            // 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 serialzied 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 correponding to the resource name.

                    final ClassLoader cloader = cls;
                    objectUrl = (URL)
                        AccessController.doPrivileged
                        (new PrivilegedAction() {
                            public Object run() {
                                if (cloader == null)
                                    return ClassLoader.getSystemResource
                                                                (resourceName);
                                else
                                    return cloader.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 = new URL(s.substring(0,ix));
                            docBase  = codeBase;

                            ix = s.lastIndexOf('/');

                            if (ix >= 0) {
                                docBase = new URL(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) {
                    beanContext.add(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);
View Full Code Here

        final Properties parameters = new Properties();
        parameters.setProperty("key1", "value1");
        parameters.setProperty("key2", "value2");
        parameters.setProperty("list", "value1, value2");

        Applet applet = new Applet()
        {
            public String getParameter(String key)
            {
                return parameters.getProperty(key);
            }
View Full Code Here

        return new AppletConfiguration(applet);
    }

    protected AbstractConfiguration getEmptyConfiguration()
    {
        return new AppletConfiguration(new Applet());
    }
View Full Code Here

    public void highlightPeakInTable(int atomNumber) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException{
      if(getParameter("highlightTable")==null || getParameter("highlightTable").equals("false"))
        return;
     

      Class[] paratypes={new Applet().getClass()};
      Class jso = Class.forName("netscape.javascript.JSObject");
      Method getWindowMethod=jso.getMethod("getWindow", paratypes);
      Object win=getWindowMethod.invoke(jso, new Object[] {this});
      Class[] paratypes2={new String("").getClass()};
      Method evalMethod=jso.getMethod("eval", paratypes2);
View Full Code Here

     * @param atomNumber atom number of peaks highlighted in table
     */
    public void highlightPeakInTable(int atomNumber) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException{
      if(jcpApplet==null || jcpApplet.getParameter("highlightTable")==null)
          return;
      Class[] paratypes={new Applet().getClass()};
      Class jso = Class.forName("netscape.javascript.JSObject");
      Method getWindowMethod=jso.getMethod("getWindow", paratypes);
      Object win=getWindowMethod.invoke(jso, new Object[] {jcpApplet});
      Class[] paratypes2={new String("").getClass()};
      Method evalMethod=jso.getMethod("eval", paratypes2);
View Full Code Here

                if (focusLog.isLoggable(PlatformLogger.FINER)) {
                    focusLog.finer("default component is " + toFocus);
                }
            }
            if (toFocus == null) {
                Applet applet = EmbeddedFrame.getAppletIfAncestorOf(this);
                if (applet != null) {
                    toFocus = applet;
                }
            }
            candidate = toFocus;
View Full Code Here

     
    }
    else {
      // applet game should display to the user
      // that the game has been ended
      final Applet applet = (Applet) this.bsGraphics;
      BufferedImage src = ImageUtil.createImage(this.getWidth(), this
              .getHeight());
      Graphics2D g = src.createGraphics();
     
      try {
        // fill background
        g.setColor(Color.BLACK);
        g.fillRect(0, 0, this.getWidth(), this.getHeight());
       
        // play with transparency a bit
        g.setComposite(AlphaComposite.getInstance(
                AlphaComposite.SRC_OVER, 0.8f));
       
        // draw in a circle only
        Shape shape = new java.awt.geom.Ellipse2D.Float(
                this.getWidth() / 10, this.getHeight() / 10, this
                        .getWidth()
                        - (this.getWidth() / 10 * 2), this.getHeight()
                        - (this.getHeight() / 10 * 2));
        g.setClip(shape);
       
        // draw the game unto this image
        if (this instanceof GameEngine) {
          ((GameEngine) this).getCurrentGame().render(g);
        }
        this.render(g);
       
        g.dispose();
      }
      catch (Exception e) {
        g.setColor(Color.BLACK);
        g.fillRect(0, 0, this.getWidth(), this.getHeight());
        g.dispose();
      }
     
      // make it as gray
      BufferedImage converted = null;
      try {
        // technique #1
        // ColorSpace gray = ColorSpace.getInstance(ColorSpace.CS_GRAY);
        // converted = new ColorConvertOp(gray, null).filter(src, null);
       
        // technique #2
        BufferedImage image = new BufferedImage(src.getWidth(), src
                .getHeight(), BufferedImage.TYPE_BYTE_GRAY);
        Graphics gfx = image.getGraphics();
        gfx.drawImage(src, 0, 0, null);
        gfx.dispose();
        converted = image;
       
        // technique #3
        // ImageFilter filter = new GrayFilter(true, 75);
        // ImageProducer producer = new
        // FilteredImageSource(colorImage.getSource(), filter);
        // Image mage = this.createImage(producer);
       
      }
      catch (Throwable e) {
      }
      final BufferedImage image = (converted != null) ? converted : src;
     
      applet.removeAll();
      applet.setIgnoreRepaint(false);
     
      Canvas canvas = new Canvas() {
       
        /**
         *
         */
        private static final long serialVersionUID = 8493852179266447783L;
       
        public void paint(Graphics g1) {
          Graphics2D g = (Graphics2D) g1;
         
          // draw game image
          g.drawImage(image, 0, 0, null);
         
          // draw text
          g.setColor(Color.YELLOW);
          g.setFont(new Font("Verdana", Font.BOLD, 12));
          g.drawString("Game has been ended", 10, 25);
          g.drawString("Thank you for playing!", 10, 45);
          g.drawString("Visit http://www.goldenstudios.or.id/", 10,
                  75);
          g.drawString("For free game engine!", 10, 95);
          g.drawString("This game is developed with GTGE v"
                  + Game.GTGE_VERSION, 10, 115);
        }
      };
      canvas.setSize(applet.getSize());
      canvas.addMouseListener(new MouseAdapter() {
       
        public void mouseClicked(MouseEvent e) {
          try {
            applet.getAppletContext().showDocument(
                    new URL("http://goldenstudios.or.id/"));
          }
          catch (Exception excp) {
          }
        }
      });
     
      applet.add(canvas);
      applet.repaint();
      canvas.repaint();
    }
  }
View Full Code Here

TOP

Related Classes of java.applet.Applet$URLAudioClip

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.