Вопрос Проблемы с java. Swing. Подсчет слов

Регистрация
23 Дек 2013
Сообщения
93
Репутация
0
Спасибо
0
Монет
0
Я хочу, чтобы при нажатии на кнопку в поле выводилось обще количество слов. Постоянно выходит единица
JTextField textField = new JTextField();
textField.setBounds(900, 193, 60, 50);
add(textField);
JTextArea txt = new JTextArea();
txt.setBounds(32, 167, 700, 550);
txt.setLineWrap(true);
txt.setFont(font2);
add(txt);
JLabel grk = new JLabel("Tne number of grammar constructions : ");
grk.setFont(font4);
grk.setBounds(800,201,355,180);
add(grk);
JLabel ps = new JLabel("Present Simple constructions : ");
ps.setFont(font3);
ps.setBounds(800,270,290,150);
add(ps);
JTextField psi = new JTextField();
psi.setBounds(900,359,60,50);
add(psi);
JLabel pp = new JLabel("Present Perfect constructions : ");
pp.setFont(font3);
pp.setBounds(800,380,290,150);
add(pp);
JTextField ppe = new JTextField();
ppe.setBounds(900,463,60,50);
add(ppe);
String s = txt.getText();
String [] TAR = s.split(String.valueOf(new char[]{}));
int tl;
tl = TAR.length;
String.valueOf(tl);
x.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
textField.setText(String.valueOf(tl));
}
});
 
Назад
Сверху