50 |
* class JPasswordField |
* class JPasswordField |
51 |
* |
* |
52 |
* @author Andrew Selkirk |
* @author Andrew Selkirk |
53 |
|
* @author Lillian Angel |
54 |
* @version 1.0 |
* @version 1.0 |
55 |
*/ |
*/ |
56 |
public class JPasswordField extends JTextField |
public class JPasswordField extends JTextField |
179 |
} |
} |
180 |
|
|
181 |
/** |
/** |
182 |
* echoCharIsSet |
* Returns true if this JPasswordField has a character set for echoing. |
183 |
|
* A character is considered to be set if the echo character is not 0. |
184 |
* |
* |
185 |
* @return <code>true</code> if the echo char is set, |
* @return <code>true</code> if the echo char is set, |
186 |
* <code>false</code> otherwise. |
* <code>false</code> otherwise. |
187 |
*/ |
*/ |
188 |
public boolean echoCharIsSet() |
public boolean echoCharIsSet() |
189 |
{ |
{ |
190 |
return echoChar == 0; |
return echoChar != 0; |
191 |
} |
} |
192 |
|
|
193 |
/** |
/** |
209 |
} |
} |
210 |
|
|
211 |
/** |
/** |
212 |
* getText |
* Returns the text contained in this TextComponent. If the |
213 |
|
* underlying document is null, will give a NullPointerException. |
214 |
* |
* |
215 |
* @return String |
* @return String |
216 |
* |
* |
218 |
*/ |
*/ |
219 |
public String getText() |
public String getText() |
220 |
{ |
{ |
221 |
return null; // TODO |
try |
222 |
|
{ |
223 |
|
return getDocument().getText(0, getDocument().getLength()); |
224 |
|
} |
225 |
|
catch (BadLocationException ble) |
226 |
|
{ |
227 |
|
// This should never happen. |
228 |
|
throw new AssertionError(ble); |
229 |
|
} |
230 |
} |
} |
231 |
|
|
232 |
/** |
/** |
233 |
* getText |
* Fetches a portion of the text represented by the component. |
234 |
|
* Returns an empty string if length is 0. If the |
235 |
|
* underlying document is null, will give a NullPointerException. |
236 |
* |
* |
237 |
* @param offset TODO |
* @param offset TODO |
238 |
* @param length TODO |
* @param length TODO |
245 |
*/ |
*/ |
246 |
public String getText(int offset, int length) throws BadLocationException |
public String getText(int offset, int length) throws BadLocationException |
247 |
{ |
{ |
248 |
return null; // TODO |
return getDocument().getText(offset, length); |
249 |
} |
} |
250 |
|
|
251 |
/** |
/** |
252 |
* getPassword |
* Returns the text contained in this TextComponent. If the underlying |
253 |
|
* document is null, will give a NullPointerException. |
254 |
|
* For stronger security, it is recommended that the returned character |
255 |
|
* array be cleared after use by setting each character to zero. |
256 |
* |
* |
257 |
* @return char[] |
* @return char[] |
258 |
*/ |
*/ |
259 |
public char[] getPassword() |
public char[] getPassword() |
260 |
{ |
{ |
261 |
return new char[0]; // TODO |
return getText().toCharArray(); |
262 |
} |
} |
263 |
|
|
264 |
/** |
/** |
265 |
* paramString |
* Returns a string representation of this JPasswordField. This method is |
266 |
|
* intended to be used only for debugging purposes, |
267 |
|
* and the content and format of the returned string may vary between |
268 |
|
* implementations. The returned string may be empty but may not be null. |
269 |
* |
* |
270 |
* @return String |
* @return String |
271 |
*/ |
*/ |
272 |
protected String paramString() |
protected String paramString() |
273 |
{ |
{ |
274 |
return null; // TODO |
try |
275 |
|
{ |
276 |
|
return getText(); |
277 |
|
} |
278 |
|
catch (NullPointerException npe) |
279 |
|
{ |
280 |
|
return ""; |
281 |
|
} |
282 |
} |
} |
283 |
|
|
284 |
/** |
/** |