APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing.text

public Class PasswordView

extends FieldView
Class Inheritance
Imports
sun.swing.SwingUtilities2, java.awt.*, java.awt.font.FontRenderContext, javax.swing.JPasswordField

Implements a View suitable for use in JPasswordField UI implementations. This is basically a field ui that renders its contents as the echo character specified in the associated component (if it can narrow the component to a JPasswordField).
Author
Timothy Prinzing
See Also
View

Field Summary

Modifier and TypeField and Description
private final boolean
pack-priv static char[]

Constructor Summary

AccessConstructor and Description
public
PasswordView(Element
the element
elem
)

Constructs a new view wrapped on an element.

Method Summary

Modifier and TypeMethod and Description
protected int

Returns:

the updated X position >= 0
drawEchoCharacter
(Graphics
the graphics context
g
,
int
the starting X coordinate >= 0
x
,
int
the starting Y coordinate >= 0
y
,
char
the echo character
c
)
Deprecated since 9. replaced by drawEchoCharacter(Graphics2D, float, float, char)

Renders the echo character, or whatever graphic should be used to display the password characters.

protected float

Returns:

the updated X position >= 0
drawEchoCharacter
(Graphics2D
the graphics context
g
,
float
the starting X coordinate >= 0
x
,
float
the starting Y coordinate >= 0
y
,
char
the echo character
c
)

Renders the echo character, or whatever graphic should be used to display the password characters.

private float
drawEchoCharacterImpl(Graphics g, float x, float y, char c, boolean useFPAPI)

protected int

Returns:

the X location of the end of the range >= 0
drawSelectedText
(Graphics
the graphics context
g
,
int
the starting X coordinate >= 0
x
,
int
the starting Y coordinate >= 0
y
,
int
the starting offset in the model >= 0
p0
,
int
the ending offset in the model >= p0
p1
)

Overrides javax.swing.text.PlainView.drawSelectedText.

Renders the given range in the model as selected text.

protected float
drawSelectedText(Graphics2D g, float x, float y, int p0, int p1)

Overrides javax.swing.text.PlainView.drawSelectedText.

Renders the given range in the model as selected text.

private float
drawSelectedTextImpl(Graphics g, float x, float y, int p0, int p1, boolean useFPAPI)

Hides javax.swing.text.PlainView.drawSelectedTextImpl.

protected int

Returns:

the X location of the end of the range >= 0
drawUnselectedText
(Graphics
the graphics context
g
,
int
the starting X coordinate >= 0
x
,
int
the starting Y coordinate >= 0
y
,
int
the starting offset in the model >= 0
p0
,
int
the ending offset in the model >= p0
p1
)

Overrides javax.swing.text.PlainView.drawUnselectedText.

Renders the given range in the model as normal unselected text.

protected float
drawUnselectedText(Graphics2D g, float x, float y, int p0, int p1)

Overrides javax.swing.text.PlainView.drawUnselectedText.

Renders the given range in the model as normal unselected text.

private float
drawUnselectedTextImpl(Graphics g, float x, float y, int p0, int p1, boolean useFPAPI)

Hides javax.swing.text.PlainView.drawUnselectedTextImpl.

public float

Returns:

the span the view would like to be rendered into >= 0. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.
getPreferredSpan
(int
may be either View.X_AXIS or View.Y_AXIS
axis
)

Overrides javax.swing.text.FieldView.getPreferredSpan.

Determines the preferred span for this view along an axis.

public Shape

Returns:

the bounding box of the given position
modelToView
(int
the position to convert >= 0
pos
,
Shape
the allocated region to render into
a
,
Position.Bias b)

Overrides javax.swing.text.FieldView.modelToView.

Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.

public int

Returns:

the location within the model that best represents the given point in the view
viewToModel
(float
the X coordinate >= 0.0f
fx
,
float
the Y coordinate >= 0.0f
fy
,
Shape
the allocated region to render into
a
,
Position.Bias[] bias)

Overrides javax.swing.text.FieldView.viewToModel.

Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Inherited from javax.swing.text.FieldView:
adjustAllocationadjustPaintRegiongetFontMetricsgetResizeWeightinsertUpdatepaintremoveUpdateupdateVisibilityModel

Field Detail

drawEchoCharacterOverriddenback to summary
private final boolean drawEchoCharacterOverridden
ONEback to summary
pack-priv static char[] ONE

Constructor Detail

PasswordViewback to summary
public PasswordView(Element elem)

Constructs a new view wrapped on an element.

Parameters
elem:Element

the element

Method Detail

drawEchoCharacterback to summary
protected int drawEchoCharacter(Graphics g, int x, int y, char c)

Renders the echo character, or whatever graphic should be used to display the password characters. The color in the Graphics object is set to the appropriate foreground color for selected or unselected text.

