/** * Returns the popup menu for this component, lazily creating it if * necessary. * * @return The popup menu. * @see #createPopupMenu() * @see #setPopupMenu(JPopupMenu) */ public JPopupMenu getPopupMenu() { if (!popupMenuCreated) { popupMenu = createPopupMenu(); if (popupMenu!=null) { ComponentOrientation orientation = ComponentOrientation. getOrientation(Locale.getDefault()); popupMenu.applyComponentOrientation(orientation); } popupMenuCreated = true; } return popupMenu; }
@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() ); } });
popupMenuList.add(mnRestoreDefault); popupMenuList.applyComponentOrientation(ComponentOrientation.getOrientation(I18n.getLocaleDefault()));
menu.add(itemSelectAll); menu.applyComponentOrientation(ComponentOrientation.getOrientation(I18n.getLocaleDefault()));
/** * @inheritDoc * */ @Override public void applyComponentOrientation(ComponentOrientation o) { getPopupMenu().applyComponentOrientation(o); }
/** * @inheritDoc * */ @Override public void applyComponentOrientation(ComponentOrientation o) { getPopupMenu().applyComponentOrientation(o); }
/** * @inheritDoc * */ @Override public void applyComponentOrientation(ComponentOrientation o) { getPopupMenu().applyComponentOrientation(o); }
/** * @inheritDoc * */ @Override public void applyComponentOrientation(ComponentOrientation o) { getPopupMenu().applyComponentOrientation(o); }
/** * @inheritDoc * */ public void applyComponentOrientation(ComponentOrientation o) { getPopupMenu().applyComponentOrientation(o); }
/** * Overridden to apply the new orientation to our (possibly hidden) * child components. * * @param o The new component orientation. */ @Override public void applyComponentOrientation(ComponentOrientation o) { super.applyComponentOrientation(o); for (Component c : children) { c.applyComponentOrientation(o); } }
/** * Overridden to apply the new orientation to our (possibly hidden) * child components. * * @param o The new component orientation. */ public void applyComponentOrientation(ComponentOrientation o) { super.applyComponentOrientation(o); for (Iterator i=children.iterator(); i.hasNext(); ) { Component c = (Component)i.next(); c.applyComponentOrientation(o); } }
/** * Sets the orientation of this component. This is overridden to also * update the orientation of the popup menu. * * @param o The new orientation. */ @Override public void applyComponentOrientation(ComponentOrientation o) { super.applyComponentOrientation(o); if (popupMenu!=null) { popupMenu.applyComponentOrientation(o); } }
/** * Overridden to apply the new orientation to our (possibly hidden) child * components. * * @param o The new component orientation. */ public void applyComponentOrientation(ComponentOrientation o) { super.applyComponentOrientation(o); for (Iterator i = children.iterator(); i.hasNext();) { Component c = (Component) i.next(); c.applyComponentOrientation(o); } }
/** * Returns the popup menu for this component, lazily creating it if * necessary. * * @return The popup menu. * @see #createPopupMenu() * @see #setPopupMenu(JPopupMenu) */ public JPopupMenu getPopupMenu() { if (!popupMenuCreated) { popupMenu = createPopupMenu(); if (popupMenu!=null) { ComponentOrientation orientation = ComponentOrientation. getOrientation(Locale.getDefault()); popupMenu.applyComponentOrientation(orientation); } popupMenuCreated = true; } return popupMenu; }
/** * Returns the popup menu for this component, lazily creating it if * necessary. * * @return The popup menu. * @see #createPopupMenu() * @see #setPopupMenu(JPopupMenu) */ public JPopupMenu getPopupMenu() { if (!popupMenuCreated) { popupMenu = createPopupMenu(); if (popupMenu!=null) { ComponentOrientation orientation = ComponentOrientation. getOrientation(Locale.getDefault()); popupMenu.applyComponentOrientation(orientation); } popupMenuCreated = true; } return popupMenu; }
/** * Returns the popup menu for this component, lazily creating it if * necessary. * * @return The popup menu. * @see #createPopupMenu() * @see #setPopupMenu(JPopupMenu) */ public JPopupMenu getPopupMenu() { if (!popupMenuCreated) { popupMenu = createPopupMenu(); if (popupMenu!=null) { ComponentOrientation orientation = ComponentOrientation. getOrientation(Locale.getDefault()); popupMenu.applyComponentOrientation(orientation); } popupMenuCreated = true; } return popupMenu; }
@Override public void actionPerformed(ActionEvent e) { Point location = getLocation(); location.y = getHeight(); popupMenu.applyComponentOrientation( MenuButton.this.getComponentOrientation()); popupMenu.show(MenuButton.this, 0,location.y); }
/** * Sets up vertical scrollbar's popup menu. */ private void createVerticalScrollBarMenu() { vertSBMenu = new JPopupMenu(); ResourceBundle msg = ResourceBundle.getBundle(RScrollPane.class.getName()); addMenuItem("ScrollHere","ScrollHereVertical", vertSBMenu, msg); vertSBMenu.addSeparator(); addMenuItem("Top", "Top", vertSBMenu, msg); addMenuItem("Bottom", "Bottom", vertSBMenu, msg); vertSBMenu.addSeparator(); addMenuItem("PageUp", "PageUp", vertSBMenu, msg); addMenuItem("PageDown", "PageDown", vertSBMenu, msg); vertSBMenu.addSeparator(); addMenuItem("ScrollUp", "ScrollUp", vertSBMenu, msg); addMenuItem("ScrollDown", "ScrollDown", vertSBMenu, msg); vertSBMenu.applyComponentOrientation(getComponentOrientation()); }
/** * Shows the popup menu with the consideration of the invoker's orientation. * * @param popup the popup menu * @param invoker the invoker for the popup menu * @param x the x, usually the x of the mouse clicked position * @param y the y, usually the y of the mouse clicked position */ public static void showPopupMenu(JPopupMenu popup, Component invoker, int x, int y) { popup.applyComponentOrientation(invoker.getComponentOrientation()); if (popup.getComponentOrientation().isLeftToRight()) { popup.show(invoker, x, y); } else { popup.show(invoker, x - popup.getPreferredSize().width, y); } } }
/** * Sets up horizontal scrollbar's popup menu. */ private void createHorizontalScrollBarMenu() { horizSBMenu = new JPopupMenu(); ResourceBundle msg = ResourceBundle.getBundle(RScrollPane.class.getName()); addMenuItem("ScrollHere", "ScrollHereHorizontal", horizSBMenu, msg); horizSBMenu.addSeparator(); addMenuItem("LeftEdge", "LeftEdge", horizSBMenu, msg); addMenuItem("RightEdge", "RightEdge", horizSBMenu, msg); horizSBMenu.addSeparator(); addMenuItem("PageLeft", "PageLeft", horizSBMenu, msg); addMenuItem("PageRight", "PageRight", horizSBMenu, msg); horizSBMenu.addSeparator(); addMenuItem("ScrollLeft","ScrollLeft",horizSBMenu, msg); addMenuItem("ScrollRight", "ScrollRight", horizSBMenu, msg); horizSBMenu.applyComponentOrientation(getComponentOrientation()); }