/** * ************************************ Constructs a BorderButton * * @param borderOwner */ public BorderButtonD(Component borderOwner) { this.borderOwner = borderOwner; // register our mouseListener, making sure it is the first one added MouseListener[] ml = borderOwner.getMouseListeners(); for (int i = 0; i < ml.length; i++) borderOwner.removeMouseListener(ml[i]); borderOwner.addMouseListener(this); for (int i = 0; i < ml.length; i++) borderOwner.addMouseListener(ml[i]); // register mouseMotionListener borderOwner.addMouseMotionListener(this); icon = new ImageIcon[maxIconCount]; isVisibleIcon = new boolean[maxIconCount]; isMouseOverIcon = new boolean[maxIconCount]; iconRect = new Rectangle[maxIconCount]; al = new ActionListener[maxIconCount]; for (int i = 0; i < maxIconCount; i++) { icon[i] = new ImageIcon(); iconRect[i] = new Rectangle(); isMouseOverIcon[i] = false; // need default visibility = false so that focus lost/gained // visibility works isVisibleIcon[i] = false; } }
void removePopupListeners(Component comp) { MouseListener ms[] = comp.getMouseListeners(); for (int i = 0; i < ms.length; i++) { if (ms[i] instanceof PopupListener) { comp.removeMouseListener(ms[i]); } } }
void removeClickListeners(Component comp) { MouseListener ls[] = comp.getMouseListeners(); for (int i = 0; i < ls.length; i++) { if (ls[i] instanceof ClickListener) { comp.removeMouseListener(ls[i]); Err.pr(SdzNote.FIELD_VALIDATION, "Removed all focus listeners from " + comp); } } }
ClickListener createClickListener(Component comp, Object itemAdapter) { ClickListener result = null; MouseListener ls[] = comp.getMouseListeners(); for (int i = 0; i < ls.length; i++) { if (ls[i] instanceof ClickListener) { Err.error("Already have a ClickListenerI on " + comp.getName()); } } result = new ClickListener((ItemAdapter) itemAdapter); return result; }
private final void notifyMouseClicked(final int id, final int x, final int y) { final Component comp = searchComponentByHcCode(mlet, id); if (comp != null) { final MouseListener[] mlistener = comp.getMouseListeners(); MouseEvent event = null; for (int i = 0; i < mlistener.length; i++) { if (event == null) { event = buildMouseEvent(comp, MouseEvent.MOUSE_CLICKED, x, y); } mlistener[i].mouseClicked(event); } } else { LogManager.err(NO_COMPONENT_HCCODE + id); } }
/** * Propagates certain mouse events, such as MOUSE_CLICKED, MOUSE_RELEASED etc. to the deepest * component. * * @param e The MouseEvent to be propagated. */ protected void propagateMouseListenerEvent(MouseEvent e) { if (POPUP_IS_MODAL == false) { Component deepestComponent = getDeepestComponent(e.getPoint()); if (deepestComponent != null) { MouseListener[] mouseListeners = deepestComponent.getMouseListeners(); int eventID; // Get the event type eventID = e.getID(); Point pt = e.getPoint(); Point convertedPt = SwingUtilities.convertPoint(glassPane, e.getPoint(), deepestComponent); MouseEvent evt = new MouseEvent( deepestComponent, e.getID(), System.currentTimeMillis(), e.getModifiers(), convertedPt.x, convertedPt.y, e.getClickCount(), e.isPopupTrigger(), e.getButton()); // Distibute the event to the component's listeners. for (int i = 0; i < mouseListeners.length; i++) { // Forward the appropriate mouse event if (eventID == MouseEvent.MOUSE_PRESSED) { mouseListeners[i].mousePressed(evt); } else if (eventID == MouseEvent.MOUSE_RELEASED) { mouseListeners[i].mouseReleased(evt); } else if (eventID == MouseEvent.MOUSE_CLICKED) { mouseListeners[i].mouseClicked(evt); } } } } }