[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cp-patches]: Patch: JPasswordField
From: |
Lillian Angel |
Subject: |
Re: [cp-patches]: Patch: JPasswordField |
Date: |
Wed, 24 Aug 2005 13:10:00 -0400 |
>
> Are you sure you want to return the empty string if there is a
> BadLocationException thrown from the underlying code? It looks like that
> might hide problems with the Document (sub) class implementation. Better
> would be to chain it in a InternalError() and throw that since it seems
> that BadLocationException should never be thrown when getText() is
> called like this.
I handled this the same way JTextComponent does.
/**
* Retrieves the current text in this text document.
*
* @return the text
*
* @exception NullPointerException if the underlaying document is null
*/
public String getText()
{
if (doc == null)
return null;
try
{
return doc.getText(0, doc.getLength());
}
catch (BadLocationException e)
{
// This should never happen.
return "";
}
}
I think it makes most sense to return an empty string.
Lillian