Applet (Loading things ony once)

Is there a way to only load things that you want once with an Applet. I only want the buttons and the background to load one time and then I want paint to just move an airplane across the screen (on top of the bg). Here is the code I'm using. When I comment out the firstTime flag it works (but it flickers)
private boolean firstTime = true;
public void paint(Graphics g)
  if (firstTime)
   doStuff(g);
   firstTime = false;
  g.drawImage(airplane, xPos, 0, 150, 100, this);
  xPos += 10;
  repaint(); 
// I want this executed once. Possible?
public void doStuff(Graphics g)
  // Get the width and height of the applet.  
  int width = getWidth();
  int height = getHeight();  
  // Set the 'level' buttons to the lower left hand corner
  // of the scren.
  easy.setBounds(0,height-20,40,20);
  medium.setBounds(50, height-20, 50, 20);
  hard.setBounds(110, height-20, 50,20);
  // Draw the background image.
  g.drawImage(bg1, 0, 0, width, height, this);
  firstTime = false; 
}

i did, but the problem was that i couldn't draw the image because i didn't have a Graphics object. When I created a graphics object it still didn't draw it.

Similar Messages

  • Is there any thing called applet loading timeout

    Friends...
    Is there anything known as applet loading timeout....
    One of my applets is geting loaded on intranet 1 which is faster but is not being loading on intranet 2 (a bit slower) keeping everything else same....
    please guide...
    what could be the reason...
    regards
    raghav..

    yes there are no exceptions until it says class not found exception..
    and yes of course they are into a jar file.
    raghav

  • Multiple instances of the same applet loaded causes problem

    I have a java applet that has several classes in the project. The applet has a JTable a JButton and a JLabel control. The applet is displayed within an HTML page. The problem is that if a user opens the same html page more than once with the applet in it, only the last applet loaded receives the screen updates.
    For example in one senario. I have an error message that displays in the Label control once they click on the button.
    The user opens the html page and the applet is loaded (window 1). The user then opens the same html page again (window 2) with window 1 still open. If the user clicks on the Button in window 1, the error message is displayed in the window 2 applet.
    Originally I had some static variables. Thinking it was being used globally by the JVM so I removed all of them and it still happens. I have tried using both the Applet and Object tag. But it still happens.
    Has anyone experienced this before? Any suggestions on how to make the applet update the instance that recieved the events and not just the last one that was loaded?

    You need to look at applet classloader issues. If applets have the same archive list and come from the same codebase, they have the same classloader. A class is namespaced by it's class + classloader. Any statics in a class with a classloader will be shared. If you instead make it such that your applets have unique classloaders (which you can't change for unsigned applets by yourself) by changing the codebase, that would be one solution.
    For other solutions, I recommend searching the forum. This issue comes up a lot.

  • How to make an applet load user-defined package?

    How to have an applet load user-defined package?
    I have packages in their own directories, and the applet compiles and links with them, by use of CLASSPATH env variable. But when it comes time to run, it ignores that and does not know where the classes (in the packages) are.
    If I don't use packages and put all code in one directory, runs fine. If I use an application, I can link with and load my packages.
    I know applets can't use things like CLASSPATH for security reasons, but still, they should be able to be compiled out of several packages, why do I have to put all code together??

    OK, for reference for future newbies, here's the answer:
    use CODEBASE attribute in your html file (if on Windows server, don't use drive letter but relative path to .html file, Unix style, and put all your .class files beneath that, for example, in your .html file
    <applet
    CODEBASE="..\class
    and then have package bar Bar.class file, in ..\class\bar

  • Removing gray crappy ugly Applet loader background

    excuse my language but I've spent the last two days tring to figure out how to remove the gray screen when the applet loads in a browser...
    I've searched the forums, found other ppl with same problem but no real solutions...
    from what I found:
    1. using javascript to hide the applet while its loading
    works for IE but not for Netscape 6( http://www.codeproject.com/java/javaappletwaitmsg.asp )
    2. using an applet to load the real applet
    seems ok, but you still see the gray screen when the first applet loads... basically this just shortens the time you get to see the gray screen, not a proper solution( http://www.acm.vt.edu/~jmaxwell/appletloader/appletloader.html )
    So should I assume there is no way to tell the java plug-in not to make the screen gray while its loading the applet??????
    WHY? WHY? WHY?
    is there really no way of changing this horrible GRAY screen???
    please if anybody found out how to solve this, post it here!

    2 main reasons why the gray panel stays for a long time..
    1, the JVM is loaded, the applet is now visible but due to lots of late binding and other startup stuff, the Applet itself takes a long time to load.
    Solution, in a previous page, load a dummy applet that does basically nothing and make it 1x1 pixels in width and height. This cuts down on the JVM start up.
    2, Your Applet causes classes to load from the Web Server (of course).
    Solution in 2 parts:
    Part 1, make sure that all your applet classes are jar'ed with compression on and that your applet code has debug code off and no optimisation used when compiling. This ensures the smallest code size other than that produced an obfuscator.
    Part 2, Your applet should be doing 2 things. Firstly, it should be attempting to turn its background to the chosen colour as soon as possible. It should be doing nothing else at all, not even creating other classes, loading classes nothing at all. Secondly, when the Applets background colour is set, then you can start loading classes that do the work your Applet is supposed to do. When that is all over, you can that start to modify the Applet's panel

  • Java Applet Load Issues

    For some applets, well, nothing happens. Im not sure what the problem is, but certain applets load, and other applets just make a gray frame and generate an error. Even my own applets I compile dont run. Everything works properly on my applets, because I can run them in the appletviewer, just not in the browser (which is kinda essential for running other peoples applets on the web, ya know). Odd thing is I can run them on my other comp, and practically the only difference is that it doesnt have the SDK on it.
    Computer specs are: WinME with JDK and JRE v 1.4.1_01, and the JVM on it.
    An excerpt of the error it generates every time a problematic applet is run (from my javalog.txt file):
    Error loading class: <AppletName>
    java.lang.NoClassDefFoundError
    java.lang.ClassNotFoundException: <AppletName>
         at com/ms/vm/loader/URLClassLoader.loadClass
         at com/ms/vm/loader/URLClassLoader.loadClass
         at com/ms/applet/AppletPanel.securedClassLoad
         at com/ms/applet/AppletPanel.processSentEvent
         at com/ms/applet/AppletPanel.processSentEvent
         at com/ms/applet/AppletPanel.run
         at java/lang/Thread.run
    I have no idea what any of that mess is, or why its so painful. If anyone can give a hand, Ill be checking here every 10 seconds until the time that it gets fixed, or you can email me at [email protected], thanks.

    Can you find a "Sun Java Console" entry on IE's Tools menu? If not, the Sun jvm isn't installed in a manner that IE can access.
    The messages that you posted in your original post are from the MS jvm. If the Sun jvm is operating, you shouldn't be seeing those messages.
    If the Sun jvm is being invoked by IE, then a red/blue icon of a steaming cup of coffee will be in the Systray area of the Start bar - at the far right. If it's there, a rightclick will allow you to open the Sun java console, which will report any problems or errors encountered.
    Check it out.

  • I have a 2nd gen itouch and i tried to restore it...but i took the cord out on accident while restoring...so everytime it turns on it stops at the apple screen with the little loading thing that looks like a flower. it wont even connect to my laptop.help?

    ok, so my itouch 2nd gen starts up only to the apple logo but stops there with the loading thing that looks like a flower. it doesnt connect to my laptop either. it got unplugged while trying to restore it on my laptop and now its not rly working. any help? i alredy tried holding both buttons down like more than 100 times and it still doesnt work. so any solutions?

    Try placing the iPod in recovery mode and then try restoring the iPOd via iTunes.  For recovery mode see:
    http://support.apple.com/kb/HT1212

  • My i pod has loading thing under the apple symbol on screen what do i do it doesnt respond and restarting it doesnt help

    my i pod has loading thing under the apple symbol on screen what do i do it doesnt respond and restarting it doesnt help

    If not successful try the remaining items of
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar       

  • Why won't my Mac Pro load things without locking up ?

    Why won't my Mac Pro load things or let me do a "save as" without locking up ? I have tried to run the Apple Hardware Test and it locks up as well.

    you have anitebook in forum for 65lbs towers
    youneed to repair your disk directory or erase and restore
    and use Recovery Mode in 10.7 and later
    AHT does not lick up, not unless your laptop RAM or mobo has failed totally and died, more common for laptops that overheat, sufferwater damage, but still...
    depends on how new what to do, might try macbookmpro forum.

  • Java applet loading for a long time.

    If you go here (warning - long load to start with) -
    www.aclwebsite.co.uk
    I have placed a newsticker java applet there but when you first visit the site the browser freezes up for a while untill the applet loads.
    Any idea on whats causing this to load so much?
    Thanks.

    If you go here (warning - long load to start with) -
    www.aclwebsite.co.uk
    I have placed a newsticker java applet there but when
    you first visit the site the browser freezes up for a
    while untill the applet loads.
    Any idea on whats causing this to load so much?
    Thanks.A long-running init() or start() method of the applet. I guess you better do something about your own code then.

  • Java 1.5_13 applet loading problem due to 'activate control' fix

    I updated my JRE to Java 1.5 revision 13, and it seems to introduce a new problem. In order to fix the "click here to activate this control" problem in internet explorer, I iterate the document model and set the outerHTML of the applet tag to the same outerHTML. This removes the annoying rectangle in IE. This also causes the applet to load and break down the first time the page is displayed, because IE removes the old applet instance and creates a new one when replacing the outerHTML. When this happens on the new Java JRE release, an exception is thrown to the user saying:
    java.lang.NullPointerException
         at sun.plugin.AppletViewer.loadJarFiles(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    The applet loads correctly, but the message should not be displayed. Also, it only seems to happen sometimes (maybee because sometimes the applet does not yet start before IE runs the script to replace its contents)
    Full lifecyle from the console panel:
    basic: Registered modality listener
    basic: Registered modality listener
    liveconnect: Invoking JS method: document
    liveconnect: Invoking JS method: URL
    basic: Referencing classloader: sun.plugin.ClassLoaderInfo@181fbd6, refcount=5
    basic: Added progress listener: sun.plugin.util.GrayBoxPainter@982291
    basic: Loading applet ...
    basic: Initializing applet ...
    basic: Starting applet ...
    basic: Unregistered modality listener
    basic: Stopping applet ...
    basic: Removed progress listener: sun.plugin.util.GrayBoxPainter@982291
    basic: Finding information ...
    basic: Releasing classloader: sun.plugin.ClassLoaderInfo@181fbd6, refcount=4
    basic: Done ...
    basic: Joining applet thread ...
    basic: Destroying applet ...
    basic: Disposing applet ...
    java.lang.NullPointerException
         at sun.plugin.AppletViewer.loadJarFiles(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    basic: Exception: java.lang.NullPointerException
    java.lang.NullPointerException
         at sun.plugin.AppletViewer.loadJarFiles(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    basic: Joined applet thread ...
    basic: Unregistered modality listener
    basic: Quiting applet ...
    basic: Registered modality listener
    liveconnect: Invoking JS method: document
    liveconnect: Invoking JS method: URL
    basic: Referencing classloader: sun.plugin.ClassLoaderInfo@181fbd6, refcount=5
    basic: Added progress listener: sun.plugin.util.GrayBoxPainter@1347dad
    basic: Loading applet ...
    basic: Initializing applet ...
    basic: Starting applet ...
    Does anyone know how to fix this new issue? Or does anyone know of a better way to solve the 'activate control' problem in IE that does not cause the reloading of this applet?
    Thanks.

    Hi!
    *1 -* Poor_Sitar_player's solution that i used.
    a - Build the applet's comented code into a div ...
    </div id='555>
    <!--
    <body>
    <applet name="EditoRTFa.class" id='editor' archive="../pages/expediente/Modelo/Editor/EditoRTFa.jar"
    code="br.gov.pa.tj.processo.expediente.casos.editor.EditoRTFa.class" width="750" height="550">
    </applet>
    <body>
    -->
    </div>
    b - After, insert a javascript the will remove the coments....
    <script type="text/javascript">
    var x = document.getElementById('555');
    var texto = x.innerHTML;
    texto = texto.replace('<!--','').replace('-->','');
    x.innerHTML = texto;
    <script type="text/javascript">
    *2 - Another solution*
    If you are using struts2 or your applet is inside a internal frame, is possible that the above solution will not work.
    So, the solution that i found was place the applet code in the main page, with width and heigh iguals "*0*" and style="float: left;" to hide the applet.
    This way, the applet will be load before you call the right page.
    That's all.
    Edited by: carlosmcp on Oct 14, 2008 7:01 AM

  • What mean applet load from file system.. till now i load by browser (is

    just i heard about applet load in two way
    1) from net (this is throw html )
    2) from local file system. (What is this )
    plszz

    from local file system. (What is this )When the html file and the applet is on your harddisk and you open the html file in a browser.

  • Start routine: only once per teh load but not once per data packet

    Hi,
    I would like to execute some code in start routine (in update rules) only once per the load but not once per the data packet.
    How can I implement this.
    Regards,

    I once had that same requirement, but in a datasource in R3. I'm not sure if the same solution would work in BW, though. I used a memory id to keep the variable value between packets:
    DATA: ... n_globalvar TYPE n ...
    then I added...
    IMPORT n_globalvar FROM MEMORY ID 'ZMEMID01'.
    ...at the start of the routine to retrieve to the variable the value from the memory id.
    At the end of the code, I exported the variable back to the same memory id...
    EXPORT n_globalvar to MEMORY ID 'ZMEMID01'.

  • ASObjC: Do Two Things at Once

    Hi, All.
    I've got an AppleScript Objective C program that I'd like to have do two things at once. For example, when a button is clicked, speak a sentence, and do some math (example below). The easiest thing would be to just give it two sent actions, the handlers that I want it to run, but nope, can't do that.
    I tried using one handler within another, but it still waits for the first to finish before moving on to the second, like this:
    on secondTask()
    set x to 1
    repeat 5
    set x to x + 1
    end repeat
    end secondTask
    on btnClicked_(sender)
    secondTask()
    say "Hello, you've just clicked a button. We're doing some math right now."
    end butnClicked_
    When I use this, the tasks get done, but one at a time.
    Is there any way to get it to do two things in parallel?
    Thanks!
    -Nate

    Hello
    If I understand it correctly, something like the following snippet would work :
    --SNIPPET
    (* not tested *)
    tell current application's class "NSSpeechSynthesizer"
    set synth to its alloc()'s initWithVoice_(missing value) -- default voice
    end tell
    synth's startSpeakingString_("Humpty Dumpty sat on a wall,
    Humpty Dumpty had a great fall.
    All the king's horses and all the king's men
    Couldn't put Humpty together again.")
    tell current application to display dialog "Now speaking..." buttons {"Stop"}
    --if synth's isSpeaking() then synth's stopSpeaking()
    synth's stopSpeaking()
    synth's release()
    --END OF SNIPPET
    And if the above works, actual script in ASObjC would look something like this :
    --SCRIPT (outline)
    (* not tested *)
    property NSSpeechSynthesizer : class "NSSpeechSynthesizer"
    script myAppDelegate
    property parent : class "NSObject"
    property myButton : missing value
    property synth : {}
    on buttonClicked_(sender)
    synth's startSpeakingString_("Hello")
    end buttonClicked_
    on awakeFromNib()
    set synth to NSSpeechSynthesizer's alloc()'s initWithVoice_(missing value) -- default voice
    end awakeFromNib
    on applicationWillFinishLaunching_(aNotification)
    end applicationWillFinishLaunching_
    on applicationShouldTerminate_(sender)
    --synth's stopSpeaking() -- not sure this is necessary
    synth's release()
    return current application's NSTerminateNow
    end applicationShouldTerminate_
    end script
    --END OF SCRIPT
    *When you alloc() something, make sure you release() it.
    Regards,
    H

  • Applet loading in IE vs Firefox

    Hello!
    I have a peculiar problem. I have several web pages containing lots of applets which via static methods register to a "master" applet which in turn collects information from a remote source and then updates the registered applets periodically.
    Well this works fine, however the load times in IE are outrageous, it can take up to 2 minutes or so before a page with approxiamtely 20 applets is fully loaded. Whilst the same page takes about 2 seconds in firefox. I should also mention that when the page has been loaded in IE it works just as well as it does in firefox. The only problem is that it takes all to long for the page to load.
    What could be the explanation of this? What is the fundamental difference in IE compared to firefox when applets are loaded?
    Does anyone have some sort of clue about this one?
    /HG

    cell@tech wrote:
    When I navigate to the site in IE and click on the link the applet loads, but when I navigate to the site in FireFox3 it displays the html code. My FireFox browser runs applets just fine on other sites, so is there something else I need to put in the html code for FF3?Works fine with FF2.
    Try to add a BODY to your HTML.
    <html>
    <body>
    <applet height="600" width="600" code="com.program.startup.Starter.class">
    <param name=archive value=http://www.wheeling22.adventistchurchconnect.org/site/1/directory/WheelingWebSite.jar /> Your browser does not support the <code>applet</code> tag. </applet>
    </body>
    </html>Bye.
    RG.

Maybe you are looking for

  • Opening Document in Work from the Sent To Email a Link instead on downloading it

    Documents send via the Sent To > Email a Link SharePoint 2010 Document Library Menu is downloading rather than opening in Word. This is happening for some users and while it is open in Word just fine for other users. New to SharePoint

  • Match Bill Of Lading With invoice for payment

    HI All, In my current project, client is using 3PL (third party logistics) for transportation of goods from one plant to another plant. We are creating Bill of Lading but not using Transportation component of LE. Client has a requirement to use the b

  • Aktualisierung der Windows Phone App

    Ich würde mich sehr freuen wenn die App von der WD My Cloud auf der Windows Phone Oberfläche mal eine Aktualisierung bekommt. Letztes Update war Ende 2013. Mit einem Android Smartphone war es ein Genuss mit der Netzwerkplatte zu arbeiten. Nun besitze

  • Excel spreadsheet prints incorrectly--lacks grids, some colors--Pixma MX922

    I can't print an Excel Spreadsheet correctly to my Canon Pixma MX922. It comes out lacking borders and lacking some of the colors, even though in print preview it looks perfect. I am using Microsoft Excel 2013 and Windows 7. I just reinstalled the pr

  • Why does the keyboard hide my iMessages?

    My new 6+ and ios8 is making it impossible for me to see the recent imessages.  I have to exit the app and come back so the keyboard goes away.  I can 'drag' them up, but I cannot get to the bottom. Any help appreciated. Thanks