Search in sources :

Example 1 with MouseMotionAdapter

use of java.awt.event.MouseMotionAdapter in project jdk8u_jdk by JetBrains.

the class ExtraMouseClick method init.

public void init() {
    this.setLayout(new BorderLayout());
    frame.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent e) {
            System.out.println("MousePressed");
            pressed = true;
        }

        public void mouseReleased(MouseEvent e) {
            System.out.println("MouseReleased");
            released = true;
        }

        public void mouseClicked(MouseEvent e) {
            System.out.println("MouseClicked!!!!");
            clicked = true;
        }
    });
    frame.addMouseMotionListener(new MouseMotionAdapter() {

        public void mouseDragged(MouseEvent e) {
            System.out.println("MouseDragged--" + e);
            dragged = true;
        }

        public void mouseMoved(MouseEvent e) {
        }
    });
}
Also used : MouseMotionAdapter(java.awt.event.MouseMotionAdapter) MouseEvent(java.awt.event.MouseEvent) BorderLayout(java.awt.BorderLayout) MouseAdapter(java.awt.event.MouseAdapter)

Example 2 with MouseMotionAdapter

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

the class ToolWindowContentUi method initMouseListeners.

public static void initMouseListeners(final JComponent c, final ToolWindowContentUi ui) {
    if (c.getClientProperty(ui) != null)
        return;
    final Point[] myLastPoint = new Point[1];
    c.addMouseMotionListener(new MouseMotionAdapter() {

        public void mouseDragged(final MouseEvent e) {
            if (myLastPoint[0] == null)
                return;
            final Window window = SwingUtilities.windowForComponent(c);
            if (window instanceof IdeFrame)
                return;
            final Point windowLocation = window.getLocationOnScreen();
            PointerInfo info = MouseInfo.getPointerInfo();
            if (info == null)
                return;
            final Point newPoint = info.getLocation();
            Point p = myLastPoint[0];
            windowLocation.translate(newPoint.x - p.x, newPoint.y - p.y);
            window.setLocation(windowLocation);
            myLastPoint[0] = newPoint;
        }
    });
    c.addMouseListener(new MouseAdapter() {

        public void mousePressed(final MouseEvent e) {
            PointerInfo info = MouseInfo.getPointerInfo();
            myLastPoint[0] = info != null ? info.getLocation() : e.getLocationOnScreen();
            if (!e.isPopupTrigger()) {
                if (!UIUtil.isCloseClick(e)) {
                    ui.myWindow.fireActivated();
                }
            }
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            if (!e.isPopupTrigger()) {
                if (UIUtil.isCloseClick(e, MouseEvent.MOUSE_RELEASED)) {
                    ui.processHide(e);
                }
            }
        }
    });
    c.addMouseListener(new PopupHandler() {

        public void invokePopup(final Component comp, final int x, final int y) {
            final Content content = c instanceof BaseLabel ? ((BaseLabel) c).getContent() : null;
            ui.showContextMenu(comp, x, y, ui.myWindow.getPopupGroup(), content);
        }
    });
    c.putClientProperty(ui, Boolean.TRUE);
}
Also used : PopupHandler(com.intellij.ui.PopupHandler) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) IdeFrame(com.intellij.openapi.wm.IdeFrame) MouseMotionAdapter(java.awt.event.MouseMotionAdapter) PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 3 with MouseMotionAdapter

use of java.awt.event.MouseMotionAdapter in project adempiere by adempiere.

the class VSortTab method jbInit.

/**
	 * 	Static Layout
	 * 	@throws Exception
	 */
