How to show an html page using JEditorPane in applet.

I have never use jeditorpane with applet so i dont know how to show a html page.if you have some code or any example then please posted that.Thanks

public class MyApplet extends JApplet{
    private JTextPane textPane = null;
    public void init(){
    HTMLEditorKit editorKit = new HTMLEditorKit();
    HTMLDocument  htmlDoc   = (HTMLDocument)editorKit.createDefaultDocument();
    textPane  = new JTextPane();
    textPane.setEditable(false);
    textPane.setEditorKit(editorKit);
    textPane.setContentType("text/html");
    textPane.setDocument(htmlDoc);
    Container c = getContentPane();
    c.add(new JScrollPane(textPane),    BorderLayout.CENTER);
    c.add(buttonPanel,                  BorderLayout.SOUTH);
    c.add(Box.createVerticalStrut(5),   BorderLayout.NORTH);     
    c.add(Box.createHorizontalStrut(5), BorderLayout.EAST);     
    c.add(Box.createHorizontalStrut(5), BorderLayout.WEST);
    public void setHtml(String html){
        // you should check the textpane's document to detrmine if there
        // is already text in there..if so, then clear the textpane text and then
        // set the new html...Note: JTextPane only show basic Html ..
        // not like a full blown browser
        textPane.setTextt(html);
        textPane.setCaretPosition(0);
}

Similar Messages

  • How to show a html page in a swing applet -- URGENT!!!

    Hi All,
    I'm trying to show a html page inside a swing applet... is it possible to do that?? if so is there any built-in classes available for that?? If anyone have some examples, plz help me with that....
    Thanks,
    Ragu

    i havent tested.. but this should work. i am no expert on these either, just to give you an example.. :-)
    JEditorPane ePane = new JEditorPane();
    HTMLEditorKit html = new HTMLEditorKit();
    ePane.setEditorKit(html);
    HTMLDocument htmld = new HTMLDocument();
    try{
    URL url = new URL("http://hcs.harvard.edu/~undercon/");
    InputStream ins = url.openStream();
    ePane.setDocument(htmld);
    html.read(ins,htmld, 0);
    this.getContentPane().add(new JScrollPane(ePane),BorderLayout.CENTER);
    catch(Exception e)
    e.printStackTrace();
    }

  • How to generate dynamic HTML pages using Swing Application?

    Hello,
    I am writing a Java application to connect to a local light-weight java database. I would like to generate and present a HTML on the fly after selecting records from a database. At server side, I could easily use JSP/Servlet to do this. How can I do this on a desktop client machine using Java application? I do not want to install Apache web server on the desktop machine. Any help will be greatly appreciated. Thanks in advance.
    Dominic

    The way u need to generate your html pages depened on what u want to generate,
    anyway what i can help with, is how to display a generated page.
    u have to use JEditorPane with HTMLEditorKit and HTMLDocument to display any HTML.
    also u can use the methods provided with the above objects to generate your html format.
    I hope I helped.

  • How to create dynamic HTML page using PL/SQL code in APEX.

    hello,
    I am woking on one APEX application in which i want to create one dynamic HTML page on button press using PL/SQL code.
    Thanks

    It is possible to create HTML page with dynamic content. One way would be creating hidden field (e.g. P1_HTML on page 1) with dynamic HTML and on button click you redirect to page 2 and pass P1_HTML item value to item P2_HTML on page 2. On page you must have PL/SQL region. You can then render your dynamic HTML with code:
    htp.p(:P2_HTML);
    Don use APEX URL for passing HTML value. Problem and solution is described here: http://blog.trent-schafer.com/2011/04/03/dont-pass-string-parameters-in-the-url-in-apex-its-a-bad-idea/
    Edited by: MiroMas on 3.2.2012 3:20

  • How to display a HTML page using ABAP program.

