How can I set text to JTextField when I click off from the component? Whenever I click it, it will clear the text like this:
// Clears the "Enter text here..." when clicked
commandLine.addMouseListener(new MouseAdapter(){
@Override
public void mouseClicked(MouseEvent e){
commandLine.setText("");
}
});
But, when I click off the textfield, how can I reset it? I tried FocusEvent but it did not work as I wanted.