I'm developping an HTML Editor on a JEditor Pane. The problem is that a blank is not interpreted, and i've tried to add "& n b s p ;" in the code from a KeyListener added to the VK_SPACE event, or to define an Action to add HTML Spaces. But i didn't achieve to... I just want to insert a "& n b s p ;" in the HTML code of the document displayed in the JEditor evry time the SpaceBar is pressed. I've tried InsertContentAction() : Not a solution :It inserts " & n b s p ;" in the text (it appears litteraly). I've tried InsertHTML. But it needs a tag parameter, and in my case, i need no tag to be inserted. I'm stuck since days... Any help woul be extremely appreciated...
After creating a JEditorPane have u called setContentType("text/html"). If so then JEditorPane will look for an EditorKit registered as supporting that type, and will find the HTMLEditorKit by default. More over your "& n b s p". should not have any space in between(" ").
Joined: Jul 17, 2001
Sorry to disappoint you but i've already did all that stuff. I've even created my own EditorKit, HTMLDocument, And extended the parser... The problem isn't that simple. Moreover, you've noticed that when you don't put spaces between & n b s p it does'nt appear on the forum message (as in yours) . My question was actually how to insert content (as spaces) and not how to set a JEditorPane to read and write HTML, caus' this, i know already...
hi i was building help screens for my project using HTML. But due to the default parser 3.2 DTD, i couldnot correctly display the frames and other html controls. i saw in your posting that u could use 4.0 DTD for your purpose. Has it solved the problems mentioned above? Please help me in extending to 4.0 DTD. Thankyou ------------------
Hi Med Lam Actually I have faced EXACTLY the same problem currently, ie trying to insert some special character as it is into JTextPane. I wonder if you have found any solution/workaround ? Need help urgently! Thanks in advance! Rgds Eric Low
In HTML, " " (without the quotes) is a code character sequence to the server/browser to include an additional space in the DISPLAY of the document. It is an HTML standard to only recognise a single space (the ASCII character 32) for display purposes, and ignore multiple spaces in the stream of HTML instructions. The " " code is to tell the browser that more than one space is wanted in the display of the document. So, in an HTML document, creating an "empty" cell in a table looks like this: <TD> </TD>. And, if your desire is to have four spaces displayed, you will need to write something like " " (again, no quotes) to display four spaces, which would appear as " " (quotes used to display 4 spaces). If you want to insert the character sequence, " " into an HTML code page, (to indicate to the browser to display a space) then code your java editor to decode something like hitting F12 to mean: "insert ´ ´ at the cursor" (again without the quotes). Remember, computers do exactly what you tell them to do. If you hit the space bar while in a text editor, it inserts a space in the text.