    Hi all,
    I know that this is easy and possible too but I haven't worked on this kind yet. I need to display a screen/ABAP program like TCODE PPMDT, where an HTML page is to be displayed and on the click of the HTML links provided, I need to navigate to someother transaction codes.
    Cheers,
    Sam

    Hi,
    See this sample code
    REPORT ZTESTHTML .
    DATA: ok_code LIKE sy-ucomm,
          myurl(132).
    data: custom_container type ref to cl_gui_custom_container,
          myhtml type ref to CL_GUI_HTML_VIEWER,
          repid like sy-repid.
    DATA events TYPE cntl_simple_events.
    DATA wa_events TYPE  cntl_simple_event.
          CLASS lcl_event_receiver DEFINITION
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS NC_Handler
                FOR EVENT NAVIGATE_COMPLETE OF CL_GUI_HTML_VIEWER
                IMPORTING URL.
    ENDCLASS.
          CLASS lcl_event_receiver IMPLEMENTATION
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD NC_Handler.
        myurl = URL.
      ENDMETHOD.
    ENDCLASS.
    start-of-selection.
      set screen 100.
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
      CASE OK_CODE.
        WHEN 'BACK'.
          CALL METHOD myhtml->go_back
               EXCEPTIONS cntl_error = 1.
          if sy-subrc ne 0.
          endif.
        WHEN 'FORW'.
          CALL METHOD myhtml->go_forward
               EXCEPTIONS cntl_error = 1.
          if sy-subrc ne 0.
          endif.
        WHEN 'STOP'.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
        WHEN 'REFR'.
          CALL METHOD myhtml->SHOW_URL
               EXPORTING
                  URL = myurl
                  IN_PLACE = 'X'
                  FRAME = ''
               EXCEPTIONS
                  CNTL_ERROR = 1
                  CNHT_ERROR_NOT_ALLOWED = 2
                  CNHT_ERROR_PARAMETER = 3
                  DP_ERROR_GENERAL = 4.
        WHEN 'OTHERS'.
          CALL METHOD CL_GUI_CFW=>DISPATCH.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'MENU'.
      if myhtml is initial.
        CREATE OBJECT custom_container
           EXPORTING
              CONTAINER_NAME = 'CONTAINER1'
           EXCEPTIONS
              CNTL_ERROR = 1
              CNTL_SYSTEM_ERROR = 2
              CREATE_ERROR = 3
              LIFETIME_ERROR = 4
              LIFETIME_DYNPRO_DYNPRO_LINK = 5.
        CREATE OBJECT myhtml
           EXPORTING
              PARENT = custom_container
           EXCEPTIONS
              CNTL_ERROR = 1
              CNTL_INSTALL_ERROR = 2
              DP_INSTALL_ERROR = 3
              DP_ERROR = 4.
        wa_events-eventid = CL_GUI_HTML_VIEWER=>M_ID_NAVIGATE_COMPLETE .
        wa_events-appl_event = 'X'.
        APPEND wa_events TO events.
        CALL METHOD myhtml->set_registered_events( events = events ).
        SET HANDLER lcl_event_receiver=>NC_Handler FOR myhtml.
        CALL METHOD cl_gui_cfw=>flush
             EXCEPTIONS cntl_system_error = 1
                        cntl_error        = 2.
      endif.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    Svetlin

  • How to call an HTMl page using URL in OAF?

    Hi,
    There is a page that has a toolbar. There we have to provide a help menu in which we need to display a customized html page. Therefore, we need to set the URL property in such a way that it should map to the path where this HTML file is located.
    Kindly provide a solution.

    Create a JSP page. Put your HTML code inside it. Place the JSP page under OA_HTML directory in server.
    Mention the JSP page name in destination URL property of the link item.
    -ANand

  • How to show an HTML page in a new browser window

