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 Jonathan *** 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
Greenhorn
Joined: Aug 02, 2001
Posts: 5
posted
0
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
Tony Costa
Greenhorn
Joined: Aug 02, 2001
Posts: 5
posted
0
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
Greenhorn
Joined: Sep 13, 2011
Posts: 1
posted
0
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.setPage(URL);
textPane.setContentType("text/html");
textPane.setEditable(false);
((HTMLEditorKit)textPane.getEditorKitForContentType("text/html")).setAutoFormSubmission(false);
textPane.addHyperlinkListener(new HyperlinkListener()
{
@Override
public void hyperlinkUpdate(HyperlinkEvent e)
{
// this method will be called when user hits submit button on the form
}
});