So how do I include a web page - Java

Discussion in 'Programming' started by wvccboy, Sep 17, 2007.

  1. #1
    I'm a newbie to Java really, so I'm asking a newbie question :p

    How do I load a web page inside a Java applet?

    I just want to be able to print a page, and have the simple GUI as usual.

    I can make the GUI and all; only problem is I don't have a function to display a URL of my choice.

    Any snippets would be great.

    Thanks
     
    wvccboy, Sep 17, 2007 IP
  2. firmaterra

    firmaterra Peon

    Messages:
    756
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hmm, you mean load an applet into a webpage??


    or you at something far more fancy? :D

    If its the former and presuming you have the applet written:

    <applet code=yourfilename width=200 height=200></applet>


    If its the latter try looking up
    applet.getAppletContext().showDocument (URL)

    ...only thing is pop up blockers may kill it if thats the route you are taking.

    Your code will look something like:
    applet.getAppletContext().showDocument(new URL(yourUrl!!);
    If your URL is a local file (such as D:/myTextFile.txt) you may find yourself messing around with slashes depending on the browser visiting.

    Hope this helps.
     
    firmaterra, Sep 18, 2007 IP
    wvccboy likes this.
  3. wvccboy

    wvccboy Notable Member

    Messages:
    2,632
    Likes Received:
    81
    Best Answers:
    1
    Trophy Points:
    250
    #3
    Yes I plan to showDocument in Java. That's what I was looking for.

    Thanks!
     
    wvccboy, Sep 18, 2007 IP