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


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

Re: JEditorPane and HTML

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail
From "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this>
Subject Re: JEditorPane and HTML
Message-ID <7a1fd6adb8045@uwe> (permalink)
X-Comment-To comp.lang.java.gui
Newsgroups comp.lang.java.gui
In-Reply-To <1193148657.209517.173750@z24g2000prh.googlegroups.com>
References <1193148657.209517.173750@z24g2000prh.googlegroups.com>
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92]
Lines 52
Date Wed, 27 Apr 2011 15:40:32 GMT
NNTP-Posting-Host 96.60.20.240
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1303918832 96.60.20.240 (Wed, 27 Apr 2011 10:40:32 CDT)
NNTP-Posting-Date Wed, 27 Apr 2011 10:40:32 CDT
Organization TDS.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:2679

Show key headers only | 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