Combining JTextFields  
Author Message
Charly Si





PostPosted: 2006-4-15 2:59:00 Top

java-programmer, Combining JTextFields I have several JTextFields each contain text formatted differently. Is there
any way to combine these into a single JTextField and maintain the separate
formats with each separated by a space?


 
Stephen Marjoribanks





PostPosted: 2006-4-15 17:51:00 Top

java-programmer >> Combining JTextFields Charly Si wrote:
> I have several JTextFields each contain text formatted differently. Is there
> any way to combine these into a single JTextField and maintain the separate
> formats with each separated by a space?
>
>

It sounds like you want to use a JTextPane instead. That allows you to
have text in different formats within the same component.

Steve
 
Thomas Hawtin





PostPosted: 2006-4-15 20:13:00 Top

java-programmer >> Combining JTextFields Charly Si wrote:
> I have several JTextFields each contain text formatted differently. Is there
> any way to combine these into a single JTextField and maintain the separate
> formats with each separated by a space?

What do you mean by format? The style of the text (bold, font size, etc)
or the data format (numeric, date, ZIP code, etc)? If the former,
JEditorPane can deal with styled text. If the later, apply a
DocumentFilter to an AbstractDocument set on the JTextField.

Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
 
 
Karsten Lentzsch





PostPosted: 2006-4-15 20:51:00 Top

java-programmer >> Combining JTextFields Charly Si wrote:

> I have several JTextFields each contain text formatted differently. Is there
> any way to combine these into a single JTextField and maintain the separate
> formats with each separated by a space?

You can use a JFormattedTextField with a
custom AbstractFormatter that formats and
parses as you want.

-Karsten
 
 
Charly Si





PostPosted: 2006-4-15 22:03:00 Top

java-programmer >> Combining JTextFields
"Charly Si" <email***@***.com> wrote in message
news:eiS%f.9367$EA3.5633@dukeread10...
>I have several JTextFields each contain text formatted differently. Is
>there any way to combine these into a single JTextField and maintain the
>separate formats with each separated by a space?
>
>
I started with a string which I broke into tokens using String Tokenizer. A
JTextField was created containing each token. Each was then formatted with
different font and color. I now have a number of JTextFields containing data
that I want to display in a single pane in a JTabel. My thought is to
concatenate the several JTextFields into a single one for easy display. Is
there a way to concatenate these fields and maintain the formatting? or does
someone have a better solution?


 
 
Oliver Wong





PostPosted: 2006-4-15 22:25:00 Top

java-programmer >> Combining JTextFields "Charly Si" <email***@***.com> wrote in message
news:s270g.25035$EA3.21496@dukeread10...
>
> "Charly Si" <email***@***.com> wrote in message
> news:eiS%f.9367$EA3.5633@dukeread10...
>>I have several JTextFields each contain text formatted differently. Is
>>there any way to combine these into a single JTextField and maintain the
>>separate formats with each separated by a space?
>>
>>
> I started with a string which I broke into tokens using String Tokenizer.
> A JTextField was created containing each token. Each was then formatted
> with different font and color. I now have a number of JTextFields
> containing data that I want to display in a single pane in a JTabel. My
> thought is to concatenate the several JTextFields into a single one for
> easy display. Is there a way to concatenate these fields and maintain the
> formatting? or does someone have a better solution?

You may want to forget about JTextField and uses a JEditorPane or
JTextPane instead. See
http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html

- Oliver

 
 
HarryGuy





PostPosted: 2006-4-16 3:02:00 Top

java-programmer >> Combining JTextFields
"Oliver Wong" <email***@***.com> wrote in message
news:gn70g.13413$Zl.13104@edtnps89...
> "Charly Si" <email***@***.com> wrote in message
> news:s270g.25035$EA3.21496@dukeread10...
>>
>> "Charly Si" <email***@***.com> wrote in message
>> news:eiS%f.9367$EA3.5633@dukeread10...
>>>I have several JTextFields each contain text formatted differently. Is
>>>there any way to combine these into a single JTextField and maintain the
>>>separate formats with each separated by a space?
>>>
>>>
>> I started with a string which I broke into tokens using String Tokenizer.
>> A JTextField was created containing each token. Each was then formatted
>> with different font and color. I now have a number of JTextFields
>> containing data that I want to display in a single pane in a JTabel. My
>> thought is to concatenate the several JTextFields into a single one for
>> easy display. Is there a way to concatenate these fields and maintain the
>> formatting? or does someone have a better solution?
>
> You may want to forget about JTextField and uses a JEditorPane or
> JTextPane instead. See
> http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html
>
> - Oliver

Thanks. I don't know much about either of these and none of my Java Text
books say anything about them.but I'll try to find out how to go about using
them.

C