/** * Gets the number of the selected items. * * @return number of selected items */ public int getSelectedItemsCount() { int selectionCount = 0; Component[] components = menuPanel.getComponents(); for (Component component : components) { ScrollablePopupMenuItem item = (ScrollablePopupMenuItem) component; if (item.isSelected()) { selectionCount++; } } return selectionCount; }
/** * Adds the footer item to this pop up menu. */ private void addFooter(ScrollablePopupMenuItem footer) { this.footer = footer; this.footer.setEnabled(false); add((Component)this.footer, BorderLayout.SOUTH); }
/** * Invoked when item selection changes. */ public void selectionChanged(ScrollablePopupMenuItem targetItem, boolean wasSelected) { Component[] comps = menuPanel.getComponents(); int n = comps.length; // Deselect all if something was selected if (!wasSelected) { for (int i = n - 1; i >= 0; i--) { ScrollablePopupMenuItem item = (ScrollablePopupMenuItem) comps[i]; item.setSelected(wasSelected); } } else { for (int i = 0; i < n; i++) { ScrollablePopupMenuItem item = (ScrollablePopupMenuItem) comps[i]; if (item == targetItem) { break; } item.setSelected(true); } } footer.setText(model.getFooterText() + getSelectedItemsCount()); repaint(); }
/** * Invoked when item selection changes. */ public void selectionChanged(ScrollablePopupMenuItem targetItem, boolean wasSelected) { Component[] comps = menuPanel.getComponents(); int n = comps.length; // Deselect all if something was selected if (!wasSelected) { for (int i = n - 1; i >= 0; i--) { ScrollablePopupMenuItem item = (ScrollablePopupMenuItem) comps[i]; item.setSelected(wasSelected); } } else { for (Component comp : comps) { ScrollablePopupMenuItem item = (ScrollablePopupMenuItem) comp; if (item == targetItem) { break; } item.setSelected(true); } } footer.setText(model.getFooterText() + getSelectedItemsCount()); repaint(); }
/** * Gets the number of the selected items. * * @return number of selected items */ public int getSelectedItemsCount() { int selectionCount = 0; Component[] components = menuPanel.getComponents(); for (int i = 0; i < components.length; i++) { ScrollablePopupMenuItem item = (ScrollablePopupMenuItem) components[i]; if (item.isSelected()) { selectionCount++; } } return selectionCount; }
/** * Processes click on the pop up menu item. */ public void processItemClicked() { footer.setText(model.getFooterText() + 0); setVisible(false); model.processItemClicked(); }
/** * Sets the ScrollablePopupMenuModel. * * @param model * the model to set */ public void setModel(ScrollablePopupMenuModel model) { this.model = model; this.footer.setText(model.getFooterText()); }
/** * Adds the footer item to this pop up menu. */ private void addFooter(ScrollablePopupMenuItem footer) { this.footer = footer; this.footer.setEnabled(false); add((Component)this.footer, BorderLayout.SOUTH); }
/** * Sets the ScrollablePopupMenuModel. * * @param model * the model to set */ public void setModel(ScrollablePopupMenuModel model) { this.model = model; this.footer.setText(model.getFooterText()); }
/** * Processes click on the pop up menu item. */ public void processItemClicked() { footer.setText(model.getFooterText() + 0); setVisible(false); model.processItemClicked(); }