Search
Getting Started

Assuming you have already installed the Virtual Keyboard package, create a new project in your Java development environment and add the JKeyboard.jar archive to the list of required libraries of your application. In Eclipse-based IDEs, adding JKeyboard.jar to the build path looks like this:

  • Open the project's Properties window;
  • Open the "Java Build Path" page;
  • Open the "Libraries" tab;
  • Click the "Add External JARs" button;
  • Navigate to JKeyboard.jar and select it;

Once you have added a JKeyboard reference to your project, you can access the public classes defined in com.mindfusion.keyboard package. The most important classes are VirtualKeyboard, a Swing component that implement the keyboard, and KeyboardLayout, which let you load custom layouts. You usually create and initialize a new instances of the classes in the same place where you create and initialize the rest of the user interface of your application. A minimal application containing an embedded keyboard that send input to the application's text fields looks like this:

Java  Copy Code

import java.awt.*;
import javax.swing.*;

import com.mindfusion.keyboard.VirtualKeyboard;

public class App
{
    static public void main(String[] args)
    {
        JFrame mainFrame = new JFrame("Embedded Keyboard");
        mainFrame.getContentPane().setLayout(new BorderLayout());

        VirtualKeyboard vkb = new VirtualKeyboard();
        vkb.setFocusable(false);
        vkb.setPreferredSize(new Dimension(870, 300));
        mainFrame.getContentPane().add(vkb, BorderLayout.SOUTH);

        JTextArea text = new JTextArea();
        mainFrame.getContentPane().add(text, BorderLayout.CENTER);

        mainFrame.setSize(870, 450);
        mainFrame.setVisible(true);
        mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        text.requestFocus();
    }
}

If you need to use the virtual keyboard to send output to external applications, set its Standalone property to true. This will prevent the parent JFrame from being activated when clicked, thus stealing input focus from other windows.

Browse the other sections of this help file to learn more about the things you can do with Virtual Keyboard classes.