应该说光标比较确切.
addCaretListener(CaretListener listener)
你应会用接口的吧.
addCaretListener(CaretListener listener)
你应会用接口的吧.
解决方案 »
- JFrame和Frame有何区别,在线等
- 请教一个面试问题
- 关于一段多线程的代码,请教大家。。。。
- 用javamail写了个群发邮件的程序,问题是如果一个收件地址错误,全部邮件都发不出去!?求解决办法
- 请问如何在String libraryPath=System.getProperty("java.library.path")中。。。
- 求主JFrame中多个JInternalFrame共存解决方案!!
- 用java解析csv文件遇到的问题
- applet能向所属的服务器写数据吗?能在它和其服务器之间建立某种信用关系,来达到写数据的功能吗?
- 如何用java程序实现keytool的功能?
- 用javase如何通过id查询整个信息?
- 现在有机会给motorola A6288开发K-Java程序了~~~~
- 各位大侠救命啊,半个多月的心血不见了----Visual age
请给个简单的完整的例子
请给个简单的完整的例子
CaretListenerLabel caretListenerLabel =
new CaretListenerLabel("Caret Status");
...
text.addActionListener(caretListenerLabel);
...
protected class CaretListenerLabel extends JLabel
implements CaretListener
{
...
public void caretUpdate(CaretEvent e) {
//Get the location in the text
int dot = e.getDot();
int = e.getMark();
...
}
}
-----------------------
The CaretEvent class defines two useful methods: int getDot()
Returns the current location of the caret. If text is selected, the caret s one end of the selection.
int getMark()
Returns the other end of the selection. If nothing is selected, the value returned by this method is equal to the value returned by getDot. Note that the dot is not guaranteed to be less than the .