@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;
}