• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to turn a chat message in an Textarea to a proper line

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
eg, you send a message "My website is www.magaphone.com" in a textarea

I want it to appear as active link. Any help would be appreciated
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps a non-editable JEditorPane is better. That allows you to attach hyperlink listeners. All you need to do is make sure the contents are in HTML format.
 
Sege Stephen
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I have seen that . Will now give it more thought.

p.s I was partly asleep when I created this post, wow, so many typos. Will fix it
 
Sege Stephen
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Prime wrote:Perhaps a non-editable JEditorPane is better. That allows you to attach hyperlink listeners. All you need to do is make sure the contents are in HTML format.



Hi, I cannot use that JEditorPane as thisl textArea is already defined. It takes text Strings most of the time, the only time you would need it to show a URL is when some one enters www. something.com and click send. Other than that, all the other functions are ok in it.

I need to know how to handle that.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As already suggested, you handle it by not using a Textarea.

What do you mean it's "already defined"? What stops you from changing that and using the right component instead?
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It may be possible with JTextArea, but it will be quite hard. First, you will need a Highlighter that underlines, to highlight the "links". Next, you need a mouse (motion) listener that a) changes the cursor when the cursor is over such a "link" and back when the cursor leaves one, and can detect a link when you click on it.

It's not something I would like to do myself, frankly.
 
Sege Stephen
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok thank you Guys, I will change it to EditorPane. Hopefully it would be easy to code.
 
Sege Stephen
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to launch a browser from the GUI

Hello, I am now using JEditor pane, I can now read a link from the text message and open it. I have a simple problem. It i launches in the gui, i would like it to open the link in an external web broswer


I thought calling toExternalForm() will do the magic, but it doesn't, i have searched on the net but can't find something. Please point me in the right direction.

Sorry if I'm always appearing to be asking simple question, I am still learning.
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sege Stephen wrote:How to launch a browser from the GUI

It i launches in the gui, i would like it to open the link in an external web broswer



Use the Desktop class which what added to the API in JDK6.
 
Sege Stephen
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Camick wrote:

Sege Stephen wrote:How to launch a browser from the GUI

It i launches in the gui, i would like it to open the link in an external web broswer



Use the Desktop class which what added to the API in JDK6.




Sir, you made my day. Much appreciated. I can now go out and relax.

Just for anyone who maybe looking for the same solution

here
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic