View source | Discuss this page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Add page
Show collection (0 pages)
Collections help

Search

POS - Using shortkeys in login window

Code snippet

Name: POS - Using shortkeys in the login window
Version: POS/2.20 & 2.30 Beta
Author: Mikel Irurita



This code snippet is intented to use shortkeys in the Openbravo POS login window. This code has been copied from this forum thread.

Go to listPeople() method in JRootApp (com.openbravo.pos.forms) class.

For each user a button is created in the for loop. So the idea is to check the name of the user and assign a shortkey.

In this example pressing Alt+A keys you will login as Administrator.

//Administrator
if (user.getName().equals("Administrator")) {
   btn.setMnemonic(KeyEvent.VK_A);
}

All the together looks like:

private void listPeople() {
  try {
    jScrollPane1.getViewport().setView(null);
    JFlowPanel jPeople = new JFlowPanel();
    jPeople.applyComponentOrientation(getComponentOrientation());
    java.util.List people = m_dlSystem.listPeopleVisible();
    for (int i = 0; i < people.size(); i++) {
    AppUser user = (AppUser) people.get(i);
    JButton btn = new JButton(new AppUserAction(user));
    btn.applyComponentOrientation(getComponentOrientation());
    btn.setFocusPainted(false);
    btn.setFocusable(false);
    btn.setRequestFocusEnabled(false);
    btn.setHorizontalAlignment(SwingConstants.LEADING);
    btn.setMaximumSize(new Dimension(150, 50));
    btn.setPreferredSize(new Dimension(150, 50));
    btn.setMinimumSize(new Dimension(150, 50));
    //Administrator
    if (user.getName().equals("Administrator")) {
        btn.setMnemonic(KeyEvent.VK_A);
    }
    jPeople.add(btn);                    
    }
    jScrollPane1.getViewport().setView(jPeople);
  } catch (BasicException ee) {
    ee.printStackTrace();
}

Retrieved from "http://wiki.openbravo.com/wiki/POS_-_Using_shortkeys_in_login_window"

This page has been accessed 3,556 times. This page was last modified on 23 April 2009, at 10:16. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.