List of usage examples for javax.swing JMenuItem doClick
public void doClick()
From source file:edu.ku.brc.ui.UIHelper.java
/** * Adds a special key listener to process a RETURN key for selecting and item * in the popup list. This is installed only for Windows and Linux. * @param popupMenu the popup menu to be altered. *//*from w ww. j a v a 2 s . co m*/ public static void addSpecialKeyListenerForPopup(final JPopupMenu popupMenu) { if (!UIHelper.isMacOS()) { popupMenu.addKeyListener(new KeyAdapter() { //@Override public void keyPressed(KeyEvent e) { super.keyPressed(e); if (e.getKeyCode() == VK_ENTER) { for (int i = 0; i < popupMenu.getComponentCount(); i++) { Component c = popupMenu.getComponent(i); if (c instanceof JMenuItem) { JMenuItem mi = (JMenuItem) c; if (mi.isArmed()) { mi.doClick(); popupMenu.setVisible(false); } } } } } }); } }
From source file:com.maxl.java.amikodesk.AMiKoDesk.java
static void checkIfUpdateRequired(JMenuItem update_item) { // Get current date DateTime dT = new DateTime(); // Get stored date String updateTime = m_prefs.get("updateTime", dT.now().toString()); DateTime uT = new DateTime(updateTime); // Seconds diffSec = Seconds.secondsBetween(uT, dT); Minutes diffMin = Minutes.minutesBetween(uT, dT); // Do this only when the application is freshly installed int timeDiff = diffMin.getMinutes(); /*// www . ja va 2 s . c o m if (timeDiff == 0) m_prefs.put("updateTime", dT.now().toString()); */ // First check if everything needs to be updated... switch (m_prefs.getInt("update", 0)) { case 0: // Manual // do nothing break; case 1: // Daily if (timeDiff > 60 * 24) { m_full_db_update = true; update_item.doClick(); } break; case 2: // Weekly if (timeDiff > 60 * 24 * 7) { m_full_db_update = true; update_item.doClick(); } break; case 3: // Monthly if (timeDiff > 60 * 24 * 30) { m_full_db_update = true; update_item.doClick(); } break; default: break; } // else proceed with the Preisvergleich-only update switch (m_prefs.getInt("update-comp", 0)) { case 0: // Manual // do nothing break; case 1: // Half-hourly if (timeDiff % 30 == 0) { m_full_db_update = false; update_item.doClick(); } break; case 2: // Hourly if (timeDiff % 60 == 0) { m_full_db_update = false; update_item.doClick(); } break; case 3: // Half-daily if (timeDiff % (4 * 60) == 0) { m_full_db_update = false; update_item.doClick(); } break; default: break; } }