Skip to main content

JXPanel does not hyperlink the html <a href> data

4 replies [Last post]
vandanachadha13
Offline
Joined: 2010-09-25

I am using JXPanel for display. The data to be displayed, is read from an XML file which contains html data enclosed in CDATA tags. The data being shown is not hyperlinked. For example, for the following:

<a href="www.google.com>Test hyperlink</a>

"Test hyperlink" shows up, but it is not hyperlinked.

Other html tags like <B> or <ul> work as per their expected behaviour.

Has anybody shown the hyperlinks which is within html, and without using JXHyperlink, in JXPanel?

Modified to show correctly the html tags

Message was edited by: vandanachadha13

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
martinm1000
Offline
Joined: 2003-06-12

JXPanel and XML have nothing to do with the problem here.

Only some basic html tags are supported by some swing controls, like the label.
See http://download.oracle.com/javase/tutorial/uiswing/components/html.html

kschaefe
Offline
Joined: 2006-06-08

JXPanel is simply a container. You need to use a component which understand the display of XML/XHTML. Can you give a better example (some code perhaps) on what you are trying to do?

Karl

vandanachadha13
Offline
Joined: 2010-09-25

The component used within the JXPAnel is a LAbel.

Basic code flow is as follows:
The MainPanel class extends JXPanel
Set the layout to BoderLayout
Add a label to a TextPanel ( which is also of type JXPanel)
Add the TextPanel to the layout
Read the xml file and get the CDATA html which includes the href tags
Set the xml content to the label

Please let me know if exact code would be required to be provided.

To reiterate, other html tags like for bold, newline, etc work fine and display is as expected. Only the href tags are not showing the displayed data as hyperlinked.

In XML, I've tried both:
set data in CDATA HTML with proper tags
set data in CDATA HTML with html escaped characters like "<" etc.

kschaefe
Offline
Joined: 2006-06-08

Yes, code is required as I am not following the pseudo-code steps provided.

Karl