Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #2679

Re: JEditorPane and HTML

From "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this>
Subject Re: JEditorPane and HTML
Message-ID <7a1fd6adb8045@uwe> (permalink)
Newsgroups comp.lang.java.gui
References <1193148657.209517.173750@z24g2000prh.googlegroups.com>
Date 2011-04-27 15:40 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
timtech wrote:
..
>By "offsets" I mean the number of characters from the beginning of the
>document (including line feeds).

In that case, you might play with this example.

Mind you, I get a start position of '0' printed, which
makes it quite odd to me that both these operations 
should effect the 'e', rather than the 's'.

<sscce>
import javax.swing.*;

class HTMLTextOffset {

  public static void main(String[] args)
    throws Exception {

    String content = "<HTML>test</HTML>";

    JEditorPane jep =
      new JEditorPane("text/html", content);
    jep.setEditable(false);

    System.out.println(
      jep.getDocument().getStartPosition() );

    jep.setCaretPosition(2);
    jep.moveCaretPosition(3);

    JOptionPane.showMessageDialog( null, jep );

    jep.setCaretPosition(0);
    jep.getDocument().remove(2,1);
    JOptionPane.showMessageDialog( null, jep );
  }
}
</sscce>

-- 
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-gui/200710/1

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: JEditorPane and HTML "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
  Re: JEditorPane and HTML "timtech" <timtech@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
    Re: JEditorPane and HTML "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000

csiph-web