Results 1 to 4 of 4
  1. #1
    mchappell is offline Member
    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    Default Problem with an applet starting another applet

    Hi -

    Background - We use an Oracle development tool. Currently, it is not compatible with Java 7. It turns out that the problem lies in the value of 'java.vendor'. In 1.6, it was 'Sun', and in 1.7 it is 'Oracle'. The Oracle software that we use looks at this value to do some validation, and it doesn't like what it finds in 1.7 (go figure).

    So, I've implemented a bootstrap applet to set java.vendor to an acceptable value, and then start the 'real' applet. I've been mostly successful. Only problem that I'm having is that the first time the page loads, the 'real' applet is real tiny - it only consists of a title bar that contains the window control, minimize, maximize, and close buttons.

    If I close the 'real' applet and refresh the web page, the 'real' applet open up in the desired size.

    Here's the OBJECT tag:

    Java Code:
    <OBJECT onerror=fnNav() 
      classid=clsid:8AD9C840-044E-11D1-B3E9-00805F499D93 
      WIDTH=1400 HEIGHT=625> 
       <PARAM NAME=CODE          VALUE=QLoader> 
       <PARAM NAME=appletToLoad VALUE=oracle.forms.engine.Main> 
       <PARAM NAME=codebase      VALUE=http://vmwwfin05.abc.com> 
       <PARAM NAME=type          VALUE=application/x-java-applet> 
       <PARAM NAME=scriptable    VALUE=false> 
       <PARAM NAME=cache_option  VALUE=Plugin> 
       <PARAM NAME=cache_archive VALUE=/forms/java/Bootstrap.jar,/forms/java/frmall.jar,/forms/java/fnicons.jar,/forms/java/webutil.jar,/forms/java/jacob.jar> 
       <PARAM NAME=cache_version VALUE=1.0.0.0,10.1.2.3,6.0.8.24,2.2.0.0,1.2.0.1> 
       <PARAM NAME="serverURL"     VALUE="/forms/lservlet?ifcfs=http://vmwwfin05.abc.com/forms/frmservlet" 
       <PARAM NAME=networkRetries VALUE=30> 
       <PARAM NAME=networkStats  VALUE=true> 
       <PARAM NAME="lookAndFeel"	 VALUE="Oracle"> 
       <PARAM NAME="colorScheme"	 VALUE="teal"> 
       <PARAM NAME=splashScreen  VALUE=NO> 
       <PARAM NAME=logo          VALUE=NO> 
       <PARAM NAME=background    VALUE=NO> 
       <PARAM NAME=separateFrame VALUE=true> 
     Java Runtime Environment not installed. 
     </OBJECT>
    And the bootstrap code:

    Java Code:
    import java.applet.Applet;
    import java.applet.AppletStub;
    import java.awt.*;
    
    public class QLoader extends Applet 
        implements Runnable, AppletStub {
      String appletToLoad;
      Thread appletThread;
    
      public void init() {
        appletToLoad = getParameter("appletToLoad");
        setBackground(Color.white);
        }
    
      public void paint(Graphics g) {
        g.drawString("Loading the BIG ONE ...", 30, 30);
        } 
    
      public void run() {
        try {
          System.setProperty("java.vendor", "Sun Microsystems Inc.") ; 
          Class appletClass = Class.forName(appletToLoad);
          Applet realApplet = (Applet)appletClass.newInstance();
          realApplet.setStub(this);
          setLayout( new GridLayout(1,0));
          add(realApplet);
          realApplet.init();
          realApplet.start();
          }
        catch (Exception e) {
          System.out.println( e );
          }
        /*validate();*/
        }
    
      public void start(){
        appletThread = new Thread(this);
        appletThread.start();
        }
    
      public void stop() {
        appletThread.stop();
        appletThread = null;
        }
    
      public void appletResize( int width, int height ){
        resize( width, height );
        }
    
    }
    (Same results with/without 'validate')

    Any idea why the height/width are ignored on the initial load of the page?

    Thanks,

    Mark
    Last edited by mchappell; 01-16-2013 at 12:27 AM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

    Default Re: Problem with an applet starting another applet

    I see no need to set the layout to GridLayout(1, 0). The default BorderLayout should be just fine. Either way, after adding content to an already visible GUI you need to call revalidate(). It is sometimes necessary to also call repaint(), and it does no harm to include it anyways.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    mchappell is offline Member
    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    Default Re: Problem with an applet starting another applet

    The revalidate() and repaint() calls, added after the 'add' call, seemed to do the trick.

    Thanks for pointing me in the right direction!

    Mark

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

    Default Re: Problem with an applet starting another applet

    Yeah, variations on this problem crop up in all the forums so often. I wish the Oracle folk would give this a prominent mention somewhere in the Swing tutorial trail.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 30
    Last Post: 08-26-2011, 10:05 PM
  2. applet working in applet viewer, not browser
    By plasticfood in forum Java Applets
    Replies: 4
    Last Post: 06-24-2011, 07:47 PM
  3. Replies: 6
    Last Post: 04-01-2009, 12:09 PM
  4. starting a Swing application from an applet
    By FakeRabbit in forum Java Applets
    Replies: 9
    Last Post: 09-21-2008, 08:00 PM
  5. Replies: 4
    Last Post: 06-08-2007, 07:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •