如何禁用选择 textfield 的所有亮点。
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.JTextField;
public class CustomFocusListener implements FocusListener {
JTextField jtextField;
public CustomFocusListener(JTextField jtextField) {
this.jtextField = jtextField;
}
@Override
public void focusGained(FocusEvent e) {
jtextField.selectAll();
}
@Override
public void focusLost(FocusEvent e) {
jtextField.getHighlighter().removeAllHighlights();
}
}
当前代码也只是隐藏了内容......有人帮忙吗?