Simple Text Editor

I am developing a simple text editor in java.I haven't had many problems but i am trying to set fonts at the moment.i have developed a font chooser class.But when i am setting fonts i have only been able to set the font for a specific textArea ie I haven't been able to give different pieces of text in the textArea different fonts.Any tips or advice how to get around this would be greatly appreciated.Thanks

Comments

  • : I am developing a simple text editor in java.I haven't had many problems but i am trying to set fonts at the moment.i have developed a font chooser class.But when i am setting fonts i have only been able to set the font for a specific textArea ie I haven't been able to give different pieces of text in the textArea different fonts.Any tips or advice how to get around this would be greatly appreciated.Thanks
    :

    If this is AWT, you'll have to switch to another UI kit (Swing or SWT). Swing is included in the core API, so thats probably best.

    Have a look at JEditorPane and its subclasses.
    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JEditorPane.html

    ---------------------------------
    [size=1](Its just my sig)
    HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]


  • : If this is AWT, you'll have to switch to another UI kit (Swing or SWT). Swing is included in the core API, so thats probably best.
    :
    : Have a look at JEditorPane and its subclasses.
    : http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JEditorPane.html
    :

    Thanks for the reply.I am using Swing.I've had a look at JEditorPane but i don't see how exactly i can use it to handle a specific piece of text
  • :
    : : If this is AWT, you'll have to switch to another UI kit (Swing or SWT). Swing is included in the core API, so thats probably best.
    : :
    : : Have a look at JEditorPane and its subclasses.
    : : http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JEditorPane.html
    : :
    :
    : Thanks for the reply.I am using Swing.I've had a look at JEditorPane but i don't see how exactly i can use it to handle a specific piece of text
    :

    The class has getSelectionStart and getSelectionEnd methods.

    You use the component's model to alter the data structure (in this case, the underlying Document that holds the data).

    Example of how to set style info:
    http://javaalmanac.com/egs/javax.swing.text/style_HiliteWords2.html

    If I recall correctly, the J2SE SDK comes with a rich text editor sample that has all this.

    ---------------------------------
    [size=1](Its just my sig)
    HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]

  • : :
    : : : If this is AWT, you'll have to switch to another UI kit (Swing or SWT). Swing is included in the core API, so thats probably best.
    : : :
    : : : Have a look at JEditorPane and its subclasses.
    : : : http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JEditorPane.html
    : : :
    : :
    : : Thanks for the reply.I am using Swing.I've had a look at JEditorPane but i don't see how exactly i can use it to handle a specific piece of text
    : :
    :
    : The class has getSelectionStart and getSelectionEnd methods.
    :
    : You use the component's model to alter the data structure (in this case, the underlying Document that holds the data).
    :
    : Example of how to set style info:
    : http://javaalmanac.com/egs/javax.swing.text/style_HiliteWords2.html
    :
    : If I recall correctly, the J2SE SDK comes with a rich text editor sample that has all this.
    :
    : ---------------------------------
    : [size=1](Its just my sig)
    : HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]
    :
    :
    You could also check out the javax.swing.text.Document interface. It (and the classes which implement it) can be used to subdivide a text into pieces and set the text attributes of each piece.
  • : : :
    : : : : If this is AWT, you'll have to switch to another UI kit (Swing or SWT). Swing is included in the core API, so thats probably best.
    : : : :
    : : : : Have a look at JEditorPane and its subclasses.
    : : : : http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JEditorPane.html
    : : : :
    : : :
    : : : Thanks for the reply.I am using Swing.I've had a look at JEditorPane but i don't see how exactly i can use it to handle a specific piece of text
    : : :
    : :
    : : The class has getSelectionStart and getSelectionEnd methods.
    : :
    : : You use the component's model to alter the data structure (in this case, the underlying Document that holds the data).
    : :
    : : Example of how to set style info:
    : : http://javaalmanac.com/egs/javax.swing.text/style_HiliteWords2.html
    : :
    : : If I recall correctly, the J2SE SDK comes with a rich text editor sample that has all this.
    : :
    : : ---------------------------------
    : : [size=1](Its just my sig)
    : : HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]
    : :
    : :
    : You could also check out the javax.swing.text.Document interface. It (and the classes which implement it) can be used to subdivide a text into pieces and set the text attributes of each piece.
    :

    ================================================================

    Thanks for the replies i have managed to break up my TextPane to handle different pieces of text and to get selected text etc.But is there a way to set the Font of this text.I have a string when i get the text so is there anyway to set the Font of a string.Thanks again
  • : : : :
    : : : : : If this is AWT, you'll have to switch to another UI kit (Swing or SWT). Swing is included in the core API, so thats probably best.
    : : : : :
    : : : : : Have a look at JEditorPane and its subclasses.
    : : : : : http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JEditorPane.html
    : : : : :
    : : : :
    : : : : Thanks for the reply.I am using Swing.I've had a look at JEditorPane but i don't see how exactly i can use it to handle a specific piece of text
    : : : :
    : : :
    : : : The class has getSelectionStart and getSelectionEnd methods.
    : : :
    : : : You use the component's model to alter the data structure (in this case, the underlying Document that holds the data).
    : : :
    : : : Example of how to set style info:
    : : : http://javaalmanac.com/egs/javax.swing.text/style_HiliteWords2.html
    : : :
    : : : If I recall correctly, the J2SE SDK comes with a rich text editor sample that has all this.
    : : :
    : : : ---------------------------------
    : : : [size=1](Its just my sig)
    : : : HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]
    : : :
    : : :
    : : You could also check out the javax.swing.text.Document interface. It (and the classes which implement it) can be used to subdivide a text into pieces and set the text attributes of each piece.
    : :
    :
    : ================================================================
    :
    : Thanks for the replies i have managed to break up my TextPane to handle different pieces of text and to get selected text etc.But is there a way to set the Font of this text.I have a string when i get the text so is there anyway to set the Font of a string.Thanks again
    :
    The Font of a string has only meaning on a Graphics object and not in the memory. Font information must either be embedded into the text (as is done with HTML) or included as extra information linked to the string.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories