Results 1 to 7 of 7
- 03-18-2011, 05:15 AM #1
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
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?
- 03-18-2011, 05:22 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,540
- Rep Power
- 11
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)
- 03-18-2011, 05:26 AM #3
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
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.
- 03-18-2011, 05:27 AM #4
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!
- 03-18-2011, 05:27 AM #5
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,540
- Rep Power
- 11
Unless it spoils things also have a look at Swing Chapter 20. (Advanced topics) Constructing a Word Processor from javafaq.nu
- 03-18-2011, 05:38 AM #6
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
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.
- 03-18-2011, 05:42 AM #7
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,540
- Rep Power
- 11
Similar Threads
-
Linked list help!! Notepad Program.
By needHelp12345 in forum New To JavaReplies: 0Last Post: 02-26-2011, 04:56 PM -
Notepad program
By sridevisala in forum Java SoftwareReplies: 1Last Post: 04-26-2010, 09:56 AM -
Changing text fonts and colours for specific files.
By breako in forum EclipseReplies: 0Last Post: 01-27-2010, 03:52 PM -
Changing the default fonts via UIManager
By fletcher in forum AWT / SwingReplies: 4Last Post: 09-26-2009, 06:48 PM -
Fonts (Changing Fonts and Color's)
By dbashby in forum New To JavaReplies: 10Last Post: 04-06-2009, 01:32 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks