本文整理匯總了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;
}