Turning a Java applett into a  *.exe

How do you turn a Java applett into an *.exe?

Have a look at http://gcc.gnu.org/java/. Its not complete, and I've never tried it on Windows, but it kinda works for linux.
The other thing you could do is create a C/C++ wrapper that starts a JVM and runs your main class. http://www.kcmultimedia.com/javaserv/ has some GPL code for doing this for an NT service, but the principle is the same for non-service apps.

Similar Messages

  • How do you turn java code into an .exe or etc...

    I can't seem to figure out how to turn my java code into an executable in windows so that it runs by itself without a comipler, can someone help? (without using visual J++).

    I can't seem to figure out how to turn my java code
    into an executable in windows so that it runs by
    itself without a comipler, can someone help? (without
    using visual J++).I saw a tutorial on that, you might want to check it out.
    http://developer.java.sun.com/developer/onlineTraining/new2java/divelog/?frontpage-headlinesfeatures

  • Compiling JAVA into Windows .exe files

    Hi,
    Here's an easy question - how do you compile JAVA source into Windows .exe files (as opposed to class files with bytecode in them). I imagine there is a third-party product out there somewhere?

    A Bayesian network is a mathematical representation of logical inference.
    A very simple example has two nodes: "has tail" and "is horse", connected by a single link. If we know "is horse" is true, then it nearly always follows that "has tail" is also true. This is called modus ponens in logic. If we know "has tail" is true, then "is horse" might be true, but it might not. To infer that "is horse" is true in such a case is to commit what is called the fallacy of affirming the consequent, in logic. However, using Bayes' theorem, which would require that we know some general information about the prevelance of horses among tailed animals, and the general prevalence of horses among things in general, we can measure the exact increase in the probability that "is horse" is true that results from our knowing "has tail" to be true.
    For more information, see http://www.bayesian.org
    The classic book on the subject is Judea Pearl, Probabilistic Reasoning in Intelligent Systems.

  • How can i convert java application of bibeans to java applet?

    Hi Bibeans PMTeam,
    Bibeans provide two type client:java application and web client(JSP/Servlet),because web client's function is weaker than java app,so we want to convert java app to java applet,thus,we can embed java applet into web browser(our system framework is in web browser).
    That is,we want one applet client that commution with a server side service(can by socket,just like oracle 9i form service)that provide the data that applet need,or the applet connect to olap server and bibeans catalog server by socket(this need security authentication if olap server,bibeans catalog,web server is not in one machine).
    so we need you provide whole resolve scheme,thanks a lot,if this answer is not clarity,please connect:[email protected],thanks a lot!

    hi tomsong
    well, in my experience 20mb are quite large for an applet. also take into account that you need a certain jvm that supports this type of application (my guess is that internet explorers native vm isnt an option)
    i personally would tend to deliver the functionality via java webstart (look at the sunsite):so you can centrally manage the software, download it once and opertae an application on your client (i mean an APPLICATION and not an applet)
    regarding 2: well but there is NO bibean service in ias: so you have to open the former mentioned jdbc connection to the olap service from your client
    for the availability: you have to check with the pm team
    in the meantime: what about the following approach: give power users a java application and lightweight or random users a handy html client ?
    regards,
    thomas

  • JAVA Applet embedded in a JSP MI Application.

    Hi
    I am trying to include a Java Applet into a JSP page in my MI application. The code is as follows:
    <jsp:plugin type = "applet"
         code = "com.mycompany.applet.myApplet.class">
    </jsp:plugin>
    It gave me a Class Not Found exception. If I place the class in the same directory that the JSP resides it works properly. It seems that I need to set the codebase and/or archive property to work. But every value I use to set them still gaves me the CLASS NOT FOUND Exception. I am using MI2.5 and the jar file is located at MYAPPS/WEB-INF/lib folder. Any suggestion will be appreciated.

    Hi,
       plz try the following and see whether it can be of any help.
    <jsp:plugin type = "applet"
    code = "com.mycompany.applet.myApplet.class         
    codebase=”http://localhost:4444/*”>
    </jsp:plugin>
    OR
    <jsp:plugin type = "applet"
    code = "com.mycompany.applet.myApplet
    archive="Applet.jar"       -
    > jar  
    codebase=”http://localhost:4444/*”>
    </jsp:plugin>
    The codebase plays an important role as when u r running it relatively on a web server, the path for code base becomes relative as is described above.
    plz try this and let me know.
    regards
    anubhav

  • Java-applet counter

    Hi there,
    I've created a java-applet that can be widely used so I encourage people to include the java applet into other sites by means of the <applet code="blah.class" codebase="http://www.blah.com/"></applet>I'm wondering however if it would be possible to keep statistics of how many times the applet is loaded. I created a free Nedstat subscription and here's some html code:
    <!-- Begin Nedstat Basic code -->
    <script language="JavaScript" type="text/javascript" src="http://m1.nedstatbasic.net/basic.js">
    </script>
    <script language="JavaScript" type="text/javascript" >
    <!--
      nedstatbasic("FPZ43f3d3d287Df", 0);
    // -->
    </script>
    <noscript>
    <a target="_blank" href="http://www.nedstatbasic.net/stats?FPZ43f3d3d287Df"><img
    src="http://m1.nedstatbasic.net/n?id=FPZ43f3d3d287Df"
    border="0" width="18" height="18"
    alt="Nedstat Basic - Free web site statistics
    Personal homepage website counter"></a><br>
    <a target="_blank" href="http://www.nedstatbasic.net/">Free counter</a>
    </noscript>
    <!-- End Nedstat Basic code -->I'm guessing that the javascript here "does the counting". Is there any possibility to include this javascript in the java applet, and how could it be done?
    Thank you very much,
    happy holidays
    W.

    cool i found another solution :-)
    cheers
    W.

  • Embed java applet in web dynpro

    Hi experts,
    is it possible to embed a java applet into a web Dynpro application. Or have I to use a jsp / Servlet / AbstractPortalApplication / (JSP)Dynpage
    Regards
    Fllo

    Hi
    yes its possible...
    go thorugh these docs..:[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/91b8c890-0201-0010-c787-be96f6fade89]
    [http://www.vogella.de/articles/SAPWebDynpro/article.html]
    [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8382535d-0d01-0010-dbb5-d3d41dfefd10]
    hpe it hlps u..
    Regards,
    Khushboo

  • Including java applets in pdf documents

    Dear all,
    I would like to include a java applet in a pdf document. Is this possible? If so, how would I go about it?
    Thanks,
    Philip

    A google search threw up the following:
    JView Acrobat Plug-in for Incorporating Java Applets into PDF Documents
    Acrobat Plug-in allowing generic network-aware and standalone Java Applets to be incorporated as content within PDF documents.
    See
    http://www.giavaneers.com/technology/technology.html
    Sorry, I have no other information about this item.

  • Java Applet in Flash CS4 (ActionScript 3.0)

    Hi Guys,
    I wonder if anyone can help me as I am a little confused.
    Is it possible to insert a Java Applet into Flash CS4 (ActionScript 3.0)
    Any advice is much appreciated
    Thanks

    I wouldn't swear to it, but I don't think you can "import" and run an applet internally in flash, but you can call it as an external file from flash and display/run it in an html container for example.
    Just as flash (swf) is run through FlashPlayer as the runtime environment, Applets use the Java Console as its runtime environment.

  • Java Applets in Flash CS4 (ActionScript 3.0)

    Hi Guys,
    I wonder if anyone can help me as I am a little confused.
    Is it possible to insert a Java Applet into Flash CS4 (ActionScript 3.0)
    Any advice is much appreciated
    Thanks

    Perhaps one can do it using AIR but not Flash IDE (CS4) or ActionScript.

  • How to load Java applets on Gemxplore 3G card ? (APDU inside)

    Hi,
    Does anyone have experience on how to load Java applets into Gemxplore 3G card ?
    I tried to load the tck applets into Gemxplore 3G card but the got sw 6985 for INSTALL FOR INSTALL Make Selectable
    Here is the details on APDUs.
    Do you know what is wrong ?
    Regards
    -guoqing
    SELECT
    *00 A4 04 00 07 A0 00 00 00 18 43 4D*
    *61 1A [Normal ending of the command with <26> bytes of extra information.]*
    INITIALIZE UPDATE
    *80 50 01 01 08 00 01 02 03 04 05 06 07 (1C)*
    *43 4D 6D FF 23 B5 C4 13 20 1A 01 01 9F 15 97 A5 CE E9 CF A7 19 C6 8D F9 8B 9A 78 DB, 90 00 [Normal ending of the command.]*
    EXTERNAL AUTHENTICATE
    *84 82 01 00 10 EB 88 23 3C B6 4E 23 E9 69 1B 30 08 56 7A 1F 8F*
    *90 00 [Normal ending of the command.]*
    INSTALL FOR LOAD
    *84 E6 02 00 24 09 A0 00 00 00 62 B0 BA A1 01 00 00 0E EF 0C C6 02 00 00 C8 02 00 00 C7 02 00 00 00 53 9D 96 C2 D4 8F 41 6B (00)*
    *00, 90 00 [Normal ending of the command.]*
    SELECT
    *00 A4 04 00 07 A0 00 00 00 18 43 4D*
    *61 1A [Normal ending of the command with <26> bytes of extra information.]*
    INITIALIZE UPDATE
    *80 50 01 01 08 00 01 02 03 04 05 06 07 (1C)*
    *43 4D 6D FF 23 B5 C4 13 20 1A 01 01 A5 57 A0 A0 00 7E 5A 3F A5 10 6A 37 69 16 AA 6F, 90 00 [Normal ending of the command.]*
    EXTERNAL AUTHENTICATE
    *84 82 01 00 10 28 BA 3A C4 D6 05 C9 C9 70 37 39 F1 7B 6D F8 80*
    *90 00 [Normal ending of the command.]*
    INSTALL FOR INSTALL Make Selectable
    *84 E6 0C 00 36 09 A0 00 00 00 62 B0 BA A1 01 09 A0 00 00 00 62 B0 BA A1 81 09 A0 00 00 00 62 B0 BA A1 81 01 00 0C EF 08 C7 02 00 00 C8 02 00 00 C9 00 00 A4 CE 57 8B 19 F2 9E 0A (00)*
    *69 85*
    Edited by: guoqing on May 19, 2008 6:06 AM
    Edited by: guoqing on May 19, 2008 6:20 AM

    I don't have any experience with GTO's cards, but one would expect they provide a user guide or a data sheet how to load applications.. Reasons could be:
    1. Issuer policy to have a certain security level for content management --> raise the security level to C_MAC + ENC
    2. Issuer policy this card is static --> no post-issuance

  • Invoking Java Applet from SAP Netweaver Eportal using java webdynpro

    Hi ,
    We are using SAP Netweaver portal version 7.0.WE want to invoke java applet into webdynpro java application on button click.
    The Applet should open in a new window when the particular parameter is selected and the button is clicked
    The code is given below:
    String html = "<HTML> <HEAD></HEAD> <BODY><APPLET code=\"org.faceless.pdf2.viewer2.PDFViewerApplet\" type=\"application/x-java-applet;version=1.4.2_05\" archive=\"bfopdf.jar\" width=800 height=600></APPLET></BODY></HTML>";
    IWDCachedWebResource resource = WDWebResource.getWebResource(html.getBytes("UTF-8"), WDWebResourceType.HTML);
    resource.setResourceName("HTML_inline.html");
    IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(resource.getAbsoluteURL(),"Image");
    window.removeWindowFeature(WDWindowFeature.TOOL_BAR);
    window.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);
    window.removeWindowFeature(WDWindowFeature.STATUS_BAR);
    window.open();
    But after clicking on button new html window is opening and the applet is not showing properly. The java console showing the error:
    java.lang.ClassFormatError: Truncated class file
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClassCond(Unknown Source)
         at java.lang.ClassLoader.defineClass(Unknown Source)
         at java.security.SecureClassLoader.defineClass(Unknown Source)
         at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Exception: java.lang.ClassFormatError: Truncated class file
    Please suggest how to solve this error.
    Regards,
    Dhruba

    Hi,
    I'm not sure, but I believe the 'code' argument should end with '.class'. However, your implementation of displaying a Java applet seems ok, the error is within the applet's Jar file
    Anyway, have a look at http://download.oracle.com/javase/1,5.0/docs/guide/plugin/developer_guide/using_tags.html#applet and http://www.w3.org/TR/html401/struct/objects.html#h-13.4 on how to use the <applet> tag
    As a test, you could try and create a local HTML document on your local desktop, including the applet. I would suspect you will receive the same error in your Java console
    I believe the only option is to recompile your Java applet (if possible at all) against a newer JDK (1.4 and up)

  • Changing Java class into Java Bean

    Can anybody tell me how to change a Java class into simple Java Bean.I dont need any visual interface of Java Bean.I simply want to turn my Java class into Java Bean.

    You can use almost any class as a java bean.
    To be a bean it must
    1 - Have a constructor which takes no arguments (so it can be instantiated)
    2 - For properties/attributes which you want to have readable/writable, provide get / set methods of the appropriate type.
    Thats it.

  • Php adding java applet

    Hi, I new to java and php and I want to use php and using java applet. How to add java applet into php. Please Help me.

    How to add java applet into php. Please Help me. If it is working in html why don't you puts those tags in your php page.
    something like this. But i don't know your PHP server support java..
    <?php 
    Your php  here
       ?>
    <applet code="MyApplet.class" width=100 height=140></applet>
    <?php 
    more php  here
       ?>Edited by: sunish_jose on Jan 29, 2009 12:41 PM

  • Problem converting a (working) Java program into an applet

    When I'm trying to access an Image through a call to :
    mediaTracker = new MediaTracker(this);
    backGroundImage = getImage(getDocumentBase(), "background.gif");
    mediaTracker.addImage(backGroundImage, 0);
    I'm getting a nullPointerException as a result of the call to getDocumentBase() :
    C:\Chantier\Java\BallsApplet
    AppletViewer testBallsApplet.htmljava.lang.NullPointerException
    at java.applet.Applet.getDocumentBase(Applet.java:125)
    at Balls.<init>(Balls.java:84)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
    orAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
    onstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
    at java.lang.Class.newInstance0(Class.java:296)
    at java.lang.Class.newInstance(Class.java:249)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:548)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:477)
    at sun.applet.AppletPanel.run(AppletPanel.java:290)
    at java.lang.Thread.run(Thread.java:536)
    It seems very weird to me... :-/
    (all the .gif files are in the same directory than the .class files)
    The problem appears with AppletViewer trying to open an HTML file
    containing :
    <HTML>
    <APPLET CODE="Balls.class" WIDTH=300 HEIGHT=211>
    </APPLET>
    </HTML>
    (I tried unsuccessfully the CODEBASE and ARCHIVE attributes, with and without putting the .gif and .class into a .jar file)
    I can't find the solution by myself, so, I'd be very glad if someone could help
    me with this... Thank you very much in advance ! :-)
    You'll find below the source of a small game that I wrote and debugged (without
    problem) and that I'm now (unsuccessfully) trying to convert into an Applet :
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.net.URL;
    public class Balls extends java.applet.Applet implements Runnable, KeyListener
    private Image offScreenImage;
    private Image backGroundImage;
    private Image[] gifImages = new Image[6];
    private Image PressStart ;
    private Sprite pressStartSprite = null ;
    private Image YouLose ;
    private Sprite YouLoseSprite = null ;
    private Image NextStage ;
    private Sprite NextStageSprite = null ;
    private Image GamePaused ;
    private Sprite GamePausedSprite = null ;
    //offscreen graphics context
    private Graphics offScreenGraphicsCtx;
    private Thread animationThread;
    private MediaTracker mediaTracker;
    private SpriteManager spriteManager;
    //Animation display rate, 12fps
    private int animationDelay = 83;
    private Random rand = new Random(System.currentTimeMillis());
    private int message = 0 ; // 0 = no message (normal playing phase)
    // 1 = press space to start
    // 2 = press space for next level
    // 3 = game PAUSED, press space to unpause
    // 4 = You LOSE
    public static void main(String[] args)
    try
    new Balls() ;
    catch (java.net.MalformedURLException e)
    System.out.println(e);
    }//end main
    public void start()
    //Create and start animation thread
    animationThread = new Thread(this);
    animationThread.start();
    public void init()
    try
    new Balls() ;
    catch (java.net.MalformedURLException e)
    System.out.println(e);
    public Balls() throws java.net.MalformedURLException
    {//constructor
    // Load and track the images
    mediaTracker = new MediaTracker(this);
    backGroundImage = getImage(getDocumentBase(), "background.gif");
    mediaTracker.addImage(backGroundImage, 0);
    PressStart = getImage(getDocumentBase(), "press_start.gif");
    mediaTracker.addImage(PressStart, 0);
    NextStage = getImage(getDocumentBase(), "stage_complete.gif");
    mediaTracker.addImage(NextStage, 0);
    GamePaused = getImage(getDocumentBase(), "game_paused.gif");
    mediaTracker.addImage(GamePaused, 0);
    YouLose = getImage(getDocumentBase(), "you_lose.gif");
    mediaTracker.addImage(YouLose, 0);
    //Get and track 6 images to use
    // for sprites
    gifImages[0] = getImage(getDocumentBase(), "blueball.gif");
    mediaTracker.addImage(gifImages[0], 0);
    gifImages[1] = getImage(getDocumentBase(), "redball.gif");
    mediaTracker.addImage(gifImages[1], 0);
    gifImages[2] = getImage(getDocumentBase(), "greenball.gif");
    mediaTracker.addImage(gifImages[2], 0);
    gifImages[3] = getImage(getDocumentBase(), "yellowball.gif");
    mediaTracker.addImage(gifImages[3], 0);
    gifImages[4] = getImage(getDocumentBase(), "purpleball.gif");
    mediaTracker.addImage(gifImages[4], 0);
    gifImages[5] = getImage(getDocumentBase(), "orangeball.gif");
    mediaTracker.addImage(gifImages[5], 0);
    //Block and wait for all images to
    // be loaded
    try {
    mediaTracker.waitForID(0);
    }catch (InterruptedException e) {
    System.out.println(e);
    }//end catch
    //Base the Frame size on the size
    // of the background image.
    //These getter methods return -1 if
    // the size is not yet known.
    //Insets will be used later to
    // limit the graphics area to the
    // client area of the Frame.
    int width = backGroundImage.getWidth(this);
    int height = backGroundImage.getHeight(this);
    //While not likely, it may be
    // possible that the size isn't
    // known yet. Do the following
    // just in case.
    //Wait until size is known
    while(width == -1 || height == -1)
    System.out.println("Waiting for image");
    width = backGroundImage.getWidth(this);
    height = backGroundImage.getHeight(this);
    }//end while loop
    //Display the frame
    setSize(width,height);
    setVisible(true);
    //setTitle("Balls");
    //Anonymous inner class window
    // listener to terminate the
    // program.
    this.addWindowListener
    (new WindowAdapter()
    {public void windowClosing(WindowEvent e){System.exit(0);}});
    // Add a key listener for keyboard management
    this.addKeyListener(this);
    }//end constructor
    public void run()
    Point center_place = new Point(
    backGroundImage.getWidth(this)/2-PressStart.getWidth(this)/2,
    backGroundImage.getHeight(this)/2-PressStart.getHeight(this)/2) ;
    pressStartSprite = new Sprite(this, PressStart, center_place, new Point(0, 0),true);
    center_place = new Point(
    backGroundImage.getWidth(this)/2-NextStage.getWidth(this)/2,
    backGroundImage.getHeight(this)/2-NextStage.getHeight(this)/2) ;
    NextStageSprite = new Sprite(this, NextStage, center_place, new Point(0, 0),true);
    center_place = new Point(
    backGroundImage.getWidth(this)/2-GamePaused.getWidth(this)/2,
    backGroundImage.getHeight(this)/2-GamePaused.getHeight(this)/2) ;
    GamePausedSprite = new Sprite(this, GamePaused, center_place, new Point(0, 0),true);
    center_place = new Point(
    backGroundImage.getWidth(this)/2-YouLose.getWidth(this)/2,
    backGroundImage.getHeight(this)/2-YouLose.getHeight(this)/2) ;
    YouLoseSprite = new Sprite(this, YouLose, center_place, new Point(0, 0),true);
    BackgroundImage bgimage = new BackgroundImage(this, backGroundImage) ;
    for (;;) // infinite loop
    long time = System.currentTimeMillis();
    message = 1 ; // "press start to begin"
    while (message != 0)
    repaint() ;
    try
    time += animationDelay;
    Thread.sleep(Math.max(0,time - System.currentTimeMillis()));
    catch (InterruptedException e)
    System.out.println(e);
    }//end catch
    boolean you_lose = false ;
    for (int max_speed = 7 ; !you_lose && max_speed < 15 ; max_speed++)
    for (int difficulty = 2 ; !you_lose && difficulty < 14 ; difficulty++)
    boolean unfinished_stage = true ;
    spriteManager = new SpriteManager(bgimage);
    spriteManager.setParameters(difficulty, max_speed) ;
    //Create 15 sprites from 6 gif
    // files.
    for (int cnt = 0; cnt < 15; cnt++)
    if (cnt == 0)
    Point position = new Point(
    backGroundImage.getWidth(this)/2-gifImages[0].getWidth(this)/2,
    backGroundImage.getHeight(this)/2-gifImages[0].getHeight(this)/2) ;
    spriteManager.addSprite(makeSprite(position, 0, false));
    else
    Point position = spriteManager.
    getEmptyPosition(new Dimension(gifImages[0].getWidth(this),
    gifImages[0].getHeight(this)));
    if (cnt < difficulty)
    spriteManager.addSprite(makeSprite(position, 1, true));
    else
    spriteManager.addSprite(makeSprite(position, 2, true));
    }//end for loop
    time = System.currentTimeMillis();
    while (!spriteManager.getFinishedStage() && !spriteManager.getGameOver())
    // Loop, sleep, and update sprite
    // positions once each 83
    // milliseconds
    spriteManager.update();
    repaint();
    try
    time += animationDelay;
    Thread.sleep(Math.max(0,time - System.currentTimeMillis()));
    catch (InterruptedException e)
    System.out.println(e);
    }//end catch
    }//end while loop
    if (spriteManager.getGameOver())
    message = 4 ;
    while (message != 0)
    spriteManager.update();
    repaint();
    try
    time += animationDelay;
    Thread.sleep(Math.max(0,time - System.currentTimeMillis()));
    catch (InterruptedException e)
    System.out.println(e);
    }//end catch
    you_lose = true ;
    if (spriteManager.getFinishedStage())
    message = 2 ;
    while (message != 0)
    spriteManager.update();
    repaint();
    try
    time += animationDelay;
    Thread.sleep(Math.max(0,time - System.currentTimeMillis()));
    catch (InterruptedException e)
    System.out.println(e);
    }//end catch
    } // end for difficulty loop
    } // end for max_speed
    } // end infinite loop
    }//end run method
    private Sprite makeSprite(Point position, int imageIndex, boolean wind)
    return new Sprite(
    this,
    gifImages[imageIndex],
    position,
    new Point(rand.nextInt() % 5,
    rand.nextInt() % 5),
    wind);
    }//end makeSprite()
    //Overridden graphics update method
    // on the Frame
    public void update(Graphics g)
    //Create the offscreen graphics
    // context
    if (offScreenGraphicsCtx == null)
    offScreenImage = createImage(getSize().width,
    getSize().height);
    offScreenGraphicsCtx = offScreenImage.getGraphics();
    }//end if
    if (message == 0)
    // Draw the sprites offscreen
    spriteManager.drawScene(offScreenGraphicsCtx);
    else if (message == 1)
    pressStartSprite.drawSpriteImage(offScreenGraphicsCtx);
    else if (message == 2)
    NextStageSprite.drawSpriteImage(offScreenGraphicsCtx);
    else if (message == 3)
    GamePausedSprite.drawSpriteImage(offScreenGraphicsCtx);
    else if (message == 4)
    YouLoseSprite.drawSpriteImage(offScreenGraphicsCtx);
    // Draw the scene onto the screen
    if(offScreenImage != null)
    g.drawImage(offScreenImage, 0, 0, this);
    }//end if
    }//end overridden update method
    //Overridden paint method on the
    // Frame
    public void paint(Graphics g)
    //Nothing required here. All
    // drawing is done in the update
    // method above.
    }//end overridden paint method
    // Methods to handle Keyboard event
    public void keyPressed(KeyEvent evt)
    int key = evt.getKeyCode(); // Keyboard code for the pressed key.
    if (key == KeyEvent.VK_SPACE)
    if (message != 0)
    message = 0 ;
    else
    message = 3 ;
    if (key == KeyEvent.VK_LEFT)
    if (spriteManager != null)
    spriteManager.goLeft() ;
    else if (key == KeyEvent.VK_RIGHT)
    if (spriteManager != null)
    spriteManager.goRight() ;
    else if (key == KeyEvent.VK_UP)
    if (spriteManager != null)
    spriteManager.goUp() ;
    else if (key == KeyEvent.VK_DOWN)
    if (spriteManager != null)
    spriteManager.goDown() ;
    if (spriteManager != null)
    spriteManager.setMessage(message) ;
    public void keyReleased(KeyEvent evt)
    public void keyTyped(KeyEvent e)
    char key = e.getKeyChar() ;
    //~ if (key == 's')
    //~ stop = true ;
    //~ else if (key == 'c')
    //~ stop = false ;
    //~ spriteManager.setStop(stop) ;
    }//end class Balls
    //===================================//
    class BackgroundImage
    private Image image;
    private Component component;
    private Dimension size;
    public BackgroundImage(
    Component component,
    Image image)
    this.component = component;
    size = component.getSize();
    this.image = image;
    }//end construtor
    public Dimension getSize(){
    return size;
    }//end getSize()
    public Image getImage(){
    return image;
    }//end getImage()
    public void setImage(Image image){
    this.image = image;
    }//end setImage()
    public void drawBackgroundImage(Graphics g)
    g.drawImage(image, 0, 0, component);
    }//end drawBackgroundImage()
    }//end class BackgroundImage
    //===========================
    class SpriteManager extends Vector
    private BackgroundImage backgroundImage;
    private boolean finished_stage = false ;
    private boolean game_over = false ;
    private int difficulty ;
    private int max_speed ;
    public boolean getFinishedStage()
    finished_stage = true ;
    for (int cnt = difficulty ; cnt < size(); cnt++)
    Sprite sprite = (Sprite)elementAt(cnt);
    if (!sprite.getEaten())
    finished_stage = false ;
    return finished_stage ;
    public boolean getGameOver() {return game_over ;}
    public void setParameters(int diff, int speed)
    difficulty = diff ;
    max_speed = speed ;
    finished_stage = false ;
    game_over = false ;
    Sprite sprite;
    for (int cnt = 0;cnt < size(); cnt++)
    sprite = (Sprite)elementAt(cnt);
    sprite.setSpeed(max_speed) ;
    public SpriteManager(BackgroundImage backgroundImage)
    this.backgroundImage = backgroundImage ;
    }//end constructor
    public Point getEmptyPosition(Dimension spriteSize)
    Rectangle trialSpaceOccupied = new Rectangle(0, 0,
    spriteSize.width,
    spriteSize.height);
    Random rand = new Random(System.currentTimeMillis());
    boolean empty = false;
    int numTries = 0;
    // Search for an empty position
    while (!empty && numTries++ < 100)
    // Get a trial position
    trialSpaceOccupied.x =
    Math.abs(rand.nextInt() %
    backgroundImage.
    getSize().width);
    trialSpaceOccupied.y =
    Math.abs(rand.nextInt() %
    backgroundImage.
    getSize().height);
    // Iterate through existing
    // sprites, checking if position
    // is empty
    boolean collision = false;
    for(int cnt = 0;cnt < size(); cnt++)
    Rectangle testSpaceOccupied = ((Sprite)elementAt(cnt)).getSpaceOccupied();
    if (trialSpaceOccupied.intersects(testSpaceOccupied))
    collision = true;
    }//end if
    }//end for loop
    empty = !collision;
    }//end while loop
    return new Point(trialSpaceOccupied.x, trialSpaceOccupied.y);
    }//end getEmptyPosition()
    public void update()
    Sprite sprite;
    // treat special case of sprite #0 (the player)
    sprite = (Sprite)elementAt(0);
    sprite.updatePosition() ;
    int hitIndex = testForCollision(sprite);
    if (hitIndex != -1)
    if (hitIndex < difficulty)
    { // if player collides with an hunter (red ball), he loose
    sprite.setEaten() ;
    game_over = true ;
    else
    // if player collides with an hunted (green ball), he eats the green
    ((Sprite)elementAt(hitIndex)).setEaten() ;
    //Iterate through sprite list
    for (int cnt = 1;cnt < size(); cnt++)
    sprite = (Sprite)elementAt(cnt);
    //Update a sprite's position
    sprite.updatePosition();
    //Test for collision. Positive
    // result indicates a collision
    hitIndex = testForCollision(sprite);
    if (hitIndex >= 0)
    //a collision has occurred
    bounceOffSprite(cnt,hitIndex);
    }//end if
    }//end for loop
    }//end update
    public void setMessage(int message)
    Sprite sprite;
    //Iterate through sprite list
    for (int cnt = 0;cnt < size(); cnt++)
    sprite = (Sprite)elementAt(cnt);
    //Update a sprite's stop status
    sprite.setMessage(message);
    }//end for loop
    }//end update
    public void goLeft()
    Sprite sprite = (Sprite)elementAt(0);
    sprite.goLeft() ;
    public void goRight()
    Sprite sprite = (Sprite)elementAt(0);
    sprite.goRight() ;
    public void goUp()
    Sprite sprite = (Sprite)elementAt(0);
    sprite.goUp() ;
    public void goDown()
    Sprite sprite = (Sprite)elementAt(0);
    sprite.goDown() ;
    private int testForCollision(Sprite testSprite)
    //Check for collision with other
    // sprites
    Sprite sprite;
    for (int cnt = 0;cnt < size(); cnt++)
    sprite = (Sprite)elementAt(cnt);
    if (sprite == testSprite)
    //don't check self
    continue;
    //Invoke testCollision method
    // of Sprite class to perform
    // the actual test.
    if (testSprite.testCollision(sprite))
    //Return index of colliding
    // sprite
    return cnt;
    }//end for loop
    return -1;//No collision detected
    }//end testForCollision()
    private void bounceOffSprite(int oneHitIndex, int otherHitIndex)
    //Swap motion vectors for
    // bounce algorithm
    Sprite oneSprite = (Sprite)elementAt(oneHitIndex);
    Sprite otherSprite = (Sprite)elementAt(otherHitIndex);
    Point swap = oneSprite.getMotionVector();
    oneSprite.setMotionVector(otherSprite.getMotionVector());
    otherSprite.setMotionVector(swap);
    }//end bounceOffSprite()
    public void drawScene(Graphics g)
    //Draw the background and erase
    // sprites from graphics area
    //Disable the following statement
    // for an interesting effect.
    backgroundImage.drawBackgroundImage(g);
    //Iterate through sprites, drawing
    // each sprite
    for (int cnt = 0;cnt < size(); cnt++)
    ((Sprite)elementAt(cnt)).drawSpriteImage(g);
    }//end drawScene()
    public void addSprite(Sprite sprite)
    addElement(sprite);
    }//end addSprite()
    }//end class SpriteManager
    //===================================//
    class Sprite
    private Component component;
    private Image image;
    private Rectangle spaceOccupied;
    private Point motionVector;
    private Rectangle bounds;
    private Random rand;
    private int message = 0 ; // number of message currently displayed (0 means "no message" = normal game)
    private int max_speed = 7 ;
    private boolean eaten = false ; // when a green sprite is eaten, it is no longer displayed on screen
    private boolean wind = true ;
    private boolean go_left = false ;
    private boolean go_right = false ;
    private boolean go_up = false ;
    private boolean go_down = false ;
    public Sprite(Component component,
    Image image,
    Point position,
    Point motionVector,
    boolean Wind
    //Seed a random number generator
    // for this sprite with the sprite
    // position.
    rand = new Random(position.x);
    this.component = component;
    this.image = image;
    setSpaceOccupied(new Rectangle(
    position.x,
    position.y,
    image.getWidth(component),
    image.getHeight(component)));
    this.motionVector = motionVector;
    this.wind = Wind ;
    //Compute edges of usable graphics
    // area in the Frame.
    int topBanner = ((Container)component).getInsets().top;
    int bottomBorder = ((Container)component).getInsets().bottom;
    int leftBorder = ((Container)component).getInsets().left;
    int rightBorder = ((Container)component).getInsets().right;
    bounds = new Rectangle( 0 + leftBorder, 0 + topBanner
    , component.getSize().width - (leftBorder + rightBorder)
    , component.getSize().height - (topBanner + bottomBorder));
    }//end constructor
    public void setMessage(int message_number)
    message = message_number ;
    public void setSpeed(int speed)
    max_speed = speed ;
    public void goLeft()
    go_left = true ;
    public void goRight()
    go_right = true ;
    public void goUp()
    go_up = true ;
    public void goDown()
    go_down = true ;
    public void setEaten()
    eaten = true ;
    setSpaceOccupied(new Rectangle(4000,4000,0,0)) ;
    public boolean getEaten()
    return eaten ;
    public Rectangle getSpaceOccupied()
    return spaceOccupied;
    }//end getSpaceOccupied()
    void setSpaceOccupied(Rectangle spaceOccupied)
    this.spaceOccupied = spaceOccupied;
    }//setSpaceOccupied()
    public void setSpaceOccupied(
    Point position){
    spaceOccupied.setLocation(
    position.x, position.y);
    }//setSpaceOccupied()
    public Point getMotionVector(){
    return motionVector;
    }//end getMotionVector()
    public void setMotionVector(
    Point motionVector){
    this.motionVector = motionVector;
    }//end setMotionVector()
    public void setBounds(Rectangle bounds)
    this.bounds = bounds;
    }//end setBounds()
    public void updatePosition()
    Point position = new Point(spaceOccupied.x, spaceOccupied.y);
    if (message != 0)
    return ;
    //Insert random behavior. During
    // each update, a sprite has about
    // one chance in 10 of making a
    // random change to its
    // motionVector. When a change
    // occurs, the motionVector
    // coordinate values are forced to
    // fall between -7 and 7. This
    // puts a cap on the maximum speed
    // for a sprite.
    if (!wind)
    if (go_left)
    motionVector.x -= 2 ;
    if (motionVector.x < -15)
    motionVector.x = -14 ;
    go_left = false ;
    if (go_right)
    motionVector.x += 2 ;
    if (motionVector.x > 15)
    motionVector.x = 14 ;
    go_right = false ;
    if (go_up)
    motionVector.y -= 2 ;
    if (motionVector.y < -15)
    motionVector.y = -14 ;
    go_up = false ;
    if (go_down)
    motionVector.y += 2 ;
    if (motionVector.y > 15)
    motionVector.y = 14 ;
    go_down = false ;
    else if(rand.nextInt() % 7 == 0)
    Point randomOffset =
    new Point(rand.nextInt() % 3,
    rand.nextInt() % 3);
    motionVector.x += randomOffset.x;
    if(motionVector.x >= max_speed)
    motionVector.x -= max_speed;
    if(motionVector.x <= -max_speed)
    motionVector.x += max_speed ;
    motionVector.y += randomOffset.y;
    if(motionVector.y >= max_speed)
    motionVector.y -= max_speed;
    if(motionVector.y <= -max_speed)
    motionVector.y += max_speed;
    }//end if
    //Move the sprite on the screen
    position.translate(motionVector.x, motionVector.y);
    //Bounce off the walls
    boolean bounceRequired = false;
    Point tempMotionVector = new Point(
    motionVector.x,
    motionVector.y);
    //Handle walls in x-dimension
    if (position.x < bounds.x)
    bounceRequired = true;
    position.x = bounds.x;
    //reverse direction in x
    tempMotionVector.x = -tempMotionVector.x;
    else if ((position.x + spaceOccupied.width) > (bounds.x + bounds.width))
    bounceRequired = true;
    position.x = bounds.x +
    bounds.width -
    spaceOccupied.width;
    //reverse direction in x
    tempMotionVector.x =
    -tempMotionVector.x;
    }//end else if
    //Handle walls in y-dimension
    if (position.y < bounds.y)
    bounceRequired = true;
    position.y = bounds.y;
    tempMotionVector.y = -tempMotionVector.y;
    else if ((position.y + spaceOccupied.height)
    > (bounds.y + bounds.height))
    bounceRequired = true;
    position.y = bounds.y +
    bounds.height -
    spaceOccupied.height;
    tempMotionVector.y =
    -tempMotionVector.y;
    }//end else if
    if(bounceRequired)
    //save new motionVector
    setMotionVector(
    tempMotionVector);
    //update spaceOccupied
    setSpaceOccupied(position);
    }//end updatePosition()
    public void drawSpriteImage(Graphics g)
    if (!eaten)
    g.drawImage(image,
    spaceOccupied.x,
    spaceOccupied.y,
    component);
    }//end drawSpriteImage()
    public boolean testCollision(Sprite testSprite)
    //Check for collision with
    // another sprite
    if (testSprite != this)
    return spaceOccupied.intersects(
    testSprite.getSpaceOccupied());
    }//end if
    return false;
    }//end testCollision
    }//end Sprite class
    //===================================//
    Thanks for your help...

    Sorry,
    Can you tell me how do you solve it because I have got the same problem.
    Can you indicate me the topic where did you find solution.
    Thank in advance.

