Important: The information in this document is obsolete and should not be used for new development.
Inherits from | |
Implements | |
Package | com.apple.cocoa.application |
Companion guide |
NSTextFieldCell adds to NSCell’s text display capabilities by allowing you to set the color of both the text and its background. You can also specify whether the cell draws its background at all. All of the methods declared by this class are also declared by NSTextField, which uses NSTextFieldCells to draw and edit text.
Placeholder strings, set using setPlaceholderString
or setPlaceholderAttributedString
, now appear in the text field cell if the actual string is null
or ""
. They are drawn in grey on the cell and are not archived in the “pre-10.2” nib format.
Creates an empty NSTextFieldCell.
public NSTextFieldCell
()
Creates an NSTextFieldCell initialized with aString and set to have the cell’s default menu.
public NSTextFieldCell
(String aString)
If no field editor has been created, one is created.
Creates an NSTextFieldCell initialized with anImage and set to have the cell’s default menu.
public NSTextFieldCell
(NSImage anImage)
If anImage is null
, no image is set.
Returns the color of the background the receiver draws behind the text.
public NSColor backgroundColor
()
drawsBackground
backgroundColor
(NSTextField)setBackgroundColor
Returns the receiver’s bezel style.
public int bezelStyle
()
Possible return values are described in “Constants.”
Returns true
if the receiver’s cell draws its background color behind its text, false
if it draws no background.
public boolean drawsBackground
()
backgroundColor
drawsBackground
(NSTextField)setDrawsBackground
Returns the cell’s attributed placeholder string.
public NSAttributedString placeholderAttributedString
()
Returns the cell’s plain text placeholder string.
public String placeholderString
()
Sets the color of the background that the receiver draws behind the text to aColor.
public void setBackgroundColor
(NSColor aColor)
setDrawsBackground
setBackgroundColor
(NSTextField)backgroundColor
Sets the receiver’s bezel style to be style.
public void setBezelStyle
(int style)
Possible values for style are described in “Constants.” You must have already sent setBezeled
with an argument of true
.
Controls whether the receiver draws its background color behind its text.
public void setDrawsBackground
(boolean flag)
If flag is true
, then it does; if flag is false
, then it draws nothing behind its text.
setBackgroundColor
setDrawsBackground
(NSTextField)drawsBackground
Sets the placeholder of the cell as an attributed string.
public void setPlaceholderAttributedString
(NSAttributedString string)
Note that invoking this successfully will clear out the plain text string set by setPlaceholderString
.
Sets the placeholder of the cell as a plain text string.
public void setPlaceholderString
(String string)
Note that invoking this successfully will clear out the attributed string set by setPlaceholderAttributedString
.
Sets the color used to draw the receiver’s text to aColor.
public void setTextColor
(NSColor aColor)
setBackgroundColor
setTextColor
(NSTextField)textColor
public NSText setUpFieldEditorAttributes
(NSText textObj)
You never invoke this method directly; by overriding it, however, you can customize or replace the field editor. When you override this method, you should generally invoke the implementation of super
and return the textObj argument. For information on field editors, see “Using the Window’s Field Editor”.
Returns the color used to draw the receiver’s text.
public NSColor textColor
()
backgroundColor
textColor
(NSTextField)setTextColor
The following constants are specify the bezel style of the text field, and are set using bezelStyle
and setBezelStyle
.
Constant | Description |
---|---|
TextFieldSquareBezel | Corners are square. |
TextFieldRoundedBezel | Corners are rounded. |
© 1997, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-01)