Meaningless Drivel is fun!
The moose likes Swing / AWT / SWT and the fly likes JEditorPane and HTML submit button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JEditorPane and HTML submit button" Watch "JEditorPane and HTML submit button" New topic

JEditorPane and HTML submit button

Jonathan Whitehead

Joined: Jun 13, 2001
Posts: 10
Hi all,
There are lots of messages in this archive about getting hyperlinks to work in a JEditorPane, which were very helpful to me thank you ) (***) (The answer is add a HyperlinkListener.)
But I have an HTML tag [input type=submit] in the JEditorPane inside a [form action="newpage.jsp"]. And clicking on the corresponding button does not seem to create a Hyperlink Event (perhaps this is logical, i don't know). And of course the newpage.jsp is not displayed.
Any clues on what I should do to handle the button click event?
Also the JEditorPane does not handle multiple groups of radio buttons (inside a form). You can only select one radio button in the entire form, even though they have different values for the "name" attribute in the [input] tag.
Maybe JEditorPane is just not designed to do this kind of stuff, and I need to really understand all about EditorKits and stuff, and do it myself. Are there any helpful tutorials about this?
Thanks in advance
*** P.S. (sorry this is my standard smiley and I don't mean to yawn or be angry or embarrassed )
[This message has been edited by Jonathan Whitehead (edited July 11, 2001).]
[This message has been edited by Jonathan Whitehead (edited July 11, 2001).]
Tony Costa

Joined: Aug 02, 2001
Posts: 5
I am attempting to do this same thing. I'll let you know if I find anything. I'd appreciate it if you would let me know if you find anything.
Tony Costa

Joined: Aug 02, 2001
Posts: 5
Found this at jGuru:
The JEditorPane is not a full blown implementation of HTML browser. It does not support an HTTP forms interface. However you can add components like JButton to the JEditorPane using the following method -

SimpleAttributeSet sas = new SimpleAttributeSet();
StyleConstants.setComponent(sas, new JButton("Hello"));
editorPane.getDocument().insertString(editorPane.getDocument().getLength(), "", sas);
Eduard Napolov

Joined: Sep 13, 2011
Posts: 1
Found how to do it. You need to set flag on HTMLEditorKit so instead of posting data to URL it will generate hyperlink event:

JTextPane textPane = new JTextPane();
textPane.addHyperlinkListener(new HyperlinkListener()
public void hyperlinkUpdate(HyperlinkEvent e)
// this method will be called when user hits submit button on the form
I agree. Here's the link:
subject: JEditorPane and HTML submit button
jQuery in Action, 3rd edition