Package de.t68.utils.keyboard.test

Examples of de.t68.utils.keyboard.test.EventTest


    {
        keyboardTextField.setText(original.getText());
        if (popup == null)
        {
            popup = new JPopupMenu();
            KeyboardLayout layout = LanguageMap.getInstance().getKeyboardLayoutForCurrentLocale();
            VKeyboard keyboard = new VKeyboard(layout, keyFontSize, keyboardTextField);
            popup.add(keyboard);
            popup.pack();
        }
        popup.show(original, 0, 0);
View Full Code Here


        tb.setPreferredSize(new Dimension(20, 200));
        f.getContentPane().setLayout(new BorderLayout());
        f.getContentPane().add(p, BorderLayout.CENTER);
        final LanguageMap map = LanguageMap.getInstance();

        KeyboardLayout layout = map.getKeyboardLayoutForLocale("th", "TH");
        final VKeyboard v = new VKeyboard(layout, tb);
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(v.getKeyPanel(), BorderLayout.CENTER);
        final JComboBox<String> comboBox = new JComboBox<>(new Vector<>(map.keySet()));
        comboBox.setFocusable(false);
        JPanel boxPanel = new JPanel(new FlowLayout());
        boxPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 20));
        boxPanel.add(comboBox);
        panel.add(boxPanel, BorderLayout.NORTH);
        comboBox.setSelectedItem(layout.getLocaleString().get(0));
        comboBox.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e)
            {
                Object item = comboBox.getSelectedItem();
                if (item instanceof String)
                {
                    KeyboardLayout keyboardLayout = map.get(item);
                    if (keyboardLayout != null)
                        v.setKeyboardLayout(keyboardLayout);
                }
            }
        });
View Full Code Here

        JTextComponent tb = new JTextArea(10, 80);
        tb.setFont(new Font("Lucida", Font.PLAIN, 20));
        tb.setPreferredSize(new Dimension(20, 200));
        f.getContentPane().setLayout(new BorderLayout());
        f.getContentPane().add(p, BorderLayout.CENTER);
        final LanguageMap map = LanguageMap.getInstance();

        KeyboardLayout layout = map.getKeyboardLayoutForLocale("th", "TH");
        final VKeyboard v = new VKeyboard(layout, tb);
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(v.getKeyPanel(), BorderLayout.CENTER);
        final JComboBox<String> comboBox = new JComboBox<>(new Vector<>(map.keySet()));
        comboBox.setFocusable(false);
        JPanel boxPanel = new JPanel(new FlowLayout());
        boxPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 20));
        boxPanel.add(comboBox);
        panel.add(boxPanel, BorderLayout.NORTH);
        comboBox.setSelectedItem(layout.getLocaleString().get(0));
        comboBox.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e)
            {
                Object item = comboBox.getSelectedItem();
                if (item instanceof String)
                {
                    KeyboardLayout keyboardLayout = map.get(item);
                    if (keyboardLayout != null)
                        v.setKeyboardLayout(keyboardLayout);
                }
            }
        });
View Full Code Here

        keyboardTextField.setText(original.getText());
        if (popup == null)
        {
            popup = new JPopupMenu();
            KeyboardLayout layout = LanguageMap.getInstance().getKeyboardLayoutForCurrentLocale();
            VKeyboard keyboard = new VKeyboard(layout, keyFontSize, keyboardTextField);
            popup.add(keyboard);
            popup.pack();
        }
        popup.show(original, 0, 0);
    }
