URGENT - Bullets in JEditorPane

im workin on a HTML editor.
im trying to have a toggle button which will insert a bullet and also remove the bullet for a sentence. im able to insert the bullet.
BUT IM NOT ABLE TO REMOVE BULLETS.
Any help on this would be greatly appreciated.
thank you

Hi,
you could read the HTML portion containing the bullet(s) into a string, then parse the string for UL and LI tags and remove them, then you could write the HTML string back to the document replacing the portion previously read.
To extract the existing HTML, you would place the caret somewhere into the bullet list and call getParagraphElement for that position. With the Element you call getParentElement until you have the UL tag. With the Element containing the UL tag, you can call getStartOffset and getEndOffset to extract the HTML. To copy the HTML to a string you can use a StringWriter as follows
    HTMLDocument doc = (HTMLDocument) editorPane.getDocument();
    EditorKit kit = (EditorKit) editorPane.getEditorKit();
    StringWriter sw = new StringWriter();
    kit.write(sw, doc, start, length);The HTML then is in sw.getBuffer().toString()
Once you manipulated the HTML as appropriate, you can write back as shown above with EditorKit.read()
Hope that helps
Ulrich

Similar Messages

  • Inserting bullets in JeditorPane

    Hi All
    I have used following code to insert a list item in my JeditorPane
    menu.add(new HTMLEditorKit.InsertHTMLTextAction("List", "<ul><li></li></ul>", TML.Tag.UL,HTML.Tag.LI));
    But it inserts two list items instead of one.
    Can anyone suggest something regarding this.
    Thanks
    Abhinit

    Ok, figured it out myself:
            notesArea.getInputMap().put(KeyStroke.getKeyStroke("enter"), "enterAction");
            notesArea.getActionMap().put("enterAction", new HTMLEditorKit.InsertHTMLTextAction("InsertBR", "<br>", null, HTML.Tag.IMPLIED, null, null));

  • Urgent: sizing a JEditorPane issues

    Hi,
    I need to build a table of HTML formatted text entries, where each of the entries is essentially a JEditorPane. So what I do is 2 JPanels, each of which has a Gridlayout. Into these I put components which are Jpanels containing a JEditorPane each.
    When I do that I get a table with huge amounts of white space around every line of text. I cannot figure out where this white space comes from. There are no P or BR marks in the html. Also, although all the html is one-liners, the table lines do not nicely line up at all.
    So I thought I'd set the size of these components to some predetermined, resonable size, like 200, 12. Now I don't see anything -- the content of the JEditorPane is entirely out of the visible area. When I make them a bit bigger, like 200, 32, I see the text, but again have some white space.
    Does anybody have an idea what's going on here?
    So essentially, the gallery contains a JScrollPane, which contains a Panel with 2 subpanels, each of which contains a column of these components. Each of these is a Jpanel containing a JEditorPane.
    This might be an overly complex packaging of the JEditorPanes, but there is some method to that madness...
    Thanks a lot for any ideas,
    Andreas

    Hi Andreas,
    Did you find any solution for this ? I am facing the same problem.
    When creating a new row in a JTable, with JEditorPane as the cell editor, some new lines are inserted and the cursor is positioned at the end of those unknown characters.
    Thanx
    MKPrasad.

  • Refreshing JEditorPane (Urgent) plz help

    hello programmers,
    i'm building an html editor:
    My html editor has a split pane, the 2 pane got of the split pane are JEditorPanes, one on which i write tag and the other i display them,... thankfully all's working great, my syntax is highlighting and the html is displayed well but i've got the following problem:
    when i save a html page , i wanna my browser (on the right side of the slipt pane) to display the html page... it's ok .. it displays it with the method JHTMLEditorPane.setPage(file:/// directory/ file) but the problem is that when i save the page again using the same filename... my html page on the JHTMLEditorPane stays the same... it does not update...
    is their a refresh function for the JEditorPane? how can i update my JHTMLPane to reflect the changes i've brought to it? ONe thing , the page changes when i save it by aother file name..... PLz help it's very urgent!!!!!!!
    Bernard

    Have you tried to close and then re-open the file in your editorpane after you've saved?
    It will work when you change the name because it has to open the file as new. Java can't dynamically update values upon files like C does with pointers.

  • Urgent : addinf html lists to Jeditorpane

    Hi All
    I am trying to insert a list item in a Html document opened in JeditorPane. I have used the following code but when I run it it inserts two list items instead of one.
    Can anyone suggest me how to overcome this problem?
    HTMLEditorKit.InsertHTMLTextAction ("Bullet", "<li> </li>", HTML.Tag.UL,HTML.Tag.LI);
    Regards
    Abhinit Kumar

    Hi All
    I am trying to insert a list item in a Html document opened in JeditorPane. I have used the following code but when I run it it inserts two list items instead of one.
    Can anyone suggest me how to overcome this problem?
    HTMLEditorKit.InsertHTMLTextAction ("Bullet", "<li> </li>", HTML.Tag.UL,HTML.Tag.LI);
    Regards
    Abhinit Kumar

  • How to load a text file int JEditorPane and highlight some words (Urgent !)

    I want to load a text file into a JEditorPane and then highlights some keywords such as while,if and else.I am using an EditorKit in order to style the JEditorPane. I have no difficulty while giving the input through the keyboard but lots of exceptions are thrown if i try to load the string from a file.

    Hi,
    I think the setCharacterAttributes(int offset, int length, AttributeSet s, boolean replace) will solve the problem.
    You can create your own Styled Document and set it to the Editor Pane.

  • Urgent-- Display a MS Word document in a JEditorPane

    Hi All, When i try to display the contents of MS word document using a JEditorPane, certain junk value gets displayed before and after the actual text... can i get any help...
    Thanx in advance...

    Desktop.open(File)
    And as an aside, you are lucky I am so bored. Usually I would close a post offering just one Duke, without any reply.

  • Refreshing the jeditorpane with the same file name(URGENT)

    Hi,
    I'm having trouble getting the JEditorPane to refresh the contents of an HTML file after updating it. Currently the original version of the file is shown and despite using setPage() with the same filename again, nothing happens, and the displayed file remains the same.
    I've tried removeAll(), validate() etc... but these have provided no results.
    Is there anyway i can clear the contents of the memory or something in order to fetch the updated file again?
    Any answers to this problem would be appreciated

    JEditorPane specifically doesn't allow loading of the same file/URL twice. It's one of the first checks it makes when you set the page.
    I think it'll work fine if you simply call setText("") on the editor pane to clear it down before calling setPage(..) with your file or URL. Even though the setText method doesn't load a file or anything it does create a new document which will not have the same URL as your original file so when you reload you file it will fail in the comparison and load it from scratch again.
    Hope this works for you,
    Drew

  • URGENT:- how to display bullets in a  jsp field?

    Hi,
    I need to display the names prepended with a bullet. If am displaying two fields like group_id and Names in jsp, it should look like this.
    Note: arrows are given below only just for formatting or to display columns correctly in this posting
    Group_id---> Names
    1-----> . Joe
    ------> . mary
    ------> . John
    2-----> . Mike
    ------> . Susan
    3-----> . abc
    Please advise.
    -thanks

    Hi ,
    Is your data coming from a Collection or Vector or other sources? So , am sending a code in plain html for displaying content in the required format. You can replace the bolded characters in the code ,with your dynamic content using <%=YourVariable%> .
    <html>
    <body>
    <table border="0">
    <tr>
    <td valign="top">
    1
    </td>
    <td>
    <ul>
    <li type=disc> Name1<br>
    <li type=disc> Name2<br>
    <li type=disc> Name3<br>
    </ul>
    </td>
    </tr>
    <tr>
    <td valign="top">
    2
    </td>
    <td>
    <ul>
    <li type=disc> Name4<br>
    <li type=disc> Name5<br>
    <li type=disc> Name6<br>
    </ul>
    </td>
    </tr>
    </table>
    </body>
    </html>

  • Hyperlink in JEditorPane URGENT

    I have encountered a problem regarding showing the html in JEditorPane(written under JApplet), since in the html code, there are some hyperlink which link to other html page. I can't link those page. Since I am not directly read the html from a file. I am passing those html code from the data I get from cgi and directly to JEditorPane. Anyone please help me solve this problem?
    Thank you..

    If you don't want to have to fool around with the HyperlinkListener, just add the normal <BASE> tag to your HTML file. The <BASE> tag has the following syntax:
    <BASE HREF="baseURL" TARGET="WindowName" >
    The TARGET portion is optional!
    Theoretically, the JEditorPane should be smart enough to look for the link from the same place where the original HTML file is loaded from but apparently there is a bug somewhere that prevents it from doing that.
    ;o)
    V.V.

  • URGENT: JEditorPane (a Java Browser) displaying HTML form

    Hi,
    I am using JEditorPane to display the wb pages but geeting problem as
    I don't get any kind of event when I click on the HTML form SUBMIT button though it does work but didn't allow me to get the URL of the new page that I got after hitting this SUBMIT button..
    I searched the whole net and it seems to me that lot of people got this problem...
    As I need this for my project please HELP me as soon as possible.

    This may be too late for you (hopefully not), but I had the same problem a little while ago and just figured out how to fix it. Basically, you need to examine the Element structure of the html yourself and manually handle the form, as far as I can tell. There are several ways to display a URL in a JEditorPane, but the most straight-forward (JEditorPane.setPage(URL url)) doesn't actually store the Element structure anywhere accessible. Here's the code to load the page:
    JEditorPane contents;
    HTMLEditorKit kit = new HTMLEditorKit();
    HTMLDocument htmlDoc = new HTMLDocument();
    contents.setEditorKit(kit);
    contents.setDocument(htmlDoc);
    URL url = new URL("http://blahblahblah.com");
    contents.read(url.openStream(), htmlDoc);Now that you have the page loaded correctly, you can access to the Elements within. You can use htmlDoc.getDefaultRootElement() to get the root and then iterate recursively through all the child Elements, checking out the Attributes of each. This will look for the submit button and add a listener to it for you:
    private void parseElements(Element elem) {
        AttributeSet atts = elem.getAttributes();
        //If this is the submit button, add a listener:
             Object model = atts.getAttribute(StyleConstants.ModelAttribute);
             Object type = atts.getAttribute(HTML.Attribute.TYPE);
             if ((type != null) && (type.equals("submit"))) {
                 DefaultButtonModel btn = (DefaultButtonModel) model;
                 btn.addActionListener(new ActionListener() {
                     public void actionPerformed(ActionEvent event) {
                         System.out.println("Yay!");
        //Recurse
        for (int i = 0; i < elem.getElementCount(); i++)
             parseElements(elem.getElement(i));
    }Of course, printing out "Yay!" is not really very helpful. When you're parsing through the Elements, check for the attribute StyleContsants.ModelAttribute. If that exists, you can cast it to the correct type of Model (see the documentation for HTMLDocument.HTMLReader.FormAction for information about what types of models to expect from what types of HTML elements) and store it until the "submit" button is pressed. Then all you have to do is get all the data from the models, format it and submit it to the action URL in either a "get" or a "post." The action URL is stored, in Java 1.3, in the HTML.Tag.Form attribute of one of the Elements (I don't remember which one). Getting that attribute returns a SimpleAttributeSet, and you get the HTML.Attribute.Action out of that. In Java 1.4 it's easier to find, you just have to look for the HTML.Attribure.Action attribute in one of the Elements.
    Why isn't this all automatically done for you? I don't know. Good luck.
    -Nathan

  • JEditorPane's paint method problem (urgent)

    Hi all, I have JEditorPane that displays HTML formatted text.
    My task requirement is to display a compay logo as static backgdound in this jeditorPane
    (The logo must be displayed always in the center nevermind the text scrolling)...
    So I overrided JEditorPane's paint method like that:
    public void paint(Graphics g) {
          super.paint(g);
          int scrolled_down = (int) ( (JViewport)this.getParent()).getViewPosition().
              getY();
          Rectangle visibleRectangle = new Rectangle();
          int width = visibleRectangle.getBounds().width;
          int height = visibleRectangle.getBounds().height;
          ImageIcon logo = IconFactory.getInstance().getIngLogoPaleIcon();
          g.drawImage(logo.getImage(), (width - logo.getIconWidth()) / 2,
                      scrolled_down + (height - logo.getIconHeight()) / 2, this);
        }But the problem is that I drow the logo over the some part of the text and the text is not visible.
    If I call super.paint(Graphics) mehtod after I drow the logo, the logo is overpainted and is not visible.
    (This logo is very pale transparent gif image).
    So my question is how can I achieve the effect this logo to be behind the text displayed in JEditorPane
    (I tried if it's possible to use CSS body attributes for static background image,but as I expected they are not supported)
    Thanks for every help in advance

    Hi!
    myEditorPane.setOpaque(false) This allows components under the EditorPane to show through.
    Thus, add a label with the desired image into a JLayeredPane, (if using in a JDeskTopPane you have acces to its FRAME_CONTENT_LAYER).
    Add your EditorPane on top of this after setting opaque to false and viola!
    Be aware that you should use caution when choosing a forground, (font ), color as the underlying image will affect how your text appears....
    :)

  • How to refresh the JEditorPane(URGENT)

    hi
    how to refersh the JEditorPane ..i used JEditorPane.removeAll() .but it not working
    pls help me

    usually, if you apply changes (setText, setAttributes, etc) to a document associated to a JEditorPane, the JEditorPane automatically shows the changes right away.
    If you instead want to replace the whole document, you could use JEdtiorPane.setDocument(), which again usually shows the newly assigned document right away.
    To simply wipe out the current contents, you can try
    JEditorPane.remove(0, JEditorPane.getDocument().getLength());
    Hope this helps
    Ulrich

  • JEditorPane clicked line (urgent !!!)

    I want to find which line is clicked when i click onto a text in a JEditorPane.How can I do it?

    Assuming you have a text document and not an HTML document, try:
    **  Return the current line number at the Caret position.
    public static int getLineAtCaret(JTextComponent component)
         int caretPosition = component.getCaretPosition();
         Element root = component.getDocument().getDefaultRootElement();
         return root.getElementIndex( caretPosition ) + 1;
    }

  • How to print a bullet in smartforms?

    Hi All,
    How to print a bullet in smartforms?
    I need it urgently.
    Any help would be appeciated.
    Regards,
    Mahesh.

    Hi,
    if i remember correct <600> is the value for bullets.
    you can insert this using sap system symbols ---> select bullets (before this place your cursor where ever you want the bullets.
    eg:
    P1  <600> test.
    Thanks,
    Sree.

Maybe you are looking for

  • Cisco Jabber for Windows unable to make calls in softphone mode

    Hi, I am facing an issue when I make a call from jabber in softphone mode to another jabber client my call fails and using wireshark traces I see SIP2.0 503 Service Unavailable. I have followed the guide and was able to deploy it once before successf

  • Error while importing a cerificate on portal

    Hi gurus, We got an error while importing sertificate in portal (Error mentioned below) JVMXE006:OutOfMemoryError, stAllocArray for executeJ ava failed at com.sap.engine.services.keystore.impl.coder.RepositoryCoder.decode(Re positoryCoder.java:71)   

  • SAP R/3 ENTERPRISE 4.7 / ORACLE 9i / kernel 640 for AIX 6.1

    Hello, We plan to migrate our SAP systems from AIX 5.3 to AIX 6.1. We are currently running a SAP R/3 ENTERPRISE 4.7 on ORACLE 9i with a 640 kernel 64 bits UC. I would like to know if AIX 6.1 is validated for our system (SAP 4.7, ORCALE 9i and kernel

  • Oddball fix

    hi i tried the bulletsandbones oddball fix for a problem and had no difficulty with repairing permissions, but was unable to locate the garageband preference files to delete them. the FAQ gives directions for S X 5 and older, and i have 10.6.2. is th

  • How do I stop the constant stars coming out of the firefox symbol - please help - they are driving me crazy

    ''locking this thread as the Owner of this thread answered in the related thread'' starting today when I clicked on firefox on my mac, there are blue stars constantly coming out of the firefox symbol and they are annoying and driving me crazy. How do