Results 1 to 7 of 7
  1. #1
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default Changing fonts in notepad type program

    I have designed a notepad program which is fairly basic atm(allows for saving, opening, deleting, and setting color, size, and style of some font.)

    I am trying to allow the program to let me change the font type without altering previously written text in the textArea. I got it to work but it sets all text to the new font, not just any font typed after the change.

    Any advice? I have some thoughts which are a bit hard to explain, and don't really work.

    While I have a thread open, I'd also like to ask if there is a way to set one font to have multiple styles(bold, and italics for instance), or are there ways to add underlines, strike through in the text?

    One last thing, is there any way to extract all the fonts on a given system?

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Have a read of the JTextArea API documentation. The whole introductory section is worth reading, even beyond the first sentence: "A JTextArea is a multi-line area that displays plain text."

    It looks like you are after a JEditorPane/JTextPane. See the section on Using Text Components in Oracle's Tutorial. (and the links and examples therein)

  3. #3
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Thanks a ton, I haven't read all of the java tutorials yet and a lot of my learning has been through books and I have not gotten into these things. Now that I know what I am looking for I can hopefully easily research and implement it. I appreciate the quick response.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default

    Could you please give us some useful information? Your post doesn't even hint at what Java component you have used for the editor, not even to tell us what toolkit (AWT, Swing, SWT...) it is from.

    If this is Swing, go through Using Text Components (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

    db

    edit Too late!

  5. #5
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Unless it spoils things also have a look at Swing Chapter 20. (Advanced topics) Constructing a Word Processor from javafaq.nu

  6. #6
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Im sorry for being vague(especially since I usually explain to people that detailed explanation is needed), my original design used a text area.

    Thanks for the link pbrockway, I will have to save that link for comparisons to see how I can improve my editor later.

  7. #7
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    You're welcome. I remembered having looked at that code/text years ago and thinking that it did a good job of explaining things.

Similar Threads

  1. Linked list help!! Notepad Program.
    By needHelp12345 in forum New To Java
    Replies: 0
    Last Post: 02-26-2011, 04:56 PM
  2. Notepad program
    By sridevisala in forum Java Software
    Replies: 1
    Last Post: 04-26-2010, 09:56 AM
  3. Replies: 0
    Last Post: 01-27-2010, 03:52 PM
  4. Changing the default fonts via UIManager
    By fletcher in forum AWT / Swing
    Replies: 4
    Last Post: 09-26-2009, 06:48 PM
  5. Fonts (Changing Fonts and Color's)
    By dbashby in forum New To Java
    Replies: 10
    Last Post: 04-06-2009, 01:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •