Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Text links in applet

 
mohan kannan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Thomas Smets
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question has nothing to do with Applet !
Give a look at :
Dr David Marshall web site
If you can't use the JEditorPane give a look at URL following & you have most of it !
Thomas,
 
mohan kannan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks thomas
Is it possible with applet to open a url by capturing mouse click events
thanks
mohan
 
David G Risner
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
mohan kannan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

Hope that helps you out.
 
mohan kannan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thaks david
I will try out
Regards
Mohan
 
mohan kannan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks David
It worked
Regards
Mohab
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic