How to highlight HTML source code in JEditorPane

I used JEditorPane to display the HTML source code. Now I want to highlight some part of the HTML code.
e.g. change the font or color of the second line in this piece of HTML code.
I tried to highlight the text in HTML way, e.g.
JEditorPane jep=new JEditorPane():
jet.setContentType("text/html");
jet .setText("<html><i>display styled text</i></html>");
but it didn't work at all. As the text I want to highlight is alreay a part of the HTML code.
I have to sort it out ASAP. as the deadline of my project is coming...
any advice is appreciated.
Thanks so much..:)

"In order to display the original html source code (not the effect made by HTML code ) i n JEditorPane,
i can't use editorPane.setContentType("text/html"): As it will try to render the webpage with this piece of HTML code..
e.g. here is the piece of html code i want to display in JEditorPane:
<HTML><HEAD><TITLE>Department of Computer Science Home Page</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2737.800" name=GENERATOR>
</HEAD>.........</HTML>
what i want to do is to highlight "Department of Computer Science Home Page" by setting it bold or italic."
Not really sure what you're saying here, but it sounds like you mean that you want the HTML itself to change. If that's it just:
<HTML>
<HEAD>
  <TITLE>Department of Computer Science Home Page</TITLE>
  <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
  <META content="MSHTML 6.00.2737.800" name=GENERATOR>
</HEAD>
<BODY color='blue' bgcolor='white'>
  <tr>
   <td bgcolor=yellow>Department of Computer Science Home Page</td>
  </tr>
</BODY>
</HTML>FWIW HTH, B4N
~Bill

