Search in sources :

Example 81 with MouseListener

use of java.awt.event.MouseListener in project lotro-companion by dmorcellet.

the class TomesEditionPanelController method buildTomeController.

private TomeIconController buildTomeController(TomesSet tomes, STAT stat) {
    TomeIconController controller = new TomeIconController(tomes, stat);
    JLabel label = controller.getLabel();
    MouseListener listener = buildLeftClickListener();
    label.addMouseListener(listener);
    return controller;
}
Also used : MouseListener(java.awt.event.MouseListener) JLabel(javax.swing.JLabel)

Example 82 with MouseListener

use of java.awt.event.MouseListener in project cytoscape-impl by cytoscape.

the class NetworkMediator method addMouseListenersForSelection.

private void addMouseListenersForSelection(final AbstractNetworkPanel<?> item, final JComponent... components) {
    // This mouse listener listens for mouse pressed events to select the list items
    final MouseListener selectionListener = new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            networkMainPanel.onMousePressedItem(e, item);
        }
    };
    // This mouse listener listens for the right-click events to show the pop-up window
    final PopupListener popupListener = new PopupListener(item);
    for (JComponent c : components) {
        c.addMouseListener(selectionListener);
        c.addMouseListener(popupListener);
    }
}
Also used : MouseListener(java.awt.event.MouseListener) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) JComponent(javax.swing.JComponent)

Example 83 with MouseListener

use of java.awt.event.MouseListener in project cytoscape-impl by cytoscape.

the class NetworkViewMediator method addMouseListeners.

private void addMouseListeners(final ThumbnailPanel tp, final Component... components) {
    // This mouse listener listens for mouse pressed events to select the list items
    final MouseListener selectionListener = new MouseAdapter() {

        @Override
        public void mousePressed(final MouseEvent e) {
            getNetworkViewGrid().onMousePressedItem(e, tp);
        }

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2 && !e.isPopupTrigger()) {
                // Double-Click: set this one as current and show attached view or view frame
                final NetworkViewFrame frame = getNetworkViewFrame(tp.getNetworkView());
                if (frame != null)
                    getNetworkViewMainPanel().showViewFrame(frame);
                else
                    gridViewToggleModel.setMode(Mode.VIEW);
            }
        }
    };
    // This mouse listener listens for the right-click events to show the pop-up window
    final PopupListener popupListener = new PopupListener(tp);
    for (Component c : components) {
        c.addMouseListener(selectionListener);
        c.addMouseListener(popupListener);
    }
}
Also used : MouseListener(java.awt.event.MouseListener) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) Component(java.awt.Component)

Example 84 with MouseListener

use of java.awt.event.MouseListener in project tray by qzind.

the class LinkLabel method initialize.

private void initialize() {
    actionListeners = new ArrayList<>();
    addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {
            for (ActionListener actionListener : actionListeners) {
                actionListener.actionPerformed(new ActionEvent(e.getSource(), e.getID(), "mouseClicked"));
            }
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }

        @Override
        public void mouseEntered(MouseEvent e) {
            setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        }

        @Override
        public void mouseExited(MouseEvent e) {
            setCursor(Cursor.getDefaultCursor());
        }
    });
}
Also used : MouseListener(java.awt.event.MouseListener) MouseEvent(java.awt.event.MouseEvent) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 85 with MouseListener

use of java.awt.event.MouseListener in project com.revolsys.open by revolsys.

the class MouseOverlay method mousePressed.

@Override
public void mousePressed(final MouseEvent e) {
    updateEventPoint(e);
    final Window window = SwingUtil.getWindowAncestor(this);
    window.setAlwaysOnTop(true);
    window.toFront();
    window.setFocusableWindowState(true);
    window.requestFocus();
    window.setAlwaysOnTop(false);
    requestFocusInWindow();
    for (final Component overlay : getOverlays()) {
        if (overlay instanceof MouseListener) {
            final MouseListener listener = (MouseListener) overlay;
            listener.mousePressed(e);
            if (e.isConsumed()) {
                return;
            }
        }
    }
}
Also used : Window(java.awt.Window) MouseListener(java.awt.event.MouseListener) JComponent(javax.swing.JComponent) Component(java.awt.Component)

Aggregations

MouseListener (java.awt.event.MouseListener)104 MouseEvent (java.awt.event.MouseEvent)67 Dimension (java.awt.Dimension)21 JLabel (javax.swing.JLabel)20 MouseAdapter (java.awt.event.MouseAdapter)19 JPanel (javax.swing.JPanel)16 Component (java.awt.Component)14 JComponent (javax.swing.JComponent)14 ActionEvent (java.awt.event.ActionEvent)13 ActionListener (java.awt.event.ActionListener)11 MouseMotionListener (java.awt.event.MouseMotionListener)11 JButton (javax.swing.JButton)11 JScrollPane (javax.swing.JScrollPane)11 Insets (java.awt.Insets)8 BorderLayout (java.awt.BorderLayout)7 Color (java.awt.Color)7 Point (java.awt.Point)7 File (java.io.File)7 ImageIcon (javax.swing.ImageIcon)6 JCheckBox (javax.swing.JCheckBox)6