    Hi Everyone,
    I am trying to show a page generated by some servlet in a new browser window when the button is clicked on the applet. I can accomplish that by using AppletContext as in:
    myApplet.getAppletContext().showDocument(servletUrl, "_blank");
    The only problem with this is that I don't have any control over how the new browser window is displayed. Using JavaScript I can set size, hide toolbar and address bar, etc. But how can I hide address bar on a new browser window generated in this scenario?
    I tried to call intermediate servlet from my applet which in turn generates a new window by writing out JavaScript code. This way I lose my previous page with the applet even though a new window is displayed the way I wanted but I want this new browser window to act as a pop-up box and my applet page stay on screen. Also, is there a way to send a POST request from an applet by using AppletContext.showDocument() method?
    Any help will be greatly appreciated!
    Thanks in advance,
    Y.M.

    Did you ever figure out a solution for this? I too would like to open a new browser window to act as a pop-up box and my applet page stay on screen. If anyone has any thoughts on how to do this, please post! thanks.

  • How to go to anchor html link from external html page in JEditorPane

    Hi people,
    I've been trying to jump to an anchor link from an external html page in JEditorPane, and I cannot get it working, I'm sure it can be done somehow...
    The HTML page has a link like:
    Hello
    and this is loaded into JEditorPane ok.
    The HyperlinkListener implementation:
    public void hyperlinkUpdate( HyperlinkEvent e )
    try {
    if ( e.getEventType() == HyperlinkEvent.EventType.ACTIVATED )
    editorPane_.setPage( getClass().getResource(
    MyDialog.this.getBaseURL().concat( e.getURL().getFile().substring(
    e.getURL().getFile().lastIndexOf( "/" ) + 1 ) ) ) );
    if ( e.getURL().getRef() != null )
    editorPane_.scrollToReference( e.getURL().getRef() );
    else return;
    } catch ( IOException ioe ) { ioe.printStackTrace(); }
    This code loads the new html file ok, but it does not scroll to the anchor. The MyDialog.this.getBaseURL() just returns something like com.name.package, I construct the URL by using this base url and the name of the html file to open.
    ANy help, thanks

