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


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

Re: disable html parsing

From "Thomas Hawtin" <thomas.hawtin@THRWHITE.remove-dii-this>
Subject Re: disable html parsing
Message-ID <4572d86e$0$8742$ed2619ec@ptn-nntp-reader02.plus.net> (permalink)
Newsgroups comp.lang.java.gui
References <1165127903.476519.204240@f1g2000cwa.googlegroups.com>
Date 2011-04-27 15:26 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
Andrew Thompson wrote:
> Daniel wrote:
> ...
>> A few cells contain <html> and more text that is used in the program
>> it is editing the messages for.
>>
>> I would like to disable the default cell renderer from parsing the
>> html and instead display "<html> here is multi <br> line text </html>"
>> Is this possible?

> class NonHTMLLabel extends JLabel {
>   NonHTMLLabel(String label) {
>     super("<html>" + label.replaceAll("<", "&lt;"));
>   }
> }

And replace & with &amp; (first), and other differences.

> Note: there may be better solutions, above is just
> 'one way'.

 From 1.5, I believe you can do:

     label.setClientProperty("html.disable", true);

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4652898

For 1.4, I guess preppend a zero width no-break space (a.k.a. byte order 
mark, BOM). So:

     new JLabel("\ufeff"+text)


Exporting table data as HTML is also something you want to avoid the 
default PL&F behaviour for (unless you like XSS).

Tom Hawtin

---
 * 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 | NextNext in thread | Find similar


Thread

Re: disable html parsing "Thomas Hawtin" <thomas.hawtin@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
  Re: disable html parsing "Daniel" <daniel@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000

csiph-web