Adding Custom Fonts to a JTextComponent
I am working on a simpler version of Microsoft's Notepad and I am suppose to give the user a choice of fonts to use. Currently I am using a JTextArea and I know how to change the font style and size using the setFont method, but I have no idea how to give the user the choice through my Font menu item. Any help would be greatly appreciated.
[349 byte] By [
jbu004a] at [2007-11-27 3:53:54]

# 1
[url http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html]How to Use Menus[/url].
For example to change the size, you write an ActionListener that get the text of the menu item (ie. the font size). Then you convert the numeric String to a Float and use the Font.deriveFont(...) method to reset the font of the text area.
For the style you would need to store the style as the action command and then convert the value as above.