我每次点击它时都试图删除JTextField的文本。我做了一个addFocusListene
但是没有出现任何消息。我不明白为什么
nick = new JTextField("nick", 5);
add(nick);
nick.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
nick.setText("");
}
public void focusLost(FocusEvent e) {
// nothing
}
});
JLabel texto = new JLabel("CLIENTE");
add(texto);
ip = new JTextField("Introduce la IP del destinatario", 16);
add(ip);
ip.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
ip.setText("");
}
public void focusLost(FocusEvent e) {
// nothing
}
});