A Simple jTextPane Problem

M

mm

Hi all,

How do I code a jTextPane so that when a user clicks on (let say the
content of the jTextPane is "How are you?") the word "How" (only), that
word will appear in another jTextPane?

Any helps/samples would be greatly appreciated.

Thanks for your time.

MM
 
D

Deniz Dogan

mm said:
Hi all,

How do I code a jTextPane so that when a user clicks on (let say the
content of the jTextPane is "How are you?") the word "How" (only), that
word will appear in another jTextPane?

Any helps/samples would be greatly appreciated.

Thanks for your time.

MM

Hello.
May I ask if it's specifically a JTextPane that you want to use? Do you
know what the main difference between a JTextPane and a JTextArea is?

/Deniz Dogan
 
M

mm

Hi Deniz,

Thanks for replying.

I think the main defference between JTextPane and JTextArea is that
JTextArea's content type is plain only, while JTextPane can be plain or
in HTML format (Please correct me if I'm wrong, I'm new to Java). So I
think to put an action to the contents, JTextPane is more suitable than
JTextArea. But I have no idea how to do like in my first question.

Please help.

Thank You.
MM
 
D

Deniz Dogan

mm said:
Hi Deniz,

Thanks for replying.

I think the main defference between JTextPane and JTextArea is that
JTextArea's content type is plain only, while JTextPane can be plain or
in HTML format (Please correct me if I'm wrong, I'm new to Java). So I
think to put an action to the contents, JTextPane is more suitable than
JTextArea. But I have no idea how to do like in my first question.

I have never worked with JEditorPane, nor its subclass JTextPane before,
but I reckon you could add a CaretListener to it and work with that.
Perhaps there's some better way to do it, that I don't know of.

Also check out this web page:
http://java.sun.com/docs/books/tutorial/uiswing/components/text.html

Hope I could help.

/Deniz Dogan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

JTextPane and EditorKit 2
Maintain Selection in a JTextPane 1
JTextPane 0
JTextPane Question 0
Objects 2
caret on not editable JTextPane 3
JTextPane columnar data 1
Non-Programmer Needs Help With Simple Program 3

Members online

Forum statistics

Threads
474,266
Messages
2,571,075
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top