Search in sources :

Example 36 with MouseAdapter

use of java.awt.event.MouseAdapter in project HWpopup by Mu0n.

the class SwingLink method setup.

public void setup(String t, URI u) {
    text = t;
    uri = u;
    setText(text);
    setToolTipText(uri.toString());
    addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            open(uri);
        }

        public void mouseEntered(MouseEvent e) {
            setText(text, false);
        }

        public void mouseExited(MouseEvent e) {
            setText(text, true);
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter)

Example 37 with MouseAdapter

use of java.awt.event.MouseAdapter in project intellij-community by JetBrains.

the class PopupHandler method installFollowingSelectionTreePopup.

public static MouseListener installFollowingSelectionTreePopup(final JTree tree, @NotNull final ActionGroup group, final String place, final ActionManager actionManager) {
    if (ApplicationManager.getApplication() == null)
        return new MouseAdapter() {
        };
    PopupHandler handler = new PopupHandler() {

        public void invokePopup(Component comp, int x, int y) {
            if (tree.getPathForLocation(x, y) != null && Arrays.binarySearch(tree.getSelectionRows(), tree.getRowForLocation(x, y)) > -1) {
                //do not show popup menu on rows other than selection
                final ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(place, group);
                popupMenu.getComponent().show(comp, x, y);
            }
        }
    };
    tree.addMouseListener(handler);
    return handler;
}
Also used : ActionPopupMenu(com.intellij.openapi.actionSystem.ActionPopupMenu) MouseAdapter(java.awt.event.MouseAdapter)

Example 38 with MouseAdapter

use of java.awt.event.MouseAdapter in project intellij-community by JetBrains.

the class CustomizationUtil method installPopupHandler.

public static MouseListener installPopupHandler(JComponent component, @NotNull final String groupId, final String place) {
    if (ApplicationManager.getApplication() == null)
        return new MouseAdapter() {
        };
    PopupHandler popupHandler = new PopupHandler() {

        @Override
        public void invokePopup(Component comp, int x, int y) {
            ActionGroup group = (ActionGroup) CustomActionsSchema.getInstance().getCorrectedAction(groupId);
            final ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(place, group);
            popupMenu.getComponent().show(comp, x, y);
        }
    };
    component.addMouseListener(popupHandler);
    return popupHandler;
}
Also used : PopupHandler(com.intellij.ui.PopupHandler) MouseAdapter(java.awt.event.MouseAdapter)

Example 39 with MouseAdapter

use of java.awt.event.MouseAdapter in project intellij-community by JetBrains.

the class InfoAndProgressPanel method createInlineDelegate.

@NotNull
private InlineProgressIndicator createInlineDelegate(@NotNull TaskInfo info, @NotNull ProgressIndicatorEx original, final boolean compact) {
    final Collection<InlineProgressIndicator> inlines = myOriginal2Inlines.get(original);
    if (inlines != null) {
        for (InlineProgressIndicator eachInline : inlines) {
            if (eachInline.isCompact() == compact)
                return eachInline;
        }
    }
    final InlineProgressIndicator inline = new MyInlineProgressIndicator(compact, info, original);
    myInline2Original.put(inline, original);
    myOriginal2Inlines.put(original, inline);
    if (compact) {
        inline.getComponent().addMouseListener(new MouseAdapter() {

            @Override
            public void mousePressed(MouseEvent e) {
                handle(e);
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                handle(e);
            }
        });
    }
    return inline;
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) NotNull(org.jetbrains.annotations.NotNull)

Example 40 with MouseAdapter

use of java.awt.event.MouseAdapter in project intellij-community by JetBrains.

the class HoverHyperlinkLabel method setupListener.

private void setupListener() {
    addMouseListener(new MouseAdapter() {

        public void mouseEntered(MouseEvent e) {
            HoverHyperlinkLabel.super.setText(underlineTextInHtml(myOriginalText));
            setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        }

        public void mouseExited(MouseEvent e) {
            HoverHyperlinkLabel.super.setText(myOriginalText);
            setCursor(Cursor.getDefaultCursor());
        }
    });
    new ClickListener() {

        @Override
        public boolean onClick(@NotNull MouseEvent e, int clickCount) {
            HyperlinkEvent event = new HyperlinkEvent(HoverHyperlinkLabel.this, HyperlinkEvent.EventType.ACTIVATED, null);
            for (HyperlinkListener listener : myListeners) {
                listener.hyperlinkUpdate(event);
            }
            return true;
        }
    }.installOn(this);
}
Also used : MouseEvent(java.awt.event.MouseEvent) HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkListener(javax.swing.event.HyperlinkListener) MouseAdapter(java.awt.event.MouseAdapter)

Aggregations

MouseAdapter (java.awt.event.MouseAdapter)202 MouseEvent (java.awt.event.MouseEvent)199 JLabel (javax.swing.JLabel)52 JPanel (javax.swing.JPanel)48 ActionEvent (java.awt.event.ActionEvent)36 JScrollPane (javax.swing.JScrollPane)36 BorderLayout (java.awt.BorderLayout)35 Dimension (java.awt.Dimension)34 JButton (javax.swing.JButton)33 ActionListener (java.awt.event.ActionListener)32 Insets (java.awt.Insets)24 GridBagConstraints (java.awt.GridBagConstraints)20 KeyEvent (java.awt.event.KeyEvent)20 KeyAdapter (java.awt.event.KeyAdapter)19 JTextField (javax.swing.JTextField)16 ListSelectionEvent (javax.swing.event.ListSelectionEvent)16 Component (java.awt.Component)15 Point (java.awt.Point)15 JTable (javax.swing.JTable)15 ListSelectionListener (javax.swing.event.ListSelectionListener)15