PATH  Documentation > Mac OS X > Application Kit Reference: Java

Table of Contents

NSFontPanel


Inherits from:
NSPanel : NSWindow : NSResponder : NSObject
Package:
com.apple.yellow.application


Class Description


The NSFontPanel class implements the Font Panel-a user-interface object that displays a list of available fonts, letting the user preview them and change the font used to display text. The actual changes are made through conversion messages sent to the shared NSFontManager instance. There's only one Font Panel for each application.

In general, you add the facilities of the Font Panel to your application, along with the NSFontManager and the Font menu, through Interface Builder. You do this by dragging a Font menu into one of your application's menus. At run time, when the user chooses the Font Panel command for the first time, the Font Panel object is created and hooked into the font conversion system. You can also create (or access) the Font Panel using the sharedFontPanel class method.

You can add a custom view object to an NSFontPanel using setAccessoryView, or limit the fonts display by assigning a delegate to the application's font manager object. See the NSFontManager class specification for more information on using the font conversion system.

Normally, the application's Font Panel displays all the standard fonts available on the system. If this isn't appropriate for your application-for example, if only fixed-pitch fonts should be used-you can assign a delegate to the NSFontPanel object to filter the available fonts. Before the NSFontPanel adds a particular font family or face to its list, the NSFontPanel asks its delegate to confirm the addition by sending the delegate a fontManagerWillIncludeFont message. If the delegate returns true (or doesn't implement this method), the font is added. If the delegate returns false, the font isn't added.




Method Types


Constructors
NSFontPanel
Getting the Font Panel
sharedFontPanel
sharedFontPanelExists
Enabling font changes
setEnabled
isEnabled
Updating the Font Panel
setPanelFont
Converting fonts
panelConvertFont
Working in modal loops
worksWhenModal
Setting an accessory view
setAccessoryView
accessoryView


Constructors



NSFontPanel

public NSFontPanel()

Description forthcoming.

public NSFontPanel( NSRect aRect, int anInt, int anInt, boolean aBoolean)

Description forthcoming.

public NSFontPanel( NSRect aRect, int anInt, int anInt, boolean aBoolean, NSScreen aScreen)

Description forthcoming.


Static Methods



sharedFontPanel

public static NSFontPanel sharedFontPanel()

Returns the single NSFontPanel instance for the application, creating it if necessary.

See Also: sharedFontPanelExists



sharedFontPanelExists

public static boolean sharedFontPanelExists()

Returns true if the shared Font Panel has been created, false if it hasn't.

See Also: sharedFontPanel




Instance Methods



accessoryView

public NSView accessoryView()

Returns the receiver's accessory view.

See Also: setAccessoryView



isEnabled

public boolean isEnabled()

Returns true if the receiver's Set button is enabled, false if it isn't. The receiver continues to reflect the font of the selection for cooperating text objects regardless of this setting.

See Also: setEnabled



panelConvertFont

public NSFont panelConvertFont(NSFont aFont)

Converts aFont using the settings in the receiver, with the aid of the shared NSFontManager if necessary, and returns the converted font. If aFont can't be converted it's returned unchanged.

For example, if aFont is Helvetica Oblique 12.0 point and the user has selected the Times font family (and nothing else) in the Font Panel, the font returned is Times Italic 12.0 point.

See Also: convertFont (NSFontManager)



setAccessoryView

public void setAccessoryView(NSView aView)

Establishes aView as the receiver's accessory view, allowing you to add custom controls to your application's Font Panel without having to create a subclass.

See Also: accessoryView



setEnabled

public void setEnabled(boolean flag)

Controls whether the receiver's Set button is enabled. If flag is true the Set button is enabled; if flag is false it's disabled. The receiver continues to reflect the font of the selection for cooperating text objects regardless of this setting.

See Also: isEnabled



setPanelFont

public void setPanelFont( NSFont aFont, boolean flag)

Sets the selected font in the receiver to aFont if flag is false, otherwise selects no font and displays a message in the preview area indicating that multiple fonts are selected. You normally don't use this method directly; instead, you send setSelectedFont to the shared NSFontManager, which in turn invokes this method.

worksWhenModal

public boolean worksWhenModal()

Returns true, regardless of the setting established using the NSPanel method setWorksWhenModal. This allows fonts to be changed in modal windows and panels.

See Also: worksWhenModal (NSWindow), worksWhenModal (NSPanel)




Table of Contents