Re[5]: Опять клваиатура...
От: Lucker Беларусь http://lucker.intervelopers.com/
Дата: 23.03.04 11:44
Оценка: 3 (1)
А>Это 100% но тогда нельзя будет скопировать информацию с TextArea
/*
 * $Id$
 * User: lucker
 * Created: 23.03.2004 12:45:26
 */

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestRusKeys extends JFrame {
    private JTextArea jt1;

    JScrollPane jsp;
    JPanel jp;

    public TestRusKeys() {
        jt1 = new JTextArea(10, 15);
        jt1.setEditable(false);

        setRootPane(createMyRootPane());
        jp = new JPanel();
        jp.add(new JScrollPane(jt1));
        getContentPane().add(jp);
        getContentPane().setFocusable(true);
    }

    private JRootPane createMyRootPane() {
        JRootPane rootPane = new JRootPane();
        for (char ch = 'а'; ch <= 'я'; ch++) {
            final char c = ch;
            ActionListener actionListener = new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    jt1.append("" +c);
                }
            } ;

            rootPane.registerKeyboardAction(actionListener, KeyStroke.getKeyStroke(ch), JComponent.WHEN_IN_FOCUSED_WINDOW);
            jt1.registerKeyboardAction(actionListener, KeyStroke.getKeyStroke(ch), JComponent.WHEN_FOCUSED);
        }
        return rootPane;
    }
    public static void main(String[] args) {
        TestRusKeys frame = new TestRusKeys();
        frame.setBounds(200, 200, 200, 300);
        frame.show();
    }

}



Но все это не правильно, как-то...
ICQ# 333355130
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.