Parameters
g:Graphics

the graphics context

x:int

the starting X coordinate >= 0

y:int

the starting Y coordinate >= 0

c:char

the echo character

Returns:int

the updated X position >= 0

Annotations
@Deprecated
since:9
drawEchoCharacterback to summary
protected float drawEchoCharacter(Graphics2D g, float x, float y, char c)

Renders the echo character, or whatever graphic should be used to display the password characters. The color in the Graphics object is set to the appropriate foreground color for selected or unselected text.

Parameters
g:Graphics2D

the graphics context

x:float

the starting X coordinate >= 0

y:float

the starting Y coordinate >= 0

c:char

the echo character

Returns:float

the updated X position >= 0

Since
9
drawEchoCharacterImplback to summary
private float drawEchoCharacterImpl(Graphics g, float x, float y, char c, boolean useFPAPI)
drawSelectedTextback to summary
protected int drawSelectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException

Overrides javax.swing.text.PlainView.drawSelectedText.

Renders the given range in the model as selected text. This is implemented to render the text in the color specified in the hosting component. It assumes the highlighter will render the selected background. Uses the result of getEchoChar() to display the characters.

Parameters
g:Graphics

the graphics context

x:int

the starting X coordinate >= 0

y:int

the starting Y coordinate >= 0

p0:int

the starting offset in the model >= 0

p1:int

the ending offset in the model >= p0

Returns:int

the X location of the end of the range >= 0

Annotations
@Deprecated
since:9
@Override
Exceptions
BadLocationException:
if p0 or p1 are out of range
drawSelectedTextback to summary
protected float drawSelectedText(Graphics2D g, float x, float y, int p0, int p1) throws BadLocationException

Overrides javax.swing.text.PlainView.drawSelectedText.

Doc from javax.swing.text.PlainView.drawSelectedText.

Renders the given range in the model as selected text. This is implemented to render the text in the color specified in the hosting component. It assumes the highlighter will render the selected background.

Annotations
@Override
Exceptions
BadLocationException:
if the range is invalid
drawSelectedTextImplback to summary
private float drawSelectedTextImpl(Graphics g, float x, float y, int p0, int p1, boolean useFPAPI) throws BadLocationException

Hides javax.swing.text.PlainView.drawSelectedTextImpl.

Annotations
@SuppressWarnings:deprecation
drawUnselectedTextback to summary
protected int drawUnselectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException

Overrides javax.swing.text.PlainView.drawUnselectedText.

Renders the given range in the model as normal unselected text. This sets the foreground color and echos the characters using the value returned by getEchoChar().

Parameters
g:Graphics

the graphics context

x:int

the starting X coordinate >= 0

y:int

the starting Y coordinate >= 0

p0:int

the starting offset in the model >= 0

p1:int

the ending offset in the model >= p0

Returns:int

the X location of the end of the range >= 0

Annotations
@Deprecated
since:9
@Override
Exceptions
BadLocationException:
if p0 or p1 are out of range
drawUnselectedTextback to summary
protected float drawUnselectedText(Graphics2D g, float x, float y, int p0, int p1) throws BadLocationException

Overrides javax.swing.text.PlainView.drawUnselectedText.

Doc from javax.swing.text.PlainView.drawUnselectedText.

Renders the given range in the model as normal unselected text. Uses the foreground or disabled color to render the text.

Annotations
@Override
Exceptions
BadLocationException:
if the range is invalid
drawUnselectedTextImplback to summary
private float drawUnselectedTextImpl(Graphics g, float x, float y, int p0, int p1, boolean useFPAPI) throws BadLocationException

Hides javax.swing.text.PlainView.drawUnselectedTextImpl.

Annotations
@SuppressWarnings:deprecation
getPreferredSpanback to summary
public float getPreferredSpan(int axis)

Overrides javax.swing.text.FieldView.getPreferredSpan.

Determines the preferred span for this view along an axis.

Parameters
axis:int

may be either View.X_AXIS or View.Y_AXIS

Returns:float

the span the view would like to be rendered into >= 0. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.

modelToViewback to summary
public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException

Overrides javax.swing.text.FieldView.modelToView.

Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.

Parameters
pos:int

the position to convert >= 0

a:Shape

the allocated region to render into

Returns:Shape

the bounding box of the given position

Exceptions
BadLocationException:
if the given position does not represent a valid location in the associated document
See Also
View#modelToView
viewToModelback to summary
public int viewToModel(float fx, float fy, Shape a, Position.Bias[] bias)

Overrides javax.swing.text.FieldView.viewToModel.

Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Parameters
fx:float

the X coordinate >= 0.0f

fy:float

the Y coordinate >= 0.0f

a:Shape

the allocated region to render into

Returns:int

the location within the model that best represents the given point in the view

See Also
View#viewToModel