Maybe you are looking for

  • How to Configure Cisco ASA 5512 for multiple public IP interfaces

    Hi I have a new ASA 5512 that I would like to configure for multiple public IP support.  My problem may be basic but I am an occasional router admin and don't touch this stuff enough to retain everything I have learned. Here is my concept.    We have

  • NON PROFIT ORGANIZATIONS. Does Adobe envisage a discount for CC or single app subscription?

    Do you know if Adobe envisage a discount for CC or single app subscription dedicated to non profit organizations? How can I contact the Marketing division? Thank you.

  • Colors are displayed not correct

    Hi! I use lightroom 3.4.1 on Windows Vista 64bit with a Iiyama PRO LITE E2407 HDS monitor and a ATI Raedon HD3600. The colors of some images that I imported from my Canon EOS 500d into lightroom are "strange". If I display the same image with another

  • Deauthorizing my Computer for iTunes

    I have a Windows based laptop. There is an error in the operating system that will not let me open iTunes any more. (iTunes worked fine for a long time, and the error just started one day.) The guy in the genius bar could not figure it out. He sugges

  • WRT160N V2: wireless works great, but wired intermittent and slow

    Getting very good connection and speed in wireless.  But when I connect the ethernet cable, the speed slows down and half the time I get "cannot connect" error messages.  I bought this router in Oct 2009 and so don't know if it needs a firmware updat