[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Make a URL appear as a working link in a textarea component

Posted on 1998-06-12
6
Medium Priority
?
192 Views
Last Modified: 2010-04-16
I'm developing an applet which receives results from a database and then appends the results string to
a textarea component. The string contains a url which I want to appear as a working link when appended to the
textarea. I was thinking about a method which would allow you to append url objects to the textarea, but I cannot find anything, the only method I found was to append a string. Is there a solution to this or a possible work-around.
Ultimately I need to be able to link from the url which is retrieved from the database.

Thanks
Melanie
0
Comment
Question by:help_me
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 4

Expert Comment

by:evijay
ID: 1222966
You have to use a JFC Swing component HTML Text pane to do this instead of text area.
Or else, you can use html component from sun instead of text area.
0
 
LVL 4

Accepted Solution

by:
evijay earned 210 total points
ID: 1222967
You have to use a JFC Swing component HTML Text pane to do this instead of text area.
              Or else, you can use html component from sun instead of text area.
0
 

Author Comment

by:help_me
ID: 1222968
Please can you give me a url for the class description of the htmltextpane class, I have found textpane at:

http://www.dstc.uts.edu.au/java/swing-0.4.1/doc/api/com.sun.java.swing.basic.BasicTextPane.html

I found no reference to an html text pane, this is what I would like to use.

Thanks
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Expert Comment

by:evijay
ID: 1222969
The following are the places to look for

a) SwingSet demo program file HtmlPane.java
   here is the code too

           URL url = new URL(swing.javaDocPath + "/packages.html");
           html = new JEditorPane(url);
           html.setEditable(false);
           html.addHyperlinkListener(this);
           JScrollPane scroller = new JScrollPane();
           scroller.setBorder(swing.loweredBorder);
           JViewport vp = scroller.getViewport();
           vp.add(html);
           vp.setBackingStoreEnabled(true);
           add(scroller, BorderLayout.CENTER);

b) Everything about JEditorPane
      http://java.sun.com/products/jfc/swingdoc-current/index.html


0
 
LVL 4

Expert Comment

by:evijay
ID: 1222970
Since you are not getting the data from a url, u need to
extend JEditorPane class, tweak some of its methods
0
 

Author Comment

by:help_me
ID: 1222971
Thanks for the code, could you please explain how I should tweak the editor pane constructor method so that it is able to append a string of database results. Once these results have been appended, I need the urls which were fetched to show up as working links, will the HyperlinkListener be able to look at the text in the editorpane and work out where the links are?

I have not been able to get the HyperlinkListener to work in the following test program. It gives me this error - Explicit cast needed to convert Applet1 to com.sun.java.swing.event.HyperlinkListener.

import java.awt.*;
import java.awt.event.*;
import com.sun.java.swing.*;
import java.lang.*;
import java.net.*;
import java.applet.*;
import java.util.*;

public class Applet1 extends Applet
{

public void init()
{
   
    try
    {
    URL url = new URL("http://www.ox.ac.uk");
    JEditorPane html = new JEditorPane(url);
    html.setEditable(false);
    html.addHyperlinkListener(this);
    JScrollPane scroller = new JScrollPane();
    scroller.setBorder(Swing.loweredBorder);
    JViewport vp = scroller.getViewport();
    vp.add(html);
    vp.setBackingStoreEnabled(true);
    add(scroller, BorderLayout.CENTER);
    }
   
    catch (java.lang.Exception ex)
    {
    ex.printStackTrace();
    }
     

}
}

Thanks for your help.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question