简体   繁体   中英

Swing On-Screen Keyboard

I am working on a KIOSK System in Java on Windows XP. And need to do a on screen key board. I have no idea about it that how to do. So can you guys please help me out to do this. Any one have some idea about it. Thanks

I implemented a OSK in SWT and AWT for my company.

We initialize the OSk layout using a ini file were you can define the key board layout (Size, Font, how a keyboard line looks like, key label and key action)

First you should generate the keyboard reading these ini file. This is done very fast. You should enable the focuss on the created buttons and also on the top window. Otherwise the component which is getting the key actions is loosing the focus all the time.

The second step is to implement the event dispatcher manager. You have to send the OSK key events to all listening event objects. You can send a event using Robot or get the focused component with FocusManager and set it in directly.

For SWT it works very good, but in AWT their are some threading and focuss issues.

This one showed up in a search for how to go to locked kiosk mode in java / swing... - And it took me a while to find out how to do it so here it is for anyone ending up here as i did:

public class FullScreen extends JWindow {

    public FullScreen()
    {

      getContentPane().add(new JLabel("A JFrame Kiosk"), BorderLayout.NORTH);

      JButton closeButton = new JButton("Close");

      closeButton.addActionListener( new ActionListener()
          {
              public void actionPerformed( ActionEvent ae )
              {
                  System.out.println("Close button Pressed");
                  FullScreen.this.setVisible(false);
                  System.exit(0);
              }
          });
      getContentPane().add(closeButton, BorderLayout.CENTER);
    }

    public static void main(String[] args) throws Exception {

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {      
                GraphicsEnvironment.
                    getLocalGraphicsEnvironment().
                        getDefaultScreenDevice().
                            setFullScreenWindow(new FullScreen());
              }
        });
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM