写一个类QuotationMarkDocument:
public class QuotationMarkDocument extends PlainDocument
{ public void insertString(int index, String s, AttributeSet a)
throws BadLocationException
{
String newStr = s.replace('\'','\"'); super.insertString(index, newStr, a);
}
}example:
JTextField text = new JTextField();
text.setDocument(new QuotationMarkDocument());
public class QuotationMarkDocument extends PlainDocument
{ public void insertString(int index, String s, AttributeSet a)
throws BadLocationException
{
String newStr = s.replace('\'','\"'); super.insertString(index, newStr, a);
}
}example:
JTextField text = new JTextField();
text.setDocument(new QuotationMarkDocument());
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货