@Override public void mouseReleased(MouseEvent evt) { if (evt.isPopupTrigger()) { // Fix #45348: IllegalComponentStateException on show() try { menu.show(evt.getComponent(), evt.getX(), evt.getY()); } catch (IllegalComponentStateException e) { LOGGER.error(e, e); } menu.setLocation( ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT ? evt.getXOnScreen() - menu.getWidth() : evt.getXOnScreen(), evt.getYOnScreen() ); } } });
@Override public void mousePressed(MouseEvent e) { popup.applyComponentOrientation(ComponentOrientation.getOrientation(I18n.getLocaleDefault())); if (ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT) { radioCustomMethod.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 6)); } else { radioCustomMethod.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0)); } popup.show( e.getComponent(), ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT ? e.getComponent().getX() - e.getComponent().getWidth() - popup.getWidth() : e.getComponent().getX(), e.getComponent().getY() + e.getComponent().getWidth() ); popup.setLocation( ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT ? e.getComponent().getLocationOnScreen().x + e.getComponent().getWidth() - popup.getWidth() : e.getComponent().getLocationOnScreen().x, e.getComponent().getLocationOnScreen().y + e.getComponent().getWidth() ); } });
@Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { Component componentSource = (Component) e.getSource(); JPopupMenu menu = new JPopupMenu(); for (int position = 0 ; position < MediatorGui.menubar().getMenuView().getMenuComponentCount() ; position++) { // Fix #35348: SerializationException on clone() try { JMenuItem itemMenu = (JMenuItem) SerializationUtils.clone(MediatorGui.menubar().getMenuView().getMenuComponent(position)); menu.add(itemMenu); final int positionFinal = position; itemMenu.addActionListener(actionEvent -> MediatorGui.tabManagers().setSelectedIndex(positionFinal)); } catch (SerializationException ex) { LOGGER.error(ex, ex); } } menu.show(componentSource, e.getX(), e.getY()); menu.setLocation( ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT ? e.getXOnScreen() - menu.getWidth() : e.getXOnScreen(), e.getYOnScreen() ); } }
list, ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT ? mouseEvent.getX() - popupMenuList.getWidth() : mouseEvent.getX(), mouseEvent.getY() ? mouseEvent.getXOnScreen() - popupMenuList.getWidth() : mouseEvent.getXOnScreen(), mouseEvent.getYOnScreen()
if (popup.isShowing() && e.getID() == MouseEvent.MOUSE_EXITED) { int minX = popup.getLocationOnScreen().x; int maxX = popup.getLocationOnScreen().x + popup.getWidth(); int minY = popup.getLocationOnScreen().y; int maxY = popup.getLocationOnScreen().y + popup.getHeight(); int minX = overflowButton.getLocationOnScreen().x; int maxX_ob = minX + overflowButton.getWidth(); int maxX = getOrientation() == HORIZONTAL ? minX + popup.getWidth() : minX + overflowButton.getWidth() + popup.getWidth(); int minY = overflowButton.getLocationOnScreen().y; int maxY_ob = minY + overflowButton.getHeight();
private boolean isInResizeSpot(Point point) { if (point == null) return false; Rectangle resizeSpot = new Rectangle( menu.getWidth() - REZSIZE_SPOT_SIZE, menu.getHeight() - REZSIZE_SPOT_SIZE, REZSIZE_SPOT_SIZE, REZSIZE_SPOT_SIZE); return resizeSpot.contains(point); }
private boolean isInResizeSpot( Point point ) { if ( point == null ) return false; Rectangle resizeSpot = new Rectangle( menu.getWidth()-REZSIZE_SPOT_SIZE, menu.getHeight()-REZSIZE_SPOT_SIZE, REZSIZE_SPOT_SIZE, REZSIZE_SPOT_SIZE ); return resizeSpot.contains(point); }
private boolean isInResizeSpot(Point point) { if (point == null) return false; Rectangle resizeSpot = new Rectangle( menu.getWidth() - REZSIZE_SPOT_SIZE, menu.getHeight() - REZSIZE_SPOT_SIZE, REZSIZE_SPOT_SIZE, REZSIZE_SPOT_SIZE); return resizeSpot.contains(point); }
@ScriptFunction(jsDoc = WIDTH_JSDOC) @Override public int getWidth() { return super.getWidth(); }
private boolean isInResizeSpot( Point point ) { if ( point == null ) return false; Rectangle resizeSpot = new Rectangle( menu.getWidth()-REZSIZE_SPOT_SIZE, menu.getHeight()-REZSIZE_SPOT_SIZE, REZSIZE_SPOT_SIZE, REZSIZE_SPOT_SIZE ); return resizeSpot.contains(point); }
protected void showPopup(PInputEvent e) { Component invoker = (Component) e.getComponent(); if ((invoker != null) && (popup != null) && (popup.getComponentCount() > 0)) { int x = (int) e.getCanvasPosition().getX(); int y = (int) e.getCanvasPosition().getY(); if (x + popup.getWidth() > invoker.getX() + invoker.getWidth()) { x = invoker.getX() + invoker.getWidth() - popup.getWidth(); } if (y + popup.getHeight() > invoker.getY() + invoker.getHeight()) { y = invoker.getY() + invoker.getHeight() - popup.getHeight(); } popup.show(invoker, x, y); } }
case LEFT: x = menu.getWidth() * -1; y = 0; break;
public void actionPerformed(ActionEvent e) { Object src = e.getSource(); if (src instanceof JTabbedPane) { tabbedPane = (JTabbedPane) src; } else if (src instanceof ScrollablePopupMenuTabButton) { tabbedPane = (JTabbedPane) ((ScrollablePopupMenuTabButton) src).getParent(); } else { return; // shouldn't happen } BaseTabbedPaneUI ui = (BaseTabbedPaneUI) tabbedPane.getUI(); if (ui.scrollableTabLayoutEnabled()) { JPopupMenu popup = new JPopupMenu(); for (int i = 0; i < tabbedPane.getTabCount(); i++) { JMenuItem item = new JMenuItem(tabbedPane.getTitleAt(i)); item.addActionListener(new ScrollTabsPopupMenuItemAction(tabbedPane, i)); item.setEnabled(tabbedPane.isEnabledAt(i)); popup.add(item); } popup.show(ui.tabScroller.popupMenuButton, 0, 0); Point pt = ui.tabScroller.popupMenuButton.getLocationOnScreen(); int x = -popup.getWidth() + ui.tabScroller.popupMenuButton.getWidth(); int y = ui.tabScroller.popupMenuButton.getHeight() - 1; popup.setLocation(pt.x + x, pt.y + y); } } }