本文整理了Java中javax.swing.JTextField.modelToView()
方法的一些代码示例,展示了JTextField.modelToView()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextField.modelToView()
方法的具体详情如下:
包路径:javax.swing.JTextField
类名称:JTextField
方法名:modelToView
暂无
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
public void run() {
Rectangle rect = null;
try {
rect = _txt.modelToView(_txt.getText().length());
} catch (final BadLocationException e) {
FuLog.warning(e);
}
if (rect != null) {
_txt.scrollRectToVisible(rect);
}
}
};
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
public void setFile(final File _f) {
if (_f == null) {
return;
}
tf_.setText(_f.getAbsolutePath());
try {
final Rectangle rect = tf_.modelToView(tf_.getText().length());
if (rect != null) {
tf_.scrollRectToVisible(rect);
}
} catch (final BadLocationException _e) {
FuLog.error(_e);
}
}
代码示例来源:origin: stackoverflow.com
final JTextField tf = new JTextField("click here ^");
tf.addMouseListener(new MouseAdapter(){
@Override
public void mousePressed(MouseEvent e){
try{
Rectangle rect = tf.modelToView(0);//for y value
System.out.println(tf.viewToModel(new Point(e.getX(), rect.y)));
int loc = tf.viewToModel(new Point(e.getX(), rect.y));
tf.setSelectionStart(loc);
tf.setSelectionEnd(loc);
}catch(Exception ex){}//swallow the exception for demonstration only
}
});
内容来源于网络,如有侵权,请联系作者删除!