ListItem problem in JEditorPane

I'm trying to insert an item correctly before a line of text.
I tried a lot of thing but the result is always quite bad.
Please help

I'm trying to insert an item correctly before a line of text.
I tried a lot of thing but the result is always quite bad.
Please help

Similar Messages

  • /n problem with JEditorPane

    I wonder if anyone can help. I am developing an editor to edit java programs. I have a compile and run button as you would expect. When I compile the program in my editor, if I have an error I wish to highlight the line. I am using the select(int, int) method where the first int is the starting position and the second int is the ending position in the JEditorPane. The problem is that my editor takes into account the /n charachter wheras if I create a java program in any other editor and load it up in my editor, the /n is ignored. So you can see that I will have different starting and ending positions depending on where the java file was created. Can anyone help??

    no-one seems to understand the problem.You are absolutely right because I still have no idea what you are doing. In your latest post, you are copying the contents of the JEditorPane into a JTextArea just so you can figure out where the line starts and stops. Since you only posted a snippet of code, I can tell you that the following two lines look suspicious:
    values[0] = tx.getLineStartOffset(lineNo - 1) - lineNo;
    values[1] = tx.getLineEndOffset(lineNo - 1) - lineNo;
    because I can see no reason for subtracting lineNo to the start and end offsets!
    Again, your answer can be found at the link shown below:
    http://forum.java.sun.com/thread.jsp?thread=482553&forum=57&message=2251721
    Since you couldn't figure out how to solve you problem, I'll elaborate:
    For a JTextPane/JTextPane, you use the javax.swing.text.Utilities.getRowStart (instead of getLineStartOffset) and javax.swing.text.Utilities.getRowEnd (instead of getLineEndOffset) methods to get the start and end offsets. If you looked at the documentation, you'll see that all you needed to do is set the initial value of the second argument of the getRowEnd method to 0 (or the very first character of your JTextComponent) and iterate until you find the info you're looking for. For example:
    int line=1;
    int start=0,stop=-1;
    while (line<lineNo) {
       try {
          stop=javax.swing.text.Utilities.getRowEnd(editor,start);
          start+=stop;
          line++;
       } catch (BadLocationException e) {
          stop=-1;
    System.out.println(start+" "+stop);   // if stop is -1 or line!-lineNo, you've got a problem;o)
    V.V.

  • Problem with JEditorPane p lost when press ENTER

    OK, so here goes my problem.
    I have in my application a JEditorPane which formats text with bold italic and so on.
    The user can save this into a text file.
    So far so good, but the new lines are lost, no <p> tag is inserted, and no ALIGN either. All other tags - <b> <i> work fine.
    If I insert <p> tags into the text file and then open it in my application, they remain there fine.
    Any idea on this one?
    P.S. pls include some code samples, I'm not advanced ;)

    here is some code what i have used in my report program , i will still like to remind that its an Logical database program (PNP) for ABAP-HR , right now i tried the code mentioned above but not getting any result.
    TABLES: pernr,sscrfields,pa0001.
    *& Declaring Type-pools
    TYPE-POOLS : slis.
    *& Declaring Infotypes
    INFOTYPES: 0000,          " Action
                         0001.          " Org. Assignment
    *& Selection Screen
    SELECTION-SCREEN BEGIN OF BLOCK n1 WITH FRAME TITLE t1.
    PARAMETER : p_despat TYPE zhr_transfer-despt OBLIGATORY,              " Despatch Number
                r_pernr  TYPE pa0001-pernr OBLIGATORY,                                    " Reporting to
                re_pernr TYPE pa0001-pernr OBLIGATORY,                                   " Relieving Authority
                a_pernr  TYPE pa0001-pernr OBLIGATORY MODIF ID one.             " Authorize Person
    SELECTION-SCREEN END OF BLOCK n1.
    INITIALIZATION.
      t1 = 'Transfer Records'.
      LOOP AT SCREEN.
        IF screen-name = 'PNPPERNR-LOW'.                                  " Personnel Number (Mandatory)
          screen-required = 1.
            MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    AT SELECTION-SCREEN OUTPUT.
      IF a_pernr IS INITIAL.
        a_pernr = pa0001-ename.
      ENDIF.
    END-OF-SELECTION.

  • HELP!!! character display problem in JEditorPane

    hi,
    I got a headache with my program which needs to display multiple language html page in a JEditorPane. For example, if user requests a Chinese page then page is read in from an inputstreamreader using Chinese charset encoding. But what JEditorPane displays is squares and this is a very common font problem. I did everything I can
    copy font.properties.zh to font.properties
    set JEditorPane font as Font("SIMSUN",Font.PLAIN,12)
    with the bug unsolved so far.
    I am using Windows 2000/ME in UK locale.
    Anybody could help please???

    yes, the input data, for example in the case of Chinese Simpilify Character, is read in using a decoder with charset GB2312. I think I can print them out on prompt console but in a unrecognizable format.
    Anyway, I would like to reconfirm the steps I took: (Presumably I know I am going to load a Chinese page)
    1. rename font.properties.zh to font.properties
    2. set the font of JEditorPane as ("SIMSUN",Font.PLAIN,12)
    3. when try to load a Chinese page, there should be a ChangedCharSetException. extract the charset from the exception and use it to construct a new InputStreamReader.
    4. I also set the content-type of JEditorPane as something like "text/html; charset=gb2312"
    5. read in the data and parse it into a HTMLDocument instance.
    6. finally use setDocument method to display the document on the JEditorPane.
    In this way, the page gets displayed in unknown characters.
    Anybody could show me something different but feasiable? Please!!!

  • Problem with JEditorPane

    Hello
    I want to display an arabic text on JEditorPane
    I retrive this text fom database as byte[]
       byte[] arObj = rset.getBytes("ArFirstname");
       String myStr =(new String(arObj,"UTF-8")).toString().trim();
       StringBuffer buff = new StringBuffer()
       buff.append("<html><head><title></title></head><body>")
       buff.append("<h2>"+ myStr + </h2>");
       buff.append("</body></html>")
      myJEP.setPage(buff.toString());but I see only ???
    what is wrong
    thanks

    Hello
    I want to display an arabic text on JEditorPane
    I retrive this text fom database as byte[]
    byte[] arObj = rset.getBytes("ArFirstname");
    String myStr =(new String(arObj,"UTF-8")).toString().trim();
    StringBuffer buff = new StringBuffer()
    buff.append("<html><head><title></title></head><body>")
    buff.append("<h2>"+ myStr + "</h2>");
    buff.append("</body></html>")
    myJEP.setPage(buff.toString());but I see only ???
    what is wrong
    thanks

  • Sizing problem in JEditorPane

    I am tryying to set the size of JEditorPane using setSize(int w, int h) method, but it isn' working. The pane is rendered as just about a single character height even though I have given higher values (about 500) for height. Any idea what could be wrong?

    Hi,
    Refer these links:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/2016a0b1-1780-2b10-97bd-be3ac62214c7
    /people/boris.zarske/blog/2007/06/13/sizing-a-system-for-the-system-landscape-directory-of-sap-netweaver
    /people/william.li/blog/2008/03/07/step-by-step-guide-in-processing-high-volume-messages-using-pi-71s-message-packaging
    http://help.sap.com/saphelp_nwpi71/helpdata/en/46/79e8e13872275ae10000000a11466f/frameset.htm
    Regards,
    Nithiyanandam

  • Problems with JEditorPane

    Hi,
    I am developing a 'web browser' in java. When i open the java main site (www.java.sun.com) the images , texts do not 'fall into their places'. Could somebody help me?
    Thanks

    I am developing a 'web browser' in java. I don't want to discourage you, but JEditorPane is really not suitable for serious web browsing. The page that you're trying to view contains a great deal of styles and contains javascripts which JEditorPane is not prepared to handle. I'm using j2sdk1.4.2 and the page looks somewhat decent but is really useless!
    ;o)
    V.V.

  • Font Color problem with JEditorPane

    am designing an application whch will change the forecolor the keywords as the user type. like many java ide. but i am not able to do this.
    this is what i am doing. start and end refers to the start and end position of the keyword.
    if its a keyword i have to make it red.
    if not make it black.
    How to do this...
    if(isKeyWord(editor.getText(start,end-start))) {
              System.out.println("found : " + start + ":" + end);
              editor.setSelectionStart(start);
              editor.setSelectionEnd(end);
              editor.setSelectedTextColor(Color.RED);
         }else {
              System.out.println("not found : " + start + ":" + end);
              editor.setSelectionStart(start);
              editor.setSelectionEnd(end);
              editor.setSelectedTextColor(Color.RED);
    so please help me...
    thank u

    Asked and answered two days ago in this posting:
    http://forum.java.sun.com/thread.jspa?threadID=775635

  • Problem to display Animated Gif from HTML into JEditorPane

    I have a problem displaying animated gif that comes from URL (HTML) into JEditorPane.
    Let me show you the source I have:
    * @author Dobromir Gospodinov
    * @version 1.0
    * Date: Dec 6, 2002
    * Time: 6:47:53 PM
    package test.advertserver;
    import javax.swing.*;
    import java.awt.*;
    import java.io.IOException;
    public class Test {
         public static void main(String[] args) {
              JFrame frame = new JFrame();
              JEditorPane ed = new JEditorPane();
              try {
                   ed.setPage("http://localhost:8200/servlet?key=value");
              } catch (IOException e) {
                   e.printStackTrace();
              JPanel panel = new JPanel();
              panel.setPreferredSize(new Dimension(500, 500));
              panel.add(ed);
              frame.getContentPane().add(panel);
              frame.pack();
              frame.setVisible(true);
    }Part of the returned from servlet HTML includes an img tag:
    <img src="/images/MyAnimatedGif.gif" alt="animated gif comment" width="480" height="50"  border="0">Let us assume that MyAnimatedGif.gif has 10 frames and gif is looped - when the 10th is dipslayed it has to display the 1st and so on.
    JEditorPane displays frames from 1 to 10 correctly but does not start from the first again. Instead JEditorPane displays a broken image.
    I locate where the problem arise:
    JEditorPane has an HTMLEditorKit that creates javax.swing.text.html.ImageView instance for every IMG tag.
    And here is the problem:
    ImageView has an ImageObserver necessary for the asynchronous image download. ImageObserver has the imageUpdate method. But this imageUpdate method is never called with ALLBITS flag raised up. Instead, after the last frame of MyAnimatedGif.gif is downloaded the imageUpdate method is called with flag ERROR raised up. Obviously this is a bug of Sun's implementation. Finaly the flag ALLBITS has to be received for normal end of image observing. But ALLBITS flag does not come.
    So, can anybody help me how to load an animated gif within JEditorPane completely.
    Thank You in advance,
    Dobromir Gospodinov
    P.S. If somebody of you wants to debbug what happens within ImageView will have to implement it (and related classes too, because of the limited package visability) borrowing the source from Sun's ImageView.

    I'm also having this problem with java 1.4.1 I discovered that some animated gifs work fine, while others stop animating. Running with java 1.3.1 fixed the problem. I'm going to report this as a bug
    Here's my code:
    import java.awt.*;
    import java.io.*;
    import javax.swing.*;
    public class AnimatedGifTester
    extends JFrame
    public static void main(String argv[])
    throws Exception
    new AnimatedGifTester();
    public AnimatedGifTester()
    throws Exception
    String[] images = new String[] {
    "http://www.gif.com/ImageGallery/Animated/Animals/Photographic/dog_running.gif",
    "http://www.gif.com/ImageGallery/Animated/Characters/Cartoon/java.gif",
    "http://www.webdeveloper.com/animations/bnifiles/anielg.gif",
    "http://www.webdeveloper.com/animations/bnifiles/cat2.gif",
    "http://images.animfactory.com/animations/animals/fish/big_fish_swimming_md_wht.gif",
    "http://www.webgenies.co.uk/images/martian.gif",
    "http://www.webdeveloper.com/animations/bnifiles/at_sign_rotating.gif",
    "http://www.webdeveloper.com/animations/bnifiles/arrow_1.gif",
    "http://www.gif.com/ImageGallery/Animated/Characters/Cartoon/javaacro.gif",
    "http://java.sun.com/products/java-media/2D/samples/suite/Image/duke.running.gif",
    "http://www.gif.com/ImageGallery/Animated/SouthPark/Cartoon/stan.gif"
    StringBuffer buffer = new StringBuffer("<html><body>");
    for (int idx = 0; idx < images.length; idx++)
    buffer.append("<img src='" + images[idx] + "'>");
    buffer.append("</body></html>");
    String html = buffer.toString();
    // save a copy of the html to open in a browser so we can see what it's
    // supposed to look like
    BufferedWriter writer = new BufferedWriter(new FileWriter("animatedGifTest.html"));
    writer.write(html);
    writer.close();
    JEditorPane editorPane = new JEditorPane("text/html", html);
    editorPane.setEditable(false);
    getContentPane().add(editorPane);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(new Dimension(400, 600));
    show();

  • Problem with submit button in JEditorPane

    Hi,
    I'm trying to create a browser using JEditorPane. But I have 2 problems.
    1. Refreshing the current page in JEditorPane
    2. My HTML page doesn't submit the request at all.
    Is it a problem in JEditorPane or I should make it submit as we do for hyperlinks.
    If yes, then please send me the code to make a HTML page submit.

    The form is open. I should have mentioned that I made sure to check that first.  The form was created by uploading an existing PDF file that I created from a MS Word file to Adobe FormsCentral. Once the form was completed, I had a coworker test it & it worked.  We sent the form out & I have received some back, but have also received reports of the form not working.  I downloaded the form to my computer & tested it using Adobe Acrobat 9.0 Standard.  I use a Windows environment on a Dell laptop.  The form does not work for me.

  • Display FrameSet inside JEditorPane

    Hello all,
    I have the problem with JEditorPane, when I preview a html page with frameset. The html page contains two part
    1,) Navigation links on top
    2.)Body page, where anchors are used, so that when each navigation link is clicked the appropriate anchor is scrolled down in the JEditorPane.
         editorPane.addHyperlinkListener(new HyperlinkListener() {
         public void hyperlinkUpdate(final HyperlinkEvent e) {
              try{
              URL url = e.getURL();
         JEditorPane src = (JEditorPane) e.getSource();
    src.setPage(url);
              catch(IOException io){
                   io.printStackTrace();
    Here the problem is the frameset is lost and the body part is previewd inside the JEditorPane. That is the navigation part is gone and it doesnt scroll down to the anchor also.
    So can anyone please write how to support frameset in the JEditorPane.
    Thanks
    Joseph

    //try this
    //add this import
    import javax.swing.text.html.*;
    // use this hyperlinkUpdate
    public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e.getEventType() != javax.swing.event.HyperlinkEvent.EventType.ACTIVATED) return;
    JEditorPane editorPane = (JEditorPane) e.getSource();
    if (e instanceof HTMLFrameHyperlinkEvent) {
    HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e;
    HTMLDocument doc = (HTMLDocument) editorPane.getDocument();
    doc.processHTMLFrameHyperlinkEvent(evt);
    } else {
    try {
    editorPane.setPage(e.getURL());
    } catch (Throwable t) {
    t.printStackTrace();
    }

  • JEditorPane split

    Hi all ,
    I have a problem with JEditorPane, I would split it in pages .
    I mean , i load a StyledDocument from a file and I would show only a page a time, I tried a copy and paste tecnique .
    the whole file is in a JEditorPane and the single page is copied in another JEP that is showed.
    this is the code :
         public void split(JTextPane from, JTextPane to,int fromWhere ,int toWhere,int jepFromWhere){
              from.select(fromWhere,fromWhere+toWhere);
              from.copy();
              to.setCaretPosition(jepFromWhere);
              to.paste();
         public void setDoc(DefaultStyledDocument document){
              this.doc = document;
              jep.setVisible(false);
              textPaneAppoggio.setDocument(document);
              stateChanged=false;
              stop = true;
              while( how < doc.getLength() && howmuch >0){
                   split(textPaneAppoggio,jep,how,howmuch,jepHow);
                   if (stateChanged){
                        stateChanged = false;
                   }else{
                   how = how+howmuch;
                   jepHow = jepHow+howmuch;
              stop = false;
              jep.setVisible(true);
              return ;
    public void adjustmentValueChanged(AdjustmentEvent e) {
         if(!stateChanged && stop){
              jep.setCaretPosition(jep.getDocument().getLength());
         if (e.getValue()!=0){
              howmuch = 0;
              jep.select( how , jep.getCaretPosition() - e.getValue());
                 jep.cut();
                    return ;
              jep.select( how , jep.getCaretPosition() - e.getValue());
              jep.cut();
              howmuch = howmuch /2;
              stateChanged = true;
         thanks for the replies !!!

    the error is that sometimes the doc setting isn't stopped so the scrolling is done.
    I tried the set AutoScroll feature but nothing different appened the JScrollPane scrolls anyway

  • Rendering html in JEditorPane

    hi
    i have a problem in JEditorPane.
    when i rendering a html with frameset then i cannt resize the frames (like JSplitPane) but it working in browser.
    so how i do it in JEditorpane??
    thanks

    I think it just ignores it, but I could be wrong. If you want to do what you are saying, I think you need some custom document or something. The standard classes aren't going to help much, as far as I can tell.

  • JEditorPane Html Table Lines

    It seems if I load html containing tables into a JEditorPane, the format is less than great. The main problem I have is that none of the table lines show up. I was wondering if there was an option or something I'm overlooking, that would solve this problem. JEditorPane.showTheLinesSeperatingRowsAndColumnsInHtmlTables(true) for instance would be great.
    Thanks

    if the HTML source produces line, JEditorPane should shouw them as long as HTML 3.2 is used.
    Ulrich

  • JEditorPane setText 2MB HTML --- Terrible Performance !!! (65 seconds)

    I'm trying to load an HTML file that is large approximately 2MB (1927KB for the sake of precision) into a JEditorPane, and it takes about 65 seconds, it seems to be a bug of the JTextPane/JEditorPane, i have read also several articles on the web like [this one|http://java-sl.com/JEditorPanePerformance.html] , but i couldn't find a solution ...
    Here's the code that i use :
    final String htmlContent = //Load a 2MB String
    previewPane.setContentType("text/html; charset=UTF-8");
    previewPane.setText(htmlContent);
    The setText method takes about 65seconds to get completely executed as you can see in my application log :
    Set the html content(1927KB) of the Preview pane, loading time=68230ms
    Set the html content(1927KB) of the Preview pane, loading time=62693ms
    Set the html content(1927KB) of the Preview pane, loading time=66583ms
    Is there a way to solve this problem ?
    About 65 seconds to load 2MB of Text is a terrible performance on an Intel Core 2 Duo 2.93GHz with 8GB of DDR 3 RAM ...

    Remember that this data not only needs to be loaded, it also needs to be interpreted and rendered. I have a sneaky suspicion that the slowdown is actually in the rendering part. It is not a huge amount of bytes - it is a huge amount of HTML content that needs to be processed. Modern browsers can cope with that no problem, but JEditorPane is not a browser.
    It could be a performance issue, but that won't help you anything. Even if you would create a bug report it probably won't ever get a high enough priority that it will be considered for fixing; Swing isn't exactly actively developed anymore. On top of that I always saw the HTML capabilities of JEditorPane as a novelty really; nice that an attempt has been made to make it somewhat easier to load formatted text into it, but don't start treating or making expectations of it like you would of a web browser.
    There is a test you can do. Assuming you are running under Windows, try turning off Direct3D and see if that influences the performance. In other discussions I have seen that the rendering of text is actually a performance hog when hardware rendering is enabled, for whatever reason. You do this by starting Java with the following command line switch:
    -Dsun.java2d.d3d=false
    Edited by: gimbal2 on Feb 1, 2012 3:57 AM

Maybe you are looking for

  • Inconsistent Multi-Pass

    I recently bought Multi-Passes for the Daily Show and the Colbert Report. They worked as expected for the first two episodes, but today only the Colbert Report downloaded. I received a notification e-mail only for the Colbert Report - however, the sa

  • Creating the Target group

    Hi , i would like to create the target group in segment builder.i got the list of business partners.how to create the target group using this list(excel sheet) your help would be appreciated. Thanks, kenny

  • App won't load on Macs or Linux

    I'm sure there is something very basic causing this issue, but my app only seems to work on Windows machines! A Mac user told me the "initializing" message appeared the first time she went to my site, but it only got about 3/4 of the way and then the

  • How to achieve a smallest possible GUI Solaris

    Hello, everyone. I'd like to have smallest GUI Solaris possible. That is Core + Java Desktop System (Gnome Desktop). Has anyone gotten that combination works nicely yet? Please advise. Thanks. WO.

  • KEPM document delete

    Hi All, Is it possible to delete the document posted via KEPM. If yes, please let me know how can i delete . Thanks !! Mani