Similar Messages

  • How to get the source code of an HTML page in Text file Through J2EE

    How to get the source code of an HTML page in Text file Through J2EE?

    Huh? If you want something like your browser's "view source" command, simply use a URLConnection and read in the data from the URL in question. If the HTML page is instead locally on your machine, use a FileInputStream. There's no magic invovled either way.
    - Saish

  • How to get the source code of an HTML page in Text file Through java?

    How to get the source code of an HTML page in Text file Through java?
    I am coding an application.one module of that application is given below:
    The first part of the application is to connect our application to the existing HTML form.
    This module would make a connection with the HTML page. The HTML page contains the coding for the Form with various elements. The form may be a simple form with one or two fields or a complex one like the form for registering for a new Bank Account or new email account.
    The module will first connect through the HTML page and will fetch the HTML code into a Text File so that the code can be further processed.
    Could any body provide coding hint for that

    You're welcome. How about awarding them duke stars?
    edit: cheers!

  • How to read the html source code of a webpage.

    How can I read the html source code of a webpage with a java application?
    Is there a good idea?

    >
    How can I read the html source code of a webpage
    with a java application?
    Is there a good idea?
    I don't know if this is a good idea, but it works.
    1) Use a URL to obtain the document's location
    2) Use a URLConnection to open a connection between your computer and the
    document server
    3) Connect to the server
    4) Get the InputStream of said connection
    5) Associate the Input Stream with a Buffered Input Stream
    At this point you can use a loop to read lines from the BufferedInput Stream and append them to a TextArea or other suitable text component.

  • How to read and then extract HTMl source code using java program?

    Hi,
    Could someone tell me how to read and then extract the content of certain tag from html source code. For example, given url http://.... , I would like to know what the <Title> content <Title> in that page is.
    Any help is greatly appreciate.

    Use a URLConnection to make the connection to the page at the needed URL. From the URLConnection, you can get an InputStream that is the stream of data from that page. Just search through the stream and find the <title> tags (don't forget to check for case sensitivity).

  • How to get the HTML Source code from the active browser ?

    Hi All,
    I need to get the HTML Source code from the active browser (IE). I tried with the below code, but I am not able to get the Source code all the time, with respect to the different applications (http or https) and the user authentication has to be changes in few applications (_I dont know or not able to given that in the below code_). More over there is also a dependence of the URL to get the HTML Source code.
    Therefore what I feel is getting the HTML Source code from the given or active browser will be consistent than the URL. Since the Source code is available in the browser (IE) . Please help me with a sample code to achieve this . . . !
    HTMLDocument doc=(HTMLDocument) kit.createDefaultDocument();
    doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
    URL url = new URL(strURL);
    Reader HTMLReader = new InputStreamReader(url.openConnection().getInputStream());
    kit.read(HTMLReader, doc, 0);Thanks in advance,
    Regards,
    Jothi Venkatachalam
    Edited by: j0o on May 7, 2009 3:11 AM

    The simple answer is: you don't.
    Not only is it simply not possible, but the entire concept of "the active browser" doesn't exist.
    You were on the right track with your code to retrieve the page directly from the server, but as you noticed that code will only work for regular http connections.
    For https and other protocols you will need to use appropriate libraries for each protocol. Something like Apache Commons can help you with that. There are networking libraries in there for a lot of commonly used protocols.

  • How to edit the html source code for my site

    I have just started a blog, and am VERY new to it. I am trying to edit the html source code on my site (ie, to insert google adsense search bars). I go to my blog site, get to page source and see the html but I am not able to edit it. Not sure what I am doing wrong. Thanks!

    You can use any editor you want mine is set up for notepad.exe
    :see http://dmcritchie.mvps.org/firefox/firefox.htm#notepad
    :to invoke use "Ctrl+U" or View > Page Source
    :this is for sites that you maintain on your local drives or servers, and copy over to a website.

  • How can I get HTML source code of dynamic Web page ?

    Hi,
    I would like to write a program that can get HTML source code of some Web pages, but there are some dynamic Web pages that I can't do it with URL class. For example: http://www.europlex.ch/web/3schedule/showAll.jsp?context=schedule.
    Thank you very much for any solution.

    Thank you for your attention. I'm sorry because I could't describe it clearly. If you don't mind, please follow this step to understand my problem:
    In the browser, enter URL: http://www.europlex.ch/web/main.jsp?locale=_english
    Click on Schedule, you will see the page with Cinema name, Film, Time... I would like to write Java Program to get HTML code of only this Page (Not frame page).
    Do you have any idea ?
    Thanhks,

  • How do I delete the html source code

    I found the html source code, selected it but am not able to delete it so I can put in my own code. I am using firefox

    Could you describe in more detail what file it is. Is this a page on a website that you are editing, or a page on your computer you use as your home page, or some other page?

  • CQ page is not rendering properly. It is not rendering HTML. It is showing HTML source code as is.

    On some of the pages, I am getting this weird behavior wherein page is not rendering properly. It is showing HTML source code as is. Could you please help me out? What could be the issue? And how can we get rid of the same?

    Check your component jsp page. it is possible that it is just plan file without directives <@ or you might have miss to close tag which is creating source as text to render
    Paste your jsp code in case you need further help
    Thanks,
    Ajit

  • How to protect java source code?

    Hi everybody
    I love Java but I think that people can decompile my class file to take my source code!Like this program
    http://kpdus.tripod.com/jad.html
    How to protect our source code?Even you use Jar files, they can unzip them and decompile!
    Thanks in advance!

    Use Java Obfuscator. Try one of these
    http://preemptive.com/products/dasho/index.html
    http://www.zelix.com/klassmaster/obfuscator.html
    http://java-source.net/open-source/obfuscators

  • View the html source code of an apex page

    Hi everyone,
    I search to how I can view the html source code of an apex page and to be able to modify it. That's why viewing the html source code from the browser when the application is running doesn't arrange me.
    Has anyone an idea how it can this be possible?
    Best regards,

    Khadija Khalfallah wrote:
    Hi everyone,
    I search to how I can view the html source code of an apex page and to be able to modify it. That's why viewing the html source code from the browser when the application is running doesn't arrange me. What do you mean?
    Do you want to be able to pull up the HTML source generated by Apex, modify that copy, and then feed it back into Apex with the chagnes you made? If so you can't. Apex generates the HTML through its tools and you have to modify the generation routines to get different HTML.
    Do you merely want to look at the generated HTML? In Internet Explorer all you have to do is right click on the page and choose View Source to open a window with the HTML source in an editor. I sometimes find it useful to save a page and manually edit the copy to immediately see the effects of certain changes to the underlying HTML and/or Javascript without permanantly making the change in Apex.

  • Retrieving HTML source code of a web page

    Hi,
      I want to take the HTML source code of a web page. How can I take?
    Thanks and regards,
    Venkat.

    You can do that with the class "cl_http_client".
    Sample code:
    DATA: http_client TYPE REF TO if_http_client .
    DATA: w_string TYPE string ,
    w_result TYPE string ,
    r_str TYPE string .
    DATA: result_tab TYPE TABLE OF string.
    START-OF-SELECTION .
    CLEAR w_string .
    w_string = 'http://urlhost/Logs/main.asmx/SetLog'.
    CALL METHOD cl_http_client=>create_by_url
    EXPORTING
    url                = w_string
    IMPORTING
    client = http_client
    EXCEPTIONS
    argument_not_found = 1
    plugin_not_active  = 2
    internal_error     = 3
    OTHERS = 4.
    CALL METHOD HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
    EXPORTING
    NAME = '~request_method'
    VALUE = 'POST'.
    CALL METHOD http_client->REQUEST->SET_FORM_FIELD
    EXPORTING
    NAME = 'title'
    VALUE = 'Mail sistema'.
    CALL METHOD http_client->REQUEST->SET_FORM_FIELD
    EXPORTING
    NAME = 'details'
    VALUE = 'Funcion 1234'.
    CALL METHOD http_client->send
    EXCEPTIONS
    http_communication_failure = 1
    http_invalid_state         = 2.
    CALL METHOD http_client->receive
    EXCEPTIONS
    http_communication_failure = 1
    http_invalid_state         = 2
    http_processing_failed     = 3.
    CLEAR w_result .
    w_result = http_client->response->get_cdata( ).
    REFRESH result_tab .
    SPLIT w_result AT cl_abap_char_utilities=>cr_lf INTO TABLE
    result_tab .
    READ TABLE result_tab INTO r_str INDEX 2.

  • Disable view html source code

    Hi,
    Anyone know that how could I disable the html source code, so
    no one can right click and view source code.
    Thanks
    David

    Hi,
    Anyone know that how could I disable the html source code, so
    no one can
    right click and view source code.
    Thanks
    David
    There are methods that will disable the right click, but then
    what do
    you do for those people that go to the 'View' menu and select
    'Page
    Source'? Or those who use the CTRL-U? Or those of us who have
    tools
    like firebug that allow us to inspect the source both before
    and after
    it has been rendered.
    In other words you can not really do what you want to do,
    which is hide
    your HTML source. The system just does not allow it at this
    time.

  • How to examine HTML source for keywords

    Hello!
    My problem is the following. I'm new on java programming and programming general.
    I want to examine a HTML source code after special keywords.
    So ive used the URL class to get the html code and saved it in a bufferedReader and then in a string
    If i have the following html source i.e., I only want to have the words: Action, Science-Fiction and Thriller. But these words only 1 time, so not the word action i.e. in , but the word action behind it.
    <tr valign="top">
    <td nowrap>
    <font face="Arial,Helvetica,sans-serif" size="2" class="Normal">Genre(s):
    </font>
    </td>
    <td>��</td>
    <td nowrap>
    <font face="Arial,Helvetica,sans-serif" size="2" class="Daten">
    <b>
    Action
    <br>Science-Fiction
    <br>
    Thriller
    <br></b></font></td>
    </tr>
    How can i do this at the best way??
    My first idea was to usw the stringtokenizer but there is no really universal way to search for some words etc.??
    It is maybe even possible to look fot the html tag with the word genre in it to use after this the next string who is not int the html code??
    I.e:
    i am searching for genre and found:
    and after this i want to usw the string "thriller" who stands behind it! is this possible??
    One of the big problems for me is also that there are no spaced sonetimes between the tags and the string and sometimes there are still spaces.
    Hope to get good help and sorry for my maybe not very understandable questions and my bad english :)
    big thx!!!

    Ok, lets say if have this part of code:
    <table border="0"><tr valign="top"><td>
    <a name="poster" href="photogallery"><img border="0" alt="cover" src="http://ia.imdb.com/media/imdb/01/I/38/48/31m.jpg" height="140" width="99"></a>
    </td><td width="90%">
    <b class="blackcatheader">Directed by</b><br>
    <a href="/name/nm0905152/">Andy Wachowski</a><br><a href="/name/nm0905154/">Larry Wachowski</a><br>
    <br>
    <b class="blackcatheader">Writing credits</b>
    <small>(<a href="/wga">WGA</a>)</small>
    <br>
    <a href="/name/nm0905152/">Andy Wachowski</a> (written by) &#38;<br><a href="/name/nm0905154/">Larry Wachowski</a> (written by)<br>
    <br>
    <b class="ch">Genre:</b>
    <a href="/Sections/Genres/Action/">Action</a> / <a href="/Sections/Genres/Thriller/">Thriller</a> / <a href="/Sections/Genres/Sci-Fi/">Sci-Fi</a> <a href="/rg/title-tease/keywords/title/tt0133093/keywords">(more)</a>
    <br><br>
    <b class="ch">Tagline:</b> Be Afraid Of The Future <a href="/rg/title-tease/taglines/title/tt0133093/taglines">(more)</a>
    <br><br>From this part of HTML code i need the Genres (in this case: Action, Thriller & Sci-Fi), and the directors (andy & Larry Wachowsky).
    My problem is now how to get these data.
    the first idea was to get the complete HTML source, disassemble it and then search for the words. You did this in your example code very good. But what can i do if i dont kinow the words for what im searching??
    Lets say i know that there are some genres, but i dont know which genres there are??
    so i could not really search for thriller, action and so on.
    Maybe i should search for the word "Genre:", cause this stands there every time and if i found it, i must pitch on the words behind it.
    I think your example code is very good, but he must find somehow not a special word, but a special position or sth. like that.
    I tried it by myself in some ways with the stringtokenizer, but regretfully he reaches very fast his limit.
    U understand now better my problem??
    sorry for the trouble, but my english is not the best and so its very difficult for me to describe my problem in english.

Maybe you are looking for