When a JTextField gets the focus by calling "aJTextField.requestFocus()", why is the Caret invisible even after I do "aJTextField.getCaret().setVisible(true);"? How to show the caret in this case?

Sandip Chitale

You have to call requestFocus() on the Swing thread. To do that do the following -


SwingUtilities.invokeLater(
  new Runnable() {
    public void run() {
      aJTextField.requestFocus();
      aJTextField.getCaret().setVisible(true);
    }
  }
);

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact