List of usage examples for javax.swing JTextField viewToModel
@Deprecated(since = "9") public int viewToModel(Point pt)
From source file:org.yccheok.jstock.gui.NewBuyTransactionJDialog.java
private MouseListener getJFormattedTextFieldMouseListener() { MouseListener ml = new MouseAdapter() { @Override//w w w .jav a2s .com public void mousePressed(final MouseEvent e) { if (e.getClickCount() == 2) { // Ignore double click. return; } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JTextField tf = (JTextField) e.getSource(); int offset = tf.viewToModel(e.getPoint()); tf.setCaretPosition(offset); } }); } }; return ml; }