本文整理汇总了Java中javax.swing.JPasswordField.isEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java JPasswordField.isEnabled方法的具体用法?Java JPasswordField.isEnabled怎么用?Java JPasswordField.isEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JPasswordField
的用法示例。
在下文中一共展示了JPasswordField.isEnabled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawUnselectedText
import javax.swing.JPasswordField; //导入方法依赖的package包/类
/**
* 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().
*
* @param g the graphics context
* @param x the starting X coordinate >= 0
* @param y the starting Y coordinate >= 0
* @param p0 the starting offset in the model >= 0
* @param p1 the ending offset in the model >= p0
* @return the X location of the end of the range >= 0
* @exception BadLocationException if p0 or p1 are out of range
*/
protected int drawUnselectedText(Graphics g, int x, int y,
int p0, int p1) throws BadLocationException {
Container c = getContainer();
if (c instanceof JPasswordField) {
JPasswordField f = (JPasswordField) c;
if (! f.echoCharIsSet()) {
return super.drawUnselectedText(g, x, y, p0, p1);
}
if (f.isEnabled()) {
g.setColor(f.getForeground());
}
else {
g.setColor(f.getDisabledTextColor());
}
char echoChar = f.getEchoChar();
int n = p1 - p0;
for (int i = 0; i < n; i++) {
x = drawEchoCharacter(g, x, y, echoChar);
}
}
return x;
}
示例2: drawUnselectedTextImpl
import javax.swing.JPasswordField; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private float drawUnselectedTextImpl(Graphics g, float x, float y,
int p0, int p1,
boolean useFPAPI)
throws BadLocationException
{
Container c = getContainer();
if (c instanceof JPasswordField) {
JPasswordField f = (JPasswordField) c;
if (!f.echoCharIsSet()) {
boolean useDrawUnselectedFPAPI = useFPAPI
&& drawUnselectedTextOverridden
&& g instanceof Graphics2D;
return (useDrawUnselectedFPAPI )
? super.drawUnselectedText((Graphics2D) g, x, y, p0, p1)
: super.drawUnselectedText(g, (int) x, (int) y, p0, p1);
}
if (f.isEnabled()) {
g.setColor(f.getForeground());
}
else {
g.setColor(f.getDisabledTextColor());
}
char echoChar = f.getEchoChar();
int n = p1 - p0;
boolean useEchoCharFPAPI = useFPAPI
&& drawEchoCharacterOverridden
&& g instanceof Graphics2D;
for (int i = 0; i < n; i++) {
x = (useEchoCharFPAPI)
? drawEchoCharacter((Graphics2D) g, x, y, echoChar)
: drawEchoCharacter(g, (int) x, (int) y, echoChar);
}
}
return x;
}