private void jbInit() throws Exception {
    this.setLayout(mainLayout);
    //
    noLabel.setText("No");
    yesLabel.setText("Yes");
    for (MouseMotionListener mml : noList.getMouseMotionListeners()) noList.removeMouseMotionListener(mml);
    for (MouseMotionListener mml : yesList.getMouseMotionListeners()) yesList.removeMouseMotionListener(mml);
    MouseListener mouseListener = new MouseAdapter() {

        public void mouseClicked(MouseEvent me) {
            if (me.getClickCount() > 1) {
                JList list = (JList) me.getComponent();
                Point p = me.getPoint();
                int index = list.locationToIndex(p);
                if (index > -1 && list.getCellBounds(index, index).contains(p))
                    migrateValueAcrossLists(me);
            }
        }
    };
    yesList.addMouseListener(mouseListener);
    noList.addMouseListener(mouseListener);
    //
    yesList.setCellRenderer(listRenderer);
    noList.setCellRenderer(listRenderer);
    ActionListener actionListener = new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            migrateValueAcrossLists(ae);
        }
    };
    bAdd.setIcon(Env.getImageIcon("Detail24.gif"));
    bAdd.setMargin(new Insets(2, 2, 2, 2));
    bAdd.addActionListener(actionListener);
    bRemove.setIcon(Env.getImageIcon("Parent24.gif"));
    bRemove.setMargin(new Insets(2, 2, 2, 2));
    bRemove.addActionListener(actionListener);
    MouseInputListener crossListMouseListener = new DragListener();
    yesList.addMouseListener(crossListMouseListener);
    yesList.addMouseMotionListener(crossListMouseListener);
    noList.addMouseListener(crossListMouseListener);
    noList.addMouseMotionListener(crossListMouseListener);
    actionListener = new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            migrateValueWithinYesList(ae);
        }
    };
    bUp.setIcon(Env.getImageIcon("Previous24.gif"));
    bUp.setMargin(new Insets(2, 2, 2, 2));
    bUp.addActionListener(actionListener);
    bDown.setIcon(Env.getImageIcon("Next24.gif"));
    bDown.setMargin(new Insets(2, 2, 2, 2));
    bDown.addActionListener(actionListener);
    MouseMotionListener yesListMouseMotionListener = new MouseMotionAdapter() {

        public void mouseDragged(MouseEvent me) {
            JList list = (JList) me.getComponent();
            Point p = me.getPoint();
            int index = list.locationToIndex(p);
            if (index > -1 && list.getCellBounds(index, index).contains(p))
                migrateValueWithinYesList(me);
        }
    };
    yesList.addMouseMotionListener(yesListMouseMotionListener);
    //	Yamel Senih, 2015-11-13
    //	Maximize Panel when the window is resized
    yesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    noList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    this.add(noLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    this.add(yesLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    this.add(bDown, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
    this.add(noPane, new GridBagConstraints(0, 1, 1, 3, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4), 0, 0));
    this.add(yesPane, new GridBagConstraints(2, 1, 1, 3, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4), 0, 0));
    this.add(bUp, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
    this.add(bAdd, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
    this.add(bRemove, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
//	End Yamel Senih
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) MouseEvent(java.awt.event.MouseEvent) Insets(java.awt.Insets) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) Point(java.awt.Point) MouseMotionListener(java.awt.event.MouseMotionListener) Point(java.awt.Point) MouseMotionAdapter(java.awt.event.MouseMotionAdapter) MouseListener(java.awt.event.MouseListener) ActionListener(java.awt.event.ActionListener) MouseInputListener(javax.swing.event.MouseInputListener) JList(javax.swing.JList)

Example 4 with MouseMotionAdapter

use of java.awt.event.MouseMotionAdapter in project jabref by JabRef.

the class FieldFormatterCleanupsPanel method buildLayout.

private void buildLayout(List<FieldFormatterCleanup> actionsToDisplay) {
    FormBuilder builder = FormBuilder.create().layout(new FormLayout("left:pref, 13dlu, left:pref:grow, 4dlu, pref, 4dlu, pref", "pref, 2dlu, pref, 2dlu, pref, 4dlu, pref, 2dlu, fill:pref:grow, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu"));
    builder.add(cleanupEnabled).xyw(1, 1, 7);
    actionsList = new JList<>(new CleanupActionsListModel(actionsToDisplay));
    actionsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    actionsList.addMouseMotionListener(new MouseMotionAdapter() {

        @Override
        public void mouseMoved(MouseEvent e) {
            super.mouseMoved(e);
            CleanupActionsListModel m = (CleanupActionsListModel) actionsList.getModel();
            int index = actionsList.locationToIndex(e.getPoint());
            if (index > -1) {
                actionsList.setToolTipText(m.getElementAt(index).getFormatter().getDescription());
            }
        }
    });
    actionsList.getModel().addListDataListener(new ListDataListener() {

        @Override
        public void intervalRemoved(ListDataEvent e) {
            //index0 is sufficient, because of SingleSelection
            if (e.getIndex0() == 0) {
                //when an item gets deleted, the next one becomes the new 0
                actionsList.setSelectedIndex(e.getIndex0());
            }
            if (e.getIndex0() > 0) {
                actionsList.setSelectedIndex(e.getIndex0() - 1);
            }
        }

        @Override
        public void intervalAdded(ListDataEvent e) {
        //empty, not needed
        }

        @Override
        public void contentsChanged(ListDataEvent e) {
        //empty, not needed
        }
    });
    builder.add(actionsList).xyw(3, 5, 5);
    resetButton = new JButton(Localization.lang("Reset"));
    resetButton.addActionListener(e -> ((CleanupActionsListModel) actionsList.getModel()).reset(defaultFormatters));
    BibDatabaseContext databaseContext = JabRefGUI.getMainFrame().getCurrentBasePanel().getDatabaseContext();
    recommendButton = new JButton(Localization.lang("Recommended for %0", databaseContext.getMode().getFormattedName()));
    boolean isBiblatex = databaseContext.isBiblatexMode();
    recommendButton.addActionListener(e -> {
        if (isBiblatex) {
            ((CleanupActionsListModel) actionsList.getModel()).reset(Cleanups.RECOMMEND_BIBLATEX_ACTIONS);
        } else {
            ((CleanupActionsListModel) actionsList.getModel()).reset(Cleanups.RECOMMEND_BIBTEX_ACTIONS);
        }
    });
    removeButton = new JButton(Localization.lang("Remove selected"));
    removeButton.addActionListener(e -> ((CleanupActionsListModel) actionsList.getModel()).removeAtIndex(actionsList.getSelectedIndex()));
    builder.add(removeButton).xy(7, 11);
    builder.add(resetButton).xy(3, 11);
    builder.add(recommendButton).xy(5, 11);
    builder.add(getSelectorPanel()).xyw(3, 15, 5);
    makeDescriptionTextAreaLikeJLabel();
    builder.add(descriptionAreaText).xyw(3, 17, 5);
    this.setLayout(new BorderLayout());
    this.add(builder.getPanel(), BorderLayout.WEST);
    updateDescription();
    // make sure the layout is set according to the checkbox
    cleanupEnabled.addActionListener(new EnablementStatusListener(fieldFormatterCleanups.isEnabled()));
    cleanupEnabled.setSelected(fieldFormatterCleanups.isEnabled());
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) FormBuilder(com.jgoodies.forms.builder.FormBuilder) MouseEvent(java.awt.event.MouseEvent) JButton(javax.swing.JButton) ListDataListener(javax.swing.event.ListDataListener) ListDataEvent(javax.swing.event.ListDataEvent) MouseMotionAdapter(java.awt.event.MouseMotionAdapter) BorderLayout(java.awt.BorderLayout) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext)

Example 5 with MouseMotionAdapter

use of java.awt.event.MouseMotionAdapter in project jdk8u_jdk by JetBrains.

the class bug7154841 method initAndShowUI.

private static void initAndShowUI() {
    popupMenu = new JPopupMenu();
    for (int i = 0; i < 100; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(" Test " + i);
        item.addMouseMotionListener(new MouseMotionAdapter() {

            @Override
            public void mouseMoved(MouseEvent e) {
                passed = true;
            }
        });
        popupMenu.add(item);
    }
    frame = new JFrame();
    screenBounds.set(getScreenBounds());
    frame.setBounds(screenBounds.get());
    frame.setVisible(true);
}
Also used : MouseMotionAdapter(java.awt.event.MouseMotionAdapter) MouseEvent(java.awt.event.MouseEvent)

Aggregations

MouseEvent (java.awt.event.MouseEvent)34 MouseMotionAdapter (java.awt.event.MouseMotionAdapter)34 MouseAdapter (java.awt.event.MouseAdapter)20 Point (java.awt.Point)15 BorderLayout (java.awt.BorderLayout)13 Dimension (java.awt.Dimension)12 JLabel (javax.swing.JLabel)12 JPanel (javax.swing.JPanel)12 JScrollPane (javax.swing.JScrollPane)12 GridBagConstraints (java.awt.GridBagConstraints)11 GridBagLayout (java.awt.GridBagLayout)11 Insets (java.awt.Insets)11 Graphics (java.awt.Graphics)9 Border (javax.swing.border.Border)6 PointLocationInShapeContext (cbit.vcell.graph.PointLocationInShapeContext)5 RuleAnalysisChanged (cbit.vcell.graph.ReactionCartoon.RuleAnalysisChanged)5 GroupingCriteria (cbit.vcell.model.GroupingCriteria)5 RuleParticipantSignature (cbit.vcell.model.RuleParticipantSignature)5 JTextField (javax.swing.JTextField)5 MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)5