View Full Code Here

        f.getContentPane().setLayout(new BorderLayout());
        f.getContentPane().add(p, BorderLayout.CENTER);
        final LanguageMap map = LanguageMap.getInstance();

        KeyboardLayout layout = map.getKeyboardLayoutForLocale("th", "TH");
        final VKeyboard v = new VKeyboard(layout, tb);
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(v.getKeyPanel(), BorderLayout.CENTER);
        final JComboBox<String> comboBox = new JComboBox<>(new Vector<>(map.keySet()));
        comboBox.setFocusable(false);
        JPanel boxPanel = new JPanel(new FlowLayout());
        boxPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 20));
        boxPanel.add(comboBox);
        panel.add(boxPanel, BorderLayout.NORTH);
        comboBox.setSelectedItem(layout.getLocaleString().get(0));
        comboBox.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e)
            {
                Object item = comboBox.getSelectedItem();
                if (item instanceof String)
                {
                    KeyboardLayout keyboardLayout = map.get(item);
                    if (keyboardLayout != null)
                        v.setKeyboardLayout(keyboardLayout);
                }
            }
        });
        p.add(tb, BorderLayout.NORTH);
        p.add(panel, BorderLayout.CENTER);
View Full Code Here

                JPanel panel = new JPanel(new GridLayout(2, 1));
                for (int k = 0; k < 2; k++)
                {
                    final JTextField tf = new JTextField(20);
                    tf.setFont(getFont().deriveFont(20f));
                    tf.addMouseListener(new VisualTextFieldAdapter(tf, panel));
                    tf.addFocusListener(new FocusListener() {

                        @Override
                        public void focusGained(FocusEvent e)
                        {
View Full Code Here

    @Override
    public AbstractButton getComponent(VirtualKeyListener vkListener, final VKeyboard keyboard)
    {
        AbstractButton button;
        KeyboardButton kButton = null;
        ToggleKeyboardButton toggleButton = null;
        switch (key.toLowerCase())
        {
            case CAPSLOCK: // Caps Look
                toggleButton = new ToggleKeyboardButton(fontName, keyFontSize, getKeyCode(), getKeyChar());
                toggleButton.setIcon(new Capslock(32, 32));
                toggleButton.addVirtualKeyListener(vkListener);
                button = toggleButton;
                break;
            case ALT: // alt
                toggleButton = new ToggleKeyboardButton(fontName, keyFontSize, getKeyCode(), getKeyChar());
                toggleButton.setText(textToShow);
                toggleButton.addVirtualKeyListener(vkListener);
                button = toggleButton;
                if (keyboard.getAltModel() == null)
                    keyboard.setAltModel(button.getModel());
                else
                    button.setModel(keyboard.getAltModel());
                break;
            case ALTGR: // Alt-Gr
                toggleButton = new ToggleKeyboardButton(fontName, keyFontSize, getKeyCode(), getKeyChar());
                toggleButton.setText(textToShow);
                toggleButton.addVirtualKeyListener(vkListener);
                button = toggleButton;
                if (keyboard.getAltgrModel() == null)
                    keyboard.setAltgrModel(button.getModel());
                else
                    button.setModel(keyboard.getAltgrModel());
                break;
            case SHIFT: // left shift
                toggleButton = new ToggleKeyboardButton(fontName, keyFontSize, getKeyCode(), getKeyChar());
                toggleButton.setIcon(new Shift(32, 32));
                toggleButton.addVirtualKeyListener(vkListener);
                button = toggleButton;
                if (keyboard.getShiftModel() == null)
                    keyboard.setShiftModel(button.getModel());
                else
                    button.setModel(keyboard.getShiftModel());
                break;
            case IME: // only IME Mode
                JToggleButton imeButton = new JToggleButton();
                imeButton.setText(textToShow);
                imeButton.setFont(new Font(fontName, Font.PLAIN, keyFontSize));
                imeButton.addItemListener(new SelectKeyboardLayout(keyboard));
                button = imeButton;
                break;
            case BACKSPACE:
                kButton = new KeyboardButton(fontName, keyFontSize, getKeyCode(), getKeyChar());
                kButton.setIcon(new Backspace(32, 32));
                kButton.addVirtualKeyListener(vkListener);
                button = kButton;
                break;
            case ENTER: // Enter
                kButton = new KeyboardButton(fontName, keyFontSize, getKeyCode(), getKeyChar());
                kButton.setIcon(new Enter(32, 32));
                kButton.addVirtualKeyListener(vkListener);
                button = kButton;
                break;
            case LEFT: // left
                kButton = new KeyboardButton(fontName, keyFontSize, getKeyCode(), getKeyChar());
                kButton.setIcon(new Left(32, 32));
                kButton.addVirtualKeyListener(vkListener);
                button = kButton;
                break;
            case RIGHT: // right
                kButton = new KeyboardButton(fontName, keyFontSize, getKeyCode(), getKeyChar());
                kButton.setIcon(new Right(32, 32));
                kButton.addVirtualKeyListener(vkListener);
                button = kButton;
                break;
            case TAB:
                kButton = new KeyboardButton(fontName, keyFontSize, getKeyCode(), getKeyChar());
                kButton.setIcon(new Tab(32, 32));
                kButton.addVirtualKeyListener(vkListener);
                button = kButton;
                break;
            // All other special keys re
            default:
                kButton = new KeyboardButton(fontName, keyFontSize, getKeyCode(), getKeyChar());
                kButton.setText(textToShow);
                kButton.addVirtualKeyListener(vkListener);
                button = kButton;
                break;
        }
        return button;
    }
View Full Code Here

     *            the {@link VKeyboard}, manages some necessary data for the button creation
     * @return a new {@link KeyboardButton}
     */
    public AbstractButton getComponent(VirtualKeyListener vkListener, VKeyboard keyboard)
    {
        keyboardButton = new KeyboardButton(fontName, keyFontSize, normalKey, shiftKey, altKey, altshiftKey,
                VirtualKeyEvent.stringToKeyCode(normalKey), normalKey.toCharArray()[0]);
        keyboardButton.addVirtualKeyListener(vkListener);
        return keyboardButton;
    }
View Full Code Here

    @Override
    public AbstractButton getComponent(VirtualKeyListener vkListener, final VKeyboard keyboard)
    {
        AbstractButton button;
        KeyboardButton kButton = null;
        ToggleKeyboardButton toggleButton = null;
        switch (key.toLowerCase())
        {
            case CAPSLOCK: // Caps Look
                toggleButton = new ToggleKeyboardButton(fontName, keyFontSize, getKeyCode(), getKeyChar());
                toggleButton.setIcon(new Capslock(32, 32));
                toggleButton.addVirtualKeyListener(vkListener);
                button = toggleButton;
                break;
            case ALT: // alt
                toggleButton = new ToggleKeyboardButton(fontName, keyFontSize, getKeyCode(), getKeyChar());
                toggleButton.setText(textToShow);
                toggleButton.addVirtualKeyListener(vkListener);
                button = toggleButton;
                if (keyboard.getAltModel() == null)
                    keyboard.setAltModel(button.getModel());
                else
                    button.setModel(keyboard.getAltModel());
                break;
            case ALTGR: // Alt-Gr
                toggleButton = new ToggleKeyboardButton(fontName, keyFontSize, getKeyCode(), getKeyChar());
                toggleButton.setText(textToShow);
                toggleButton.addVirtualKeyListener(vkListener);
                button = toggleButton;
                if (keyboard.getAltgrModel() == null)
                    keyboard.setAltgrModel(button.getModel());
                else
                    button.setModel(keyboard.getAltgrModel());
                break;
            case SHIFT: // left shift
                toggleButton = new ToggleKeyboardButton(fontName, keyFontSize, getKeyCode(), getKeyChar());
                toggleButton.setIcon(new Shift(32, 32));
                toggleButton.addVirtualKeyListener(vkListener);
                button = toggleButton;
                if (keyboard.getShiftModel() == null)
                    keyboard.setShiftModel(button.getModel());
                else
                    button.setModel(keyboard.getShiftModel());
View Full Code Here

            @Override
            public void actionPerformed(ActionEvent e)
            {
                for (VirtualKeyListener l : vkListener)
                    l.imeKeyActivated(new ImeKeyEvent(KeyboardButton.this, imeMode));
            }
        });
    }
View Full Code Here

TOP

Related Classes of de.t68.utils.keyboard.test.EventTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.