/** * Creates a context menu. The context menu will be shown when user clicks on the label. * * @return a context menu. */ protected JidePopupMenu createContextMenu() { return new JidePopupMenu(); }
/** * Sets the visible menu item count. It will control the popup menu height along with the screen size, whichever is * smaller. * * @param visibleMenuItemCount the maximum menu item count to be shown. -1 means no limit. * @since 3.6.2 */ public void setVisibleMenuItemCount(int visibleMenuItemCount) { if (_visibleMenuItemCount != visibleMenuItemCount) { int oldValue = _visibleMenuItemCount; _visibleMenuItemCount = visibleMenuItemCount; firePropertyChange("visibleMenuCount", oldValue, visibleMenuItemCount); } }
/** * Displays the PopUpMenu at a specified position. * * @param invoker the component that triggers the event * @param x mouse X position on screen * @param y mouse Y position on screen */ @Override public void show(Component invoker, int x, int y) { Point p = getPopupMenuOrigin(invoker, x, y); super.show(invoker, p.x, p.y); }
@Override public void updateUI() { if (UIDefaultsLookup.get(getUIClassID()) == null) { LookAndFeelFactory.installJideExtension(); } setUI((PopupMenuUI) UIManager.getUI(this)); }
public Dimension getPreferredScrollableViewportSize() { Dimension size = getPreferredSize(); Dimension screenSize = PortingUtils.getLocalScreenSize(this); Container container = SwingUtilities.getAncestorOfClass(SimpleScrollPane.class, this); if (container instanceof SimpleScrollPane) { SimpleScrollPane scrollPane = (SimpleScrollPane) container; int height = screenSize.height; // limit it to the height determined by the visible menu item count if (getVisibleMenuItemCount() > 0) { int totalHeight = getVisibleMenuItemCount() * getScrollableUnitIncrement(null, 0, 0); if (height > totalHeight) { height = totalHeight; } } size.height = Math.min(size.height, height - scrollPane.getScrollUpButton().getPreferredSize().height - scrollPane.getScrollDownButton().getPreferredSize().height); } return size; }
/** * Figures out the sizes needed to calculate the menu position. * * @param invoker the component that triggers the event * @param x mouse X position on screen * @param y mouse Y position on screen * @return new position */ protected Point getPopupMenuOrigin(Component invoker, int x, int y) { Dimension size = getPreferredScrollableViewportSize(); Point p = new Point(x, y); SwingUtilities.convertPointToScreen(p, invoker); Rectangle bounds = PortingUtils.ensureOnScreen(new Rectangle(p, size)); p = bounds.getLocation(); SwingUtilities.convertPointFromScreen(p, invoker); return p; }
private void setupPopupMenu() { addPopupMenuListener(new ToolTipSwitchPopupMenuListener()); }
if (popupMenu instanceof JidePopupMenu && popupMenu.getPreferredSize().height != ((JidePopupMenu) popupMenu).getPreferredScrollableViewportSize().height) { if (popupMenu.getLayout() instanceof DefaultMenuLayout && SystemInfo.isJdk6Above()) { popupMenu.setLayout(new BoxLayout(popupMenu, ((DefaultMenuLayout) popupMenu.getLayout()).getAxis()));
private void showSliderActions(MouseEvent evt, final int sliderIndex) { final JPopupMenu menu = new JidePopupMenu(); boolean showPopupMenu = false; JMenuItem menuItem; if (canChangeSliderCount()) { menuItem = createMenuItemAddNewSlider(sliderIndex, evt); if (menuItem != null) { menu.add(menuItem); showPopupMenu = true; } if (getSliderCount() > 2 && sliderIndex != INVALID_INDEX) { menuItem = createMenuItemDeleteSlider(sliderIndex); menu.add(menuItem); showPopupMenu = true; } } if (getSliderCount() > 2 && sliderIndex > 0 && sliderIndex < getSliderCount() - 1 && isSliderEditable(sliderIndex)) { menuItem = createMenuItemCenterSampleValue(sliderIndex); menu.add(menuItem); menuItem = createMenuItemCenterColorValue(sliderIndex); menu.add(menuItem); showPopupMenu = true; } if (showPopupMenu) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); } }
private void showSliderActions(MouseEvent evt, final int sliderIndex) { final JPopupMenu menu = new JidePopupMenu(); boolean showPopupMenu = false; JMenuItem menuItem = createMenuItemAddNewSlider(sliderIndex, evt); if (menuItem != null) { menu.add(menuItem); showPopupMenu = true; } if (getSliderCount() > 3 && sliderIndex != INVALID_INDEX) { menuItem = createMenuItemDeleteSlider(sliderIndex); menu.add(menuItem); showPopupMenu = true; } if (getSliderCount() > 2 && sliderIndex > 0 && sliderIndex < getSliderCount() - 1) { menuItem = createMenuItemCenterSampleValue(sliderIndex); menu.add(menuItem); menuItem = createMenuItemCenterColorValue(sliderIndex); menu.add(menuItem); showPopupMenu = true; } if (showPopupMenu) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); } }