    he! I'm not alone in my desperation. Take a look at my problem:
    I've got a JEditorPane (not editable) inside a JFrame. The JEditorPane is loaded with the HTML text and all the links to anchors are working properly when I click on them.
    BUT
    If I try to go to an anchor from outside this JFrame I can see how the JEditorPane scrolls to the right anchor and suddenly it scrolls back to the place where the caret was located!!!
    The "funny thing" is that my code is working in jdk1.3.1 but this is happening in jdk1.4.2. Is it a bug?!?!?!
    How could I figure out what position I have to set the caret to for every anchor in order to get the scroll working correctly???
    My implementation of hyperlinkUpdate (working properly, here isn't the problem):
       jEditorPane.addHyperlinkListener(new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              MiEditorPane src = (MiEditorPane)e.getSource();
              src.goToAnchor(e.getDescription().substring(1));
        });My object jEditorPane is an instance of this class:
      class MiEditorPane extends JEditorPane {
        MiEditorPane() {
          super();
        public void goToAnchor(String anchor) {
          super.scrollToReference(anchor);
      }And this is the method I call from outside the JFrame containing the JEditorPane:
      public void goToAnchor(String anchor) {
         jEditorPane.goToAnchor(anchor);
      }Any help greatly appreciated ...

  • How to create hyperlink in Html page using Java

    Hello every one
    I want to know that how can I create a hyperlink in Html page using java ?
    Let for example
    I have code like this and i want to give hyperlink to it using java.
    rember that i am creating node using this id="name" which give me multiple value. and i want to assign diff link to each name..?
    <tr>
    <td ><span id="name"></span>
    </tr>

    but i m using this code to create node in html file
    HTMLLIElement li = (HTMLLIElement)appHTML.createElement("LI");
    Text txt = appHTML.createTextNode(name);
    li.appendChild(txt);
    appHTML.getElementById("name").appendChild(li);
    this will display all name value which is coming from database,
    and i want to assign a hyperlink to it,
    I have id with name also so I thought that using id i will
    create javascript like
    function popup(id)
         if(id==1)
              var n1 = window.open("../list/name1.html");
         if(id==2)
              var n1 = window.open("../list/name2.html");
    this way i want to popup particular file if i can pass id value in this function
    so want hyperlink like
    name

  • How to embed jnlp file into html page using object tag

    hi everyone,
    i have written one jnlp file like this.
    <?xml version="1.0" encoding="utf-8" ?>
    <!-- JNLP file for Demo applicaion -->
    <jnlp spec="1.0+" codebase="http://localhost:9080/base/" href="SampleExample.jnlp">
         <information>
              <title>Demo Application</title>
              <vendor> </vendor>
              <description>Sample Demo Application</description>
              <offline-allowed/>
         </information>
         <security/>
         <resources>
              <j2se version="1.3+" />
              <jar href="common.jar" main="true" download="eager" />
              <jar href="classes12.jar" download="eager" />
              <jar href="toplink.jar" download="eager"/>
              <package name="com.applet.*" part="applet" recursive="true"/>
         </resources>
         <applet-desc name="grid" main-class="com.applet.PriceGrid" width="1000" height="300"/>
    </jnlp>
    i am trying embed that jnlp file using object tag like
    <OBJECT
    classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH="1000" HEIGHT="300" NAME="grid">     
    <PARAM NAME="jnlp" VALUE="http://localhost:9080/base/SampleExample.jnlp">
    </OBJECT>
    but i am not able to load the applet using Web Start.
    Can anyone please help me. This is very Urgent for me.
    Thanks & Regards,
    Shiva.

    thanks.
    i am giving my problem clearly. i have one applet. Previously i am loading the applet in my html page using object tag like this...
    <OBJECT
    classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH="1000" HEIGHT="300" NAME="grid">
    <PARAM NAME="CODE" VALUE="com.adp.base.applet.PriceGrid.class" >
         <PARAM NAME="ARCHIVE" VALUE="common.jar,classes12.jar,toplink.jar" >
         <PARAM NAME="NAME" VALUE="grid" >
    <PARAM NAME="type" VALUE="application/x-java-applet">
    <PARAM NAME= "cache_option" VALUE ="no">
    </OBJECT>
    now what i need to do is
    i need load the applet only first time using web start and when ever the applet code changes in the server i need to reload the applet.
    for that i kept all the applet resources in .jnlp file.i want to cache all the resources which are in .jnlp file and applet must be displayed within a web page within a browser.
    Webstart always open a new application windows.
    I need to run an Applet embedded within a web page within a browser.
    Is there a way to still use Webstart?

  • Problem Printing html page with JEditorPane...

    Hello All,
    I Have a problem in printin html file with JEditorPane...
    My Html file contains a Table on it..
    Problem is that JEditorPane displays the html file correctly but
    it prints the file without print that Table..
    So pls help me...
    Thanx in advance,..
    Amit
    [email protected]

    I think you would know how to retrieve content of an HTML page using the URL object. Just in case.
    My apology if this short note doesn't help you at all.

  • How do I create HTML mail using Mac OS X Mail 2.0.7?

    I know how to create an HTML page. How do I send it as HTML e-mail? OS X Mail receives HTML e-mail. It's kind of hard to believe it can't send it as well. I've tried pasting it in and attaching it - neither works. Any ideas?
    Thanks,
    Jim Carruth
    iBook G4   Mac OS X (10.4.6)  

    I know how to create an HTML page. How do I send it
    as HTML e-mail?
    You open the page with Safari and use a menu option to send the page as email.
    10.5 is supposed to add html email to Mail.

  • Trying to assemble a HTML page using 3 servlets.

    I am trying to assemble a HTML page using 3 servlets.
    1 servlet for generating a standard header for the page, 1 for generating a standard footer for the page and 1 for generating the content for the page.
    I know how to generate a page with only one servlet, but how do you do it with 3 servlets, with each generating part of the page.

    Use the include method of the RequestDispatcher to include the output of the header and footer servlets.

  • How to create a html page

    Hello,i am very new to dreamweaver 8,and i have searched
    everwhere possible on how to create a html page.My website has a
    navegation bar.And on the navegation bar it has links,like
    forums,your accounts,and etc,but thats already integrated with the
    website.Now i have an option in the admin area,wher i can create a
    new category so that it would show up in the navegation bar,and i
    have a drop down menu where i cans select what to put in that
    category.But also i have an option to put a external url,so that
    when they click on it,it will take them to where that link is
    directed.The point is that i asnt to make a category in the
    navigation menu that says Lirics.So that i can put lirics of songs
    and etc,and that when users click on that link it will take them to
    the lirics page..Do you guys understand?Sorry for the bad english,i
    am now quite good with it..

    The most eloquent description will do nothing for us. To get
    a solution to
    your problem, we must see your code. Can you upload the file
    and post a
    link to it, please?
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "don_playboy" <[email protected]> wrote in
    message
    news:eaadi9$kjf$[email protected]..
    > well what i am trying to say is that i created a Folder
    named
    > Liricas(which is
    > lirics in spanish),on my ftp.Now since i created that
    folder in my ftp,it
    > will
    > show on my navegation menu control panel.But it will be
    blank since it has
    > nothing on it.Now what i want to do is,sicne i created
    that folder,and i
    > go to
    > my nav meny control panel and select it as a category it
    will show on my
    > navegation menu(the Liricas that is),but when u click it
    it has
    > nothing,since
    > it has no html or anything in the category.Now i want to
    create a html
    > page so
    > that i can put albums names,and under those albums name
    i want to create a
    > link
    > or category thats for lirics.So all this will be stored
    on the ftp.and
    > when
    > users click on the Liricas category on my navigation
    menu,it will take
    > them to
    > the liricas index page,which will show all the lirics...
    >
    >
    >
    >

  • How to create a HTML page like iView, thanks in advance!

    How to create a HTML page like iView, thanks in advance!
    I'm a newcomer, would you please tell me how to create a HTML page in WebDynpro ? In fact, i want create one welcome page which use html format and include some javascript.
    thanks again.

    jakinapallykrishna , thank you very much for you reply.
    The pdf file is a simple application, but i want know how create a view in HTML format (<HTML>... </HTML>), maybe use HTMLB control, i don't sure it.
    In fact, I need create a view in portal, some pictures in it, once mouse over one picture, it need change another picture replace old one. I don't know how to do it, just know it can be handled in HTML page. So, i need help.
    Thanks.

Maybe you are looking for

  • Adding new info object to a cube.

    Hi Friends, This is a BI SYSTEM, we have a cube with existing data in it. Now we need to add a new info object to the dimension of the cube. Now we can add the info object to the cube in 2 ways. 1. remodeling the cube 2. select the cube in RSA1 , RIG

  • I can't use Yahoo messenger (it doesn't open the dialogue window), but in other PCs with older versions of Firefox I don't have problems

    I can't use Yahoo messenger (it doesn't open the dialogue window), but in other PCs with older versions of Firefox I don't have problems As stated earlier even though when I have an incoming message I hear the "Beep" Firefox does not open the dialogu

  • Audible authorisation crashes iTunes

    When I try to authorise my copy of iTunes to play my purchases, or if I try to deauthorise my computer, then iTunes crashes. iTunes plays all other audio and video files including streaming media without a problem. It is only Audible authorisation/de

  • Help in retreiving database data using a loop

    Hi, new here, please help me with my problem. In my database table, (SQL) I have 2 coloumns AgtName and Tier1. Within this table there are these data AgtName Tier1 a b b c c d d NA e b My orginal plan was to use JSTL to retreive the data in a loop fu

  • SAP PO vendor Chagnes

    Hi, How to change the vendor Name in SAP after saving the PO. Please help me on this. Regards S.Prasad