search.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0){
find fi = new find(txt.getText(), this);// 이 부분
fi.setSize(500,100);
fi.setVisible(true);
}
});
}
}
static public class find extends JFrame{
JButton sea = new JButton("찾기");
TextField txt = new TextField(10);
int first = 0;
int last = 0;
find(String btxt, MyGUI main){
setTitle("찾기");
setLayout(new FlowLayout());
this.add(txt);
this.add(sea);
sea.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0){
first = btxt.indexOf(txt.getText());
last = first+txt.getText().length();
System.out.println(first);
System.out.println(last);
main.txt.requestFocus();
main.txt.select(first, last);
}
});
}
}
public static void main(String[] args){
MyGUI start = new MyGUI();
start.setSize(700,500);
start.setVisible(true);
}
}
어떻게해야 MyGUI 클래스 정보를 find 클래스로 넘겨줄 수 있는 지좀 알려주면 감사하겠습니다...
댓글 0