HyperlinkEvent and <a href="..." target=..

R

rolf gabler

Hi,
I got an application which sould show a html-file
as frameset, with a navigation frame in a tabbedPanel
I built a class extended by JPanel with a JEditorPane
and so far.

the result is that a link like:
<a href="x.html" target="mainframe">
will not be interpreted correct,
the frameset disapear and only the
link-site is shown.
I believe this could be a problem with my HyperlinkListener, because
when I use the HTMLFrameHyperlinkEvent and the framset
is shown in a JFrame as popup correct and all links are
working (I put the code below this post)

I add the HyperlinkListener in the following way,
which isn't able to handle a frameset
public class HTMKpnl{
....
try{
....
myJEditPnl.setEditable(false);
myJEditPnl.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED)
try {
myJEditPnl.setPage(e.getURL());
}
catch(Exception x) {
System.out.println("Hyperlink listener
error is " + x.getMessage());
}
}}
);
JScrollPane scroller = new JScrollPane();
JViewport vp = scroller.getViewport();
vp.add(myJEditPnl);
add(scroller, BorderLayout.CENTER);
}
catch (MalformedURLException e) {}
catch (IOException e) {}


what is going wrong?

best regards
Rolf

#####this code works as it has to do####

public HyperlinkListener createHyperLinkListener() {
return new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() ==
HyperlinkEvent.EventType.ACTIVATED) {
if (e instanceof
HTMLFrameHyperlinkEvent) {
((HTMLDocument)html.getDocument()
).processHTMLFrameHyperlinkEvent(
(HTMLFrameHyperlinkEvent)e);
} else {
try {
myJEditPnl.setPage(e.getURL());
} catch (IOException ioe) {
System.out.println("InpuOutputError " + ioe);
}
}
}
}
);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top