急!!!!高手解释下代码

来源:百度知道 编辑:UC知道 时间:2024/06/03 17:20:33
private void jMenuItem12ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//查找.....
//
JFrame find = new JFrame("查找");
JLabel label = new JLabel("请输入查找的字符串");
final JTextField text = new JTextField(10);
JButton button = new JButton("查找");
find.setLayout(new FlowLayout());
find.add(label);
find.add(text);
find.add(button);
find.setSize(300,90);
find.setLocation(300,200);
find.setVisible(true);
find.setResizable(false);
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{

int indexOf(String str, int fromIndex)
从指定的索引处开始,返回第一次出现的指定子字符串在此字符串中的索引。
jdk找的资料。你不是查找么?从mark这个位置开始,查找src所在的位置
jTextArea1.setSelectionStart(start);
这个是设置选中起点吧,上面的start设置
jTextArea1.setSelectionEnd(start+src.length());
设置结束位置
也就是选中 查到的字符串src