This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi all I am displaying content of a file in an applet My requirement is each line must be a clickable link and must lead to different URL / web page ie each line has some text and a url delimited by suitable character and the url part is parsed out and the entire line is constructed as a clickable link This must be achieved for all lines of the applet content Can it is possible to achieve this in an applet I am not using JApplet Thanks Mohan
Yes, you can. How are you displaying the text? In a TextArea? I think you will need to use a specialized object to display the text in order to get the clicking functionality. One way to do this is to create your own Label-like object that captures mouse clicks. You could then add these objects to a ScrollPane if you need scrolling. Then, of course, you use showDocument to actually display the URL.
David G. Risner<br />Software Engineer<br />California State University, Los Angeles
Joined: Dec 02, 2001
Thanks david Actually I am using a scrolling text on applet itself using paint method. Pl indicate how to use showDocument method to open an URL Thanks Mohan
David G Risner
Joined: May 02, 2002
showDocument is really easy to use. From a subclass of Applet, you just do: url is a URL object and target is a string that works the same as the target attribute of the <A HREF> HTML tag. So if you want to open a file "testing.html" that is is the same directory as the HTML file holding the applet and have it always open in a new window, you would do something like: