POS - Using shortkeys in login window
Code snippetName: POS - Using shortkeys in the login window
|
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(); }