Home > Archive > Java Help > July 2004 > beware: herein demons lie with JEditorPane
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
beware: herein demons lie with JEditorPane
|
|
| bad_knee 2004-07-06, 3:57 am |
| Just to pass it along...
after trying to debug the below exception for a couple hours,
it seems JEditorPane does not like certain characters?
the code
....
sb.append (str);
txtMessage.setText ("<font color=red>" + sb.toString() +
"</font><br>");
....
This would only cause the exception when str contained the "<" and ">"
characters. such as when str = str + "<User1>";
I removed the Arrowheads from str to get it to work. Hope it helps
someone else.
------------- exception -----------------------------------------
java.lang.ArrayIndexOutOfBoundsException: 0
at javax.swing.text.BoxView.getOffset(BoxView.java:1079)
at javax.swing.text.BoxView.childAllocation(BoxView.java:669)
at javax.swing.text.CompositeView.getChildAllocation(CompositeView.java:215)
at javax.swing.text.BoxView.getChildAllocation(BoxView.java:427)
at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.calculateViewPosition(BasicTextUI.java:1856)
at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.layoutContainer(BasicTextUI.java:1832)
at java.awt.Container.layout(Container.java:1020)
at java.awt.Container.doLayout(Container.java:1010)
at java.awt.Container.validateTree(Container.java:1092)
at java.awt.Container.validateTree(Container.java:1099)
at java.awt.Container.validateTree(Container.java:1099)
at java.awt.Container.validate(Container.java:1067)
at javax.swing.RepaintManager. validateInvalidComponents(RepaintManager
.java:353)
at javax.swing. SystemEventQueueUtilities$ComponentWorkR
equest.run(SystemEventQueueUtilities.java:116)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at java.awt.EventDispatchThread. pumpOneEventForHierarchy(EventDispatchTh
read.java:201)
at java.awt.EventDispatchThread. pumpEventsForHierarchy(EventDispatchThre
ad.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
| |
|
|
| VisionSet 2004-07-06, 4:11 pm |
|
"bad_knee" <bl8n8r@yahoo.com> wrote in message
news:e817ca4d.0407051720.ad4ed88@posting.google.com...
> Just to pass it along...
>
> after trying to debug the below exception for a couple hours,
> it seems JEditorPane does not like certain characters?
>
> the code
> ...
>
> sb.append (str);
> txtMessage.setText ("<font color=red>" + sb.toString() +
> "</font><br>");
>
> ...
>
> This would only cause the exception when str contained the "<" and ">"
> characters. such as when str = str + "<User1>";
>
So you mean HTML support in Java only accepts valid HTML?
That seems like the right approach to me.
--
Mike W
| |
|
|
| Roedy Green 2004-07-06, 4:11 pm |
| On Tue, 06 Jul 2004 15:54:01 GMT, "VisionSet" <spam@ntlworld.com>
wrote or quoted :
>So you mean HTML support in Java only accepts valid HTML?
>That seems like the right approach to me.
It greatly adds to the complexity of the rendering engine to allow
invalid HTML.
The problem you have in ordinary browsers is people test with IE which
is very forgiving, but then the HTML does not work other places.
Competition leads to greater and greater sloppiness, and more and more
overhead in browsers to deal with crap.
Inside Java, you don't have to deal with invalid HTML. So it makes
sense to have a streamlined engine that works only with validated
HTML. The catch is there is no easy way to run a validator on all the
HTML embedded in a Java program. Much of it does not even exist until
run time.
When Jesus comes, the first thing He will do is legislate a compact
binary format for HTML that is free from Error.
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
| |
| V S Rawat 2004-07-07, 4:00 am |
| VisionSet wrote:
> "bad_knee" <bl8n8r@yahoo.com> wrote in message
> news:e817ca4d.0407051720.ad4ed88@posting.google.com...
>
why should that give a problem?
<font color=red><User1></font><br> seems ok.
html tags can be used like that.
problem should be when it has only the opening or the
closing tag. Then it will mess up with the html.
<font color=red>User1></font><br>
<font color=red><User1</font><br>
[color=darkred]
> So you mean HTML support in Java only accepts valid HTML?
> That seems like the right approach to me.
>
> -- Mike W
On a related note, Has anyone observed whether html slows
down the program by hours.
In one of my programs, I had used Jbuttons with html
setText(). It was damn slow.
Then someone who was testing it beta, removed all html and
changed the buttons to labels, and it is running like anything.
Could that be because or html and/ or buttons?
--
Rawat
| |
| Andrew Thompson 2004-07-07, 8:59 am |
| On Wed, 07 Jul 2004 02:24:56 +0530, V S Rawat wrote:
...
> On a related note, Has anyone observed whether html slows
> down the program by hours.
As I understand it, several Mb of classes
need to be loaded (in addition to the usual
core) before HTML rendering can be done.
This leads to a singificantly slower *startup*
time, but should ne pretty much as quick at
changing text once the relevant classes are
loaded.
Of course, a simple test would help
distinguish where the bottlenecks lie.
Do time dumps throughout 2 programs.
One that displays a button w/plain text,
then changes the text 1000 times, another
with HTML formatted text that does the same.
--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
| |
| bad_knee 2004-07-07, 8:59 am |
| "VisionSet" <spam@ntlworld.com> wrote in message news:<tWzGc.66$rS4.30@newsfe2-win.ntli.net>...
> "bad_knee" <bl8n8r@yahoo.com> wrote in message
> news:e817ca4d.0407051720.ad4ed88@posting.google.com...
<snip>
[color=darkred]
>
> So you mean HTML support in Java only accepts valid HTML?
> That seems like the right approach to me.
It does at first until you consider user input.
| |
| VisionSet 2004-07-07, 4:03 pm |
|
"bad_knee" <bl8n8r@yahoo.com> wrote in message
news:e817ca4d.0407070406.143cb645@posting.google.com...
> "VisionSet" <spam@ntlworld.com> wrote in message
news:<tWzGc.66$rS4.30@newsfe2-win.ntli.net>...
>
> <snip>
>
>
> It does at first until you consider user input.
Well validate it then!
--
Mike W
| |
| Bent C Dalager 2004-07-07, 4:03 pm |
| In article <e817ca4d.0407070406.143cb645@posting.google.com>,
bad_knee <bl8n8r@yahoo.com> wrote:
>
>It does at first until you consider user input.
And, of course, once you _do_ consider user input, you quickly
conclude that you should run that input through a
plain-text-to-HTML-entities filter before ever even _considering_
putting it into your GUI.
Cheers
Bent D
--
Bent Dalager - bcd@pvv.org - http://www.pvv.org/~bcd
powered by emacs
|
|
|
|
|