Adding gravity into a Java applet

Hey guys,
I have an array of 10,000 dots (ovals) on my screen, and I am trying to make a simple physics simulator, that simulates gravity between these dots. I would like them to interact.
I'm not really sure where to start, Im not sure if there is a Java method that does this, but anyhow, can someone please explain to me how i would go about doing somthing like this.
Thanks in advance!
Andrew

sabre150 wrote:
masijade. wrote:
Futurisdom_Developer wrote:
Have a thread in an infinite loop that loops through each dot.
Everytime it checks a dot, it adds x amount of speed to the object (obviously down, seeing as gravity is pulling it down).
Hope this helps.Except that he wants gravity between the dots (i.e. as in between the Sun and the Earth).and 10,000 masses require each of the 10,000 to compute the interaction with the other 9,999 so there are about 100,000,000 calculations per iteration.I guess I should have further refined the quote, as I was taking note of "down" part. ;-)
Edit: And the "down" makes it sound as though he is talking only about adding in one direction, rather than adding in the direction from which the next dot is coming, and simply adding one does not, of course, take proximity, or mass into account, which it would need to.

Similar Messages

  • Adding a KeyListener to java applet

    I'm going to post this again, because I didn't really understand the last answer.. I know how to add KeyListeners to textfields and buttons, etc, but how do I add it to the applet itself.. I want to do this because I have a painted box on the screen and I want it to move its position everytime I hit the up key.. But I can't add the keylistener to anything but textfields and stuff. I dont know how to do it. Can u please help.. Someone told me JApplet.addKeyListener(this); but I tried it and it didn't work.. It gave me an error cannot find symbol JApplet, I dont have a variable for my whole applet, and I'm not sure how to create one either. Can anyone help?

    I'm going to post this again, because I didn't really
    understand the last answer.. That's no excuse for cross posting.
    http://forum.java.sun.com/thread.jspa?threadID=5215206

  • Call other html page on using a java applet!!

    Can I call other html page using a function into a java Applet? Please, somebody reply!!!

    How can i do? Explain!! Thanks...

  • Passing Variables From PHP to Java Applet ?

    I took one page of a project which was written entirely in PHP, and translated it into a JAVA applet, so as to support better GUI funcitonalities (immediate calculation and display of Time/Billing data, on LostFocus events...stuff like this).
    In any case - I need to pass four variables from the php scripts, to the Java Applet. I had initially, written them out from the php scripts to an html file on the server, and read them in from the applet doing something like this:
    .     this.m_TheURL = new URL(url);
         InputStream in = m_TheURL.openStream();
         DataInputStream data = new DataInputStream(new BufferedInputStream(in));
         while ((unparsed = data.readLine()) != null)
    // parsed the strings here and got my variables
    The URL I read from, was the same file I wrote out to from the PHP scripts. This worked fine - until I told my boss about it, and realised that this wasnt going to work - because the applet updates a MySql database, and issues regarding multiple users became apparent.
    The Applet has to get these variables from the previous PHP page, the same way it had - before my applet was an applet, and it was just another PHP script page.
    The PHP pages are passing variabes using CGI, and a PostGet function. My applet has to do the same thing.
    Anybody know how I can do this - safely ?

    Updated some code... in case people wanted to use it....
    <?php
    class JavaApplet {
         var $param;
         function setParam($name, $value) {
              $temp1 =  array("name" => $name, "value" => $value);
              $this->param = array_merge($this->param, $temp1);
         function delParam($name) {
             foreach ($this->param as $key => $value) {
                  if ($key = $name) {
                       unset( $this->param["$id"]);
         function echo_html() {
              echo '<applet code=TimeEntry.class width=600 height=90 >';
              foreach ($this->param as $value) {
                   foreach ($value as $key => $value2) {
                        echo '<param name="' . $key . '" value="' . $value2 . '">';
              echo '</applet>';
    $applet = &New JavaApplet;
    $applet->setParam("name1", "value");
    $applet->setParam("name2", "value");
    $applet->setParam("name3", "value");
    $applet->echo_html();
    ?>

  • Java applets in a browser, and Serial port input

    I know that there is a special package for serial port input in java. (java.Comm.SerialPort)
    What I am trying to figure out before a final decision on design is made, is if there is anyway of reading serial port input into a java applet that is running inside of a browser.
    I have found lots of reference to Serial port input, but nothing that really goes in the direction that I am lookind for.
    Any little tid bits of information pertaining to this would be greatly appreciated.
    Cuervo

    You should also consider that applets are not allowed to access their client system's hardware without being signed; in other words, the user must agree (by clicking a button) to disable the applet security features. Why would you use an applet to do this? Applets are meant to be an extension of a website. You should use an application in this situation.

  • Copy and Paste into Java Applet

    I know there have been some posts like this in the paste, but could not find a reasonable explanation.
    JVM 1.4.2_08
    For an unsigned java applet (Swing) I could not copy from a notepad document into my applets JTextField and JTextArea fields.
    JVM 1.5
    For this same applet (Swing) running under 1.5, I could copy and paste from the notepad document into my applets JTextField and JTextArea fields.
    Does anybody know why the difference?
    Is there a way to copy and paste for applets running in the 1.4.2 jvm?
    Thanks.

    I think it must be some security restriction.
    Set a policy for the applet or sign it:
    Set a policy (windows):
    C:\Program Files\Java\j2re****\lib\security\java.policy
    under grant {
         permission java.security.AllPermission;
    this means that you give all permission to all code, if you only want to give permissions for applets
    comming from google you can add the following:
    grant codeBase "http://google.com/-" {
         permission java.security.AllPermission;
    to sign
    http://forum.java.sun.com/thread.jsp?forum=63&thread=524815
    second post

  • Preventing "Paste" into java applets

    First of all, I am sorry that I was not able to search these forums. I searched but the "Sun Search" did not seem to allow a specific forum search and threw more than a page of non-forum hits.
    I would like to know whether it is possible to prevent paste (as in copy and paste) into the text field of a java applet as run on a browser as part of an online application.
    I know that there are javascript applications for preventing "right click" the use of the control keys and also (the best or most annoying in my experience) flushing the system clipboard.
    However, all these measures can be circumvented and I thin that the Opera browser in is good at circumventing them.
    When it comes to a java applet however, without interferting with the system, I would have thought it would be possible to control
    1) Connections to the system clipboard
    2) Which keys can be used to enter into a text field.
    So I would have though that preventing paste into a java text field would be possible.
    But today I was asked "Do you understand computers"? And made a fool of when I suggested that such a thing may be possible, by a Java programmer. I am surprised.
    Is it possible to prevent paste (ctrl v, or using the mouse) into a java text field?
    Tim

    cleaner way to do it (cleaner meaning not so many inner classes!) is to just add a key adapter to whatever text component you want (textfields, textareas, anything that takes KeyListener)
    example..
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class NoPaste extends KeyAdapter {
         public void keyPressed(KeyEvent e) {
              if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_V) {
                   e.consume();
    public class Test extends JFrame {
         public Test() {
              super("Test");
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              addKeyListener(new NoPaste());
              JTextField jf = new JTextField(20);
              Container c = getContentPane();
              c.setLayout(new FlowLayout(FlowLayout.CENTER));
              c.add(new JLabel("Paste: "));
              c.add(new JTextField(20));
              c.add(new JLabel("No Paste: "));
              c.add(jf);
              jf.addKeyListener(new NoPaste());
              pack();
              show();
         public static void main(String[] args) {
              new Test();
    }by calling addKeyListener(new NoPaste()); with each component you want, you can disable the ctrl+v key function. the negative side is that a context menu (or any other 3rd party component) could still call paste(), but then again they could call setText anyway, so its not much difference. not to mention Swing does not feature context menus by default..

  • How to add images into a java application (not applet)

    Hello,
    I am new in java programming. I would like to know how to add images into a java application (not an applet). If i could get an standard example about how to add a image to a java application, I would apreciated it. Any help will be greatly apreciated.
    Thank you,
    Oscar

    Your' better off looking in the java 2d forum.
    package images;
    import java.awt.*;
    import java.awt.image.*;
    import java.io.FileInputStream;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    /** * LogoImage is a class that is used to load images into the program */
    public class LogoImage extends JPanel {
         private BufferedImage image;
         private int factor = 1; /** Creates a new instance of ImagePanel */
         public LogoImage() {
              this(new Dimension(600, 50));
         public LogoImage(Dimension sz) {
              //setBackground(Color.green);      
              setPreferredSize(sz);
         public void setImage(BufferedImage im) {
              image = im;
              if (im != null) {
                   setPreferredSize(
                        new Dimension(image.getWidth(), image.getHeight()));
              } else {
                   setPreferredSize(new Dimension(200, 200));
         public void setImageSizeFactor(int factor) {
              this.factor = factor;
         public void paintComponent(Graphics g) {
              super.paintComponent(g);
              //paint background 
              Graphics2D g2D = (Graphics2D) g;
              //Draw image at its natural size first. 
              if (image != null) {
                   g2D.drawImage(image, null, 0, 0);
         public static LogoImage createImage(String filename) { /* Stream the logo gif file into an image object */
              LogoImage logoImage = new LogoImage();
              BufferedImage image;
              try {
                   FileInputStream fileInput =
                        new FileInputStream("images/" + filename);
                   image = ImageIO.read(fileInput);
                   logoImage =
                        new LogoImage(
                             new Dimension(image.getWidth(), image.getHeight()));
                   fileInput.close();
                   logoImage.setImage(image);
              } catch (Exception e) {
                   System.err.println(e);
              return logoImage;
         public static void main(String[] args) {
              JFrame jf = new JFrame("testImage");
              Container cp = jf.getContentPane();
              cp.add(LogoImage.createImage("logo.gif"), BorderLayout.CENTER);
              jf.setVisible(true);
              jf.pack();
    }Now you can use this class anywhere in your pgram to add a JPanel

  • 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.

  • 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

  • Adding an image in a java applet

    Hey everyone... I am using Jbuilder and trying to add an image or background image in my applet. The image is in the folder the java file runs out of. I would really appreciate it if anyone could help me..

    I use this to add an image that I have saved in the applet folder
    Image image;
    public void init() {
    image = getImage(getDocumentBase(), "auburn.jpg");
    and I get this error when I try to run it in Jbuilder:
    java.lang.NullPointerException
         at java.applet.Applet.getDocumentBase(Applet.java:125)
         at JavaProject.<init>(JavaProject.java:103)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
         at java.lang.Class.newInstance0(Class.java:308)
         at java.lang.Class.newInstance(Class.java:261)
         at sun.applet.AppletPanel.createApplet(AppletPanel.java:617)
         at sun.applet.AppletPanel.runLoader(AppletPanel.java:546)
         at sun.applet.AppletPanel.run(AppletPanel.java:298)
         at java.lang.Thread.run(Thread.java:534)
    What could be the problem?

  • Adding a java applet in Apex page

    Hello, I am trying to add a java applet to my page. This is what I do. I create an html region with source ;
    <applet width=300 height=300 codebase="#WORKSPACE_IMAGES#DrawingLines.class"></applet>
    and I upload DrawingLines.class file as a static file.
    When I run the page I see the java cup sign (with running circle around) but not the applet. Does this have to do anything with the browser security? My knowledge of Java is very limited, but I thought this should work.
    George

    I just feel like I have to answer this and I hope this is the last post in this thread.
    "I find it amusing that you have come to this forum demanding free technical support, and have posted over 200 times, but you yourself have never once answered somebody's question and gotten a helpful or correct reward"
    First of all, I have helped people on a few occasions , I don't know what kind of "helpful or correct reward" you are referring to but yes I have given useful answers and gotten "thank you" from a few members.
    Second, most of my posts are from year or more ago when I was learning Apex, I have very few posts in the last 6-12 months.
    Third, if nobody asks the questions then there will be no answers => there will be no forum. The very existence of this forum is based on people asking question so why should I be ashamed to "demand free technical hellp", isn't this what most people are doing here?
    The rest of your post is just words pretty much not saying anything (you might wanna try a carier in the politics) so I am not going to address it.
    Have a wonderful day.

  • Some Java applets do not work after silent installation, solved by toggling "Enable Java content in the browser" - Why?

    We have about 1,800 workstations running Windows 7 (both 32-bit and 64-bit) running various versions of the Java JRE from 6 update 32 through 7 update 51.  Most are on 6 update 45.  We would like to standardize on Java 7 update 51 (32-bit) and get everyone updated to that version for security reasons.
    For the past two weeks, we have been having trouble with our installation pre-pilot.  What we are seeing is that our procedure successfully closes any open Internet Explorer windows and Java-related processes, uninstalls all old versions of the Java JRE, and then claims to have successfully installed Java 7 update 51.  The Java Control panel works.  We can even take Internet Explorer to Verify Java Version or Java Tester - What Version of Java Are You Running? and confirm that the Java applets on those sites are loading (though the latter only works after adding the site to the exceptions site list); however, when testers try to access our Kronos Workforce Central 6.3.10 system, the Java applets used by that system do not load.
    We have tried the following things, none of which worked:
    Clear Internet Explorer browser cache and cookies.
    Clear the local Java cache.
    Reboot the computer.
    Reset Internet Explorer settings, including personal settings.
    The one thing which does work is going into the Java Control Panel, going to the Security tab, unchecking "Enable Java content in the browser", pressing Apply, pressing OK on the pop-up window, checking the "Enable Java content in the browser" box again, pressing OK, pressing OK on the pop-up window, and then restarting Internet Explorer.  It is only after this point that all Java applets, including the ones used by Kronos Workforce Central 6.3.10, work.
    What I need to know is how I can automate the procedure of reinitializing the "Enable Java content in the browser" checkbox after installation or am I doing something wrong or missing a step in the automated installation that is causing this to happen?
    We are using Microsoft SCCM 2007 R3 to accomplish this upgrade, and everything is being run on the client machine using the SYSTEM account.  First, the PowerShell script "javaclean.ps1" is run, with part of the command-line process changing the PowerShell script execution policy to Bypass.  This script handles the closing of Java-dependent applications and Java processes and uninstalls old Java versions.
    javaclean.ps1:
    #Find all Java products excluding the auto updater which actually gets uninstalled when the main install is removed.
    write-host "Searching for all installed Java versions" -ForegroundColor Yellow
    [array]$javas=Get-WmiObject -query "select * from win32_Product where (Name like 'Java %' or Name like 'Java(TM)%' or Name like 'J2SE%') and Name <> 'Java Auto Updater'"
    if ($javas.count -gt 0)
        write-host "Java is already Installed" -ForegroundColor Yellow
        #Get all the Java processes and kill them. If java is running and the processes aren't killed then this script will invoke a sudden reboot.
        [array]$processes=Get-Process -Name "Java*" #-erroraction silentlycontinue
        $processes += Get-Process -Name "iexplore" #-erroraction silentlycontinue
        $processes += Get-Process -Name "firefox" #-erroraction silentlycontinue
        $processes += Get-Process -Name "chrome" #-erroraction silentlycontinue
        $processes += Get-Process -Name "jqs" #-erroraction silentlycontinue
        $processes += Get-Process -Name "jusched" #-erroraction silentlycontinue
        $processes += Get-Process -Name "jp2launcher" #-erroraction silentlycontinue
        if ($processes.Count -gt 0)
            foreach ($myprocess in $processes)
                $myprocess.kill()
        #Loop through the installed Java products.
        foreach($java in $javas){
            write-host "Uninstalling "$java.name -ForegroundColor Yellow
            $java.Uninstall()
    After this script is complete, SCCM calls a the VBS script "install.vbs" to perform the actual installation of Java JRE 7 update 51.
    install.vbs
    '* Script: Install JRE 7 routine
    '* Date:   3/14/14
    '* Author: [REDACTED]
    '* Rev:    1.0
    '* Notes: 
    '/// Common
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objWshShell = CreateObject("WScript.Shell")
    ' Get system architecture
    Dim colSys : Set colSys = GetObject("WinMGMTS://").ExecQuery("SELECT AddressWidth FROM Win32_Processor",, 48)
    Dim objSys
    For Each objSys In colSys
        If objSys.AddressWidth = 64 Then bolIs64Bit = True
    Next
    ' Get operating system
    Dim colOS : Set colOS = GetObject("WinMGMTS://").ExecQuery ("Select * from Win32_OperatingSystem",,48)
    Dim objOS
    For Each objOS In colOS
        If Left(objOS.caption, 20) = "Microsoft Windows 8 " Then
            bolIsWin8 = True
            WScript.Echo "win8"
        End If
        If Left(objOS.caption, 22) = "Microsoft Windows 8.1 " Then
            bolIsWin81 = True
            WScript.Echo "win81"
        End    If
    Next
    ' Set 32 bit program files directory
    If bolIs64Bit = True Then
        strPFILES = "Program Files (x86)"
        strSYSDIR = "SysWOW64"
        Else strPFILES = "Program Files"
        strSYSDIR = "System32"
    End If       
    ' Set windows directory
    strWIN = objWshShell.ExpandEnvironmentStrings("%windir%")
    ' Set the current directory
    strCurrentDir = objFSO.GetParentFolderName(Wscript.ScriptFullName)
    ' Set computer name
    strCompName = objWshShell.ExpandEnvironmentStrings("%computername%")
    '/// Main script
        '/// Install via .msi & capture exit code
        'intExitCode = objWshShell.Run("msiexec.exe /i """ & strCurrentDir & "\package.msi""" & " TRANSFORMS=""" & strCurrentDir & _
        '    "\transform.mst"" ALLUSERS=1 Reboot=ReallySuppress /qn", 8, True)
        'wscript.quit(intExitCode)
        '****RUN COMMANDS HERE****
        ' Create folder structure if it doesn't exist already   
        strFullPath = "c:\Windows\Sun\Java\Deployment" '
        ' How many levels are there in the path?
        nLevel = 0
        strParentPath = strFullPath
        Do Until strParentPath = ""
            strParentPath = objFSO.GetParentFolderName(strParentPath)
            nLevel = nLevel + 1
        Loop
        For iLevel = 1 To nLevel
            ' Figure out path for directory at level iLevel
            strParentPath = strFullPath
            For j = 1 To nLevel - iLevel
                strParentPath = objFSO.GetParentFolderName(strParentPath)
              Next
        ' Does this directory exist? If not, create it.
            If objFSO.FolderExists(strParentPath) = False Then
                Set newFolder = objFSO.CreateFolder(strParentPath)
            End If
        Next
        ' Kill running processes
        objWshShell.Run "taskkill /F /IM iexplore.exe", 8, True
        objWshShell.Run "taskkill /F /IM firefox.exe", 8, True
        objWshShell.Run "taskkill /F /IM chrome.exe", 8, True
        objWshShell.Run "taskkill /F /IM javaw.exe", 8, True
        objWshShell.Run "taskkill /F /IM java.exe", 8, True
        objWshShell.Run "taskkill /F /IM jqs.exe", 8, True
        objWshShell.Run "taskkill /F /IM jusched.exe", 8, True
        ' Copy deployment files
        objFSO.CopyFile strCurrentDir & "\deployment.config", "c:\Windows\Sun\Java\Deployment\", True
        objFSO.CopyFile strCurrentDir & "\deployment.properties", "c:\Windows\Sun\Java\Deployment\", True
        ' Disable UAC
    '    If bolIsWin8 Or bolIsWin81 = True Then
    '        objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v PromptOnSecureDesktop /t REG_DWORD /d 0 /f", 8, True
    '        objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f", 8, True
    '        objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /f", 8, True
    '    End If
        ' Install application
        intExitCode = objWshShell.Run("msiexec.exe /i """ & strCurrentDir & "\jre1.7.0_51.msi"" IEXPLORER=1 AUTOUPDATECHECK=0 JAVAUPDATE=0 JU=0 WEB_JAVA=1 ALLUSERS=1 Reboot=ReallySuppress /qn", 8, True)
        ' Enable UAC
    '    If bolIsWin8 Or bolIsWin81 = True Then
    '        objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v PromptOnSecureDesktop /t REG_DWORD /d 1 /f", 8, True
    '        objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 1 /f", 8, True
    '        objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 5 /f", 8, True
    '    End If   
        wscript.quit(intExitCode)
        '/// Install via .exe on network
        'objWshShell.Run """" & strCurrentDir & "\Setup.exe"" -s -sms -f1""" & strCurrentDir & _
        '    "\setup.iss"" -f2""" & strWIN & "\Temp\Install-app.txt""", 8, True
        ' Need to turn off the open file security warning first
        Set objEnv = objWshShell.Environment("PROCESS")
        objEnv("SEE_MASK_NOZONECHECKS") = 1
    '    intExitCode = objWshShell.Run("""" & strCurrentDir & "\jre-7u45-windows-i586.exe"" /s /v""/norestart " & _
    '        "TRANSFORMS=""" & strCurrentDir & "\Tribe-jre7.mst""""", 8, True)
    '    WScript.Quit(intExitCode)
        '****RUN COMMANDS HERE****
        ' Then turn it back on
        objEnv.Remove("SEE_MASK_NOZONECHECKS")
    '/// Additional functions
    Help on this issue would be much appreciated!

    It turns out that this is actually a problem with Kronos Workforce Central.  We had the "site.java.plugin.CLSID.familyVersion" setting in that application set to "clsid:CAFEEFAC-0016-0000-FFFF-ABCDEFFEDCBA", which is the Java CLSID for Java 6.  After updating this value to "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" (the Java universal CLSID), this problem did not occur upon the automatic upgrade of Java.
    We have both Java 6 and Java 7 in our environment, and did during our Kronos implementation, so I don't know why we were using the Java 6 CLSID in the first place.
    Case closed!

  • Java Applet IIOP Call-In with Release 3C--How do we speed updownload ti

    We have successfully implemented a simple Java Applet that calls into
    Forte Services via IIOP. However, the duration of the download time for
    Applet and its required class files is UNACCEPTABLE in a typical
    INTERNET environment where 28.8K modems and multiple hops around the net
    are not uncommon. We dialed into our network at 28.8K (but no hopping),
    and found that download times varied from 1.5 - 2.0 minutes. This is
    unacceptable, even by internet standards. We have been using the
    Visigenic Visibroker product as the ORB.
    After doing some investigation, we've come up with several ideas to
    speed up download time:
    1. Figure out how to use the Visigenic components (CORBA/IIOP class
    files) that come bundled with the latest version of the Netscape
    Navigator browser, so that they don't have to be downloaded
    2. Figure out how to use ZIP files. Here's what I've read: "Since the
    introduction of Netscape Navigator 3.0, you can specify an uncompressed
    .zip file as an addition to the code base of your application. By
    specifying a ZIP file, the browser will load your applet's classes from
    a specified ZIP file before it searches the code base. This ZIP can
    improve applet download time by reducing the number of HTTP connections
    required to fetch applet code. As an added benefit, Netscape caches the
    single ZIP file so that it will not reload your applet unless the date
    of the ZIP file has changed."
    3. Figure out how to use JAR files. Here's what I've read: "JAR
    stands for Java archive. It's a file format based on the popular ZIP
    file format and is used for aggregating many files into one. Although
    JAR can be used as a general archiving tool, the primary motivation for
    its development was so that Java applets and their requisite components
    can be downloaded to a browser in a single HTTP transaction, rather than
    opening a new connection for each piece. This greatly improves the
    speed with which an applet can be loaded onto a web page and begin
    functioning. The JAR format also supports compression, which reduces the
    size of the file and improves download time still further."
    Unfortunately, we've been unable to get any of these approaches to work.
    Has any one used these or other approaches to speed up applet download
    time? Or, does anyone know of consulting firms that specialize in this
    sort of thing?
    Thanks in advance for your help.
    Mike Nelson, Project Leader
    Metrix, Inc.
    [email protected]
    414-798-8560 x1157

    We have successfully implemented a simple Java Applet that calls into
    Forte Services via IIOP. However, the duration of the download time for
    Applet and its required class files is UNACCEPTABLE in a typical
    INTERNET environment where 28.8K modems and multiple hops around the net
    are not uncommon. We dialed into our network at 28.8K (but no hopping),
    and found that download times varied from 1.5 - 2.0 minutes. This is
    unacceptable, even by internet standards. We have been using the
    Visigenic Visibroker product as the ORB.
    After doing some investigation, we've come up with several ideas to
    speed up download time:
    1. Figure out how to use the Visigenic components (CORBA/IIOP class
    files) that come bundled with the latest version of the Netscape
    Navigator browser, so that they don't have to be downloaded
    2. Figure out how to use ZIP files. Here's what I've read: "Since the
    introduction of Netscape Navigator 3.0, you can specify an uncompressed
    .zip file as an addition to the code base of your application. By
    specifying a ZIP file, the browser will load your applet's classes from
    a specified ZIP file before it searches the code base. This ZIP can
    improve applet download time by reducing the number of HTTP connections
    required to fetch applet code. As an added benefit, Netscape caches the
    single ZIP file so that it will not reload your applet unless the date
    of the ZIP file has changed."
    3. Figure out how to use JAR files. Here's what I've read: "JAR
    stands for Java archive. It's a file format based on the popular ZIP
    file format and is used for aggregating many files into one. Although
    JAR can be used as a general archiving tool, the primary motivation for
    its development was so that Java applets and their requisite components
    can be downloaded to a browser in a single HTTP transaction, rather than
    opening a new connection for each piece. This greatly improves the
    speed with which an applet can be loaded onto a web page and begin
    functioning. The JAR format also supports compression, which reduces the
    size of the file and improves download time still further."
    Unfortunately, we've been unable to get any of these approaches to work.
    Has any one used these or other approaches to speed up applet download
    time? Or, does anyone know of consulting firms that specialize in this
    sort of thing?
    Thanks in advance for your help.
    Mike Nelson, Project Leader
    Metrix, Inc.
    [email protected]
    414-798-8560 x1157

  • Java Applet Won't Initialize

    This is a modified version of a tutorial I've been working with. Code for Main.java:
    import javax.swing.*;
    public class Main {       
    * @param args the command line arguments
    public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    JFrame f = new JFrame("Swing Paint Demo");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(300,300);
    f.setVisible(true);
    Problem is that when I try to load the applet into an html file:
    <html>
    <APPLET code="Main.class"></APPLET>
    </html>
    It doesn't load.
    The file compiles and executes as a stand alone .jar, but when I try to run it as an applet it won't work.
    I know I'm probably missing an easy step. I have already checked my IE7 settings and java is enabled. I have no problem with any other java applets, just the ones I make. haha. Thank you ahead of time.

    I did some research, and got a new tutorial because the old one was inappropriate like you pointed out previously. This one I copy pasted into my editor, it compiled fine. I run it through my browser and it doesn't work still. Same issue, coincidentally, what do you make of it?import javax.swing.JApplet;
    import javax.swing.JTextField;
    import javax.swing.SwingUtilities;
    //Since we're adding a Swing component, we now need to
    //extend JApplet. We need to be careful to access
    //components only on the event-dispatching thread.
    public class Main extends JApplet {
        JTextField field;
        public void init() {
            //Execute a job on the event-dispatching thread:
            //creating this applet's GUI.
            try {
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        createGUI();
            } catch (Exception e) {
                System.err.println("createGUI didn't successfully complete");
            addItem(false, "initializing... ");
        private void createGUI() {       
            //Create the text field and make it uneditable.
            field = new JTextField();
            field.setEditable(false);
            //Set the layout manager so that the text field will be
            //as wide as possible.
            setLayout(new java.awt.GridLayout(1,0));
            //Add the text field to the applet.
            add(field);
        public void start() {
            addItem(false, "starting... ");
        public void stop() {
            addItem(false, "stopping... ");
        public void destroy() {
            addItem(false, "preparing for unloading...");
            cleanUp();
        private void cleanUp() {
            //Execute a job on the event-dispatching thread:
            //taking the text field out of this applet.
            try {
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        remove(field);
            } catch (Exception e) {
                System.err.println("cleanUp didn't successfully complete");
            field = null;
        private void addItem(boolean alreadyInEDT, String newWord) {
            if (alreadyInEDT) {
                addItem(newWord);
            } else {
                final String word = newWord;
                //Execute a job on the event-dispatching thread:
                //invoking addItem(newWord).
                try {
                    SwingUtilities.invokeAndWait(new Runnable() {
                        public void run() {
                            addItem(word);
                } catch (Exception e) {
                    System.err.println("addItem didn't successfully complete");
        //Invoke this method ONLY from the event-dispatching thread.
        private void addItem(String newWord) {
            String t = field.getText();
            System.out.println(newWord);
            field.setText(t + newWord);
    }

Maybe you are looking for

  • Problem in reports

    Hi experts, What i want is i want i shall give a input to one form and a corrosponding report will be generated using oracle report.But when i am sending the data to the report via parameter but i can not able to see any thing. I ahve defined the par

  • Exception related code

    Hi. When i try to compile following code it gives compile time errror: import java.io.*; class Parent{ public void method1() throws IOException, ArrayIndexOutOfBoundsException{      System.out.println(" HI this is parent class method"); class Child e

  • Unable to view full page , only in full screen i am able to view it

    unable to view full screen , getting only 1/2 or 1/4 view of the page . but able to see full in full screen

  • Move movie on ipad to pc

    I want to download movie from IPAD to PC

  • Zen Xtra 60 gig problem, help requi

    hello i have a nomad juxebox zen xtra 60 gig, and it has worked fine for several months. recently, i had a problem that when i was listening to a track, parts of other tracks would interrupt the song, before switching back to the original song. this