java.awt.event.MouseListener Java Examples

The following examples show how to use java.awt.event.MouseListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BeltColumnStatisticsPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Adds a {@link MouseListener} for this component. Makes sure it works on resized components as
 * well as charts.
 */
@Override
public void addMouseListener(final MouseListener listener) {
	super.addMouseListener(listener);
	// needed because we set the size of them/added tooltips so they intercept events now
	labelAttName.addMouseListener(listener);
	labelStatsMissing.addMouseListener(listener);
	labelStatsMin.addMouseListener(listener);
	labelStatsMax.addMouseListener(listener);
	labelStatsAvg.addMouseListener(listener);
	labelStatsDeviation.addMouseListener(listener);
	labelStatsLeast.addMouseListener(listener);
	labelStatsMost.addMouseListener(listener);
	labelStatsValues.addMouseListener(listener);
	labelStatsDuration.addMouseListener(listener);
	labelStatsFrom.addMouseListener(listener);
	labelStatsUntil.addMouseListener(listener);
}
 
Example #2
Source File: LinkButtonPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void init() {
    this.setLayout(new FlowLayout(
            FlowLayout.LEADING, 0, 0));
    setLinkLikeButton(button);
    leftParenthesis = new JLabel("(");                              //NOI18N
    rightParenthesis = new JLabel(")");                             //NOI18N
    add(leftParenthesis);
    add(button);
    add(rightParenthesis);
    MouseListener ml = createLabelMouseListener();
    leftParenthesis.addMouseListener(ml);
    rightParenthesis.addMouseListener(ml);
    button.setEnabled(false);
    this.setMaximumSize(
            this.getPreferredSize());
}
 
Example #3
Source File: XDataViewer.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void registerForMouseEvent(Component comp,
                                         MouseListener mouseListener) {
    if(comp instanceof JScrollPane) {
        JScrollPane pane = (JScrollPane) comp;
        comp = pane.getViewport().getView();
    }
    if(comp instanceof Container) {
        Container container = (Container) comp;
        Component[] components = container.getComponents();
        for(int i = 0; i < components.length; i++) {
            registerForMouseEvent(components[i], mouseListener);
        }
    }

    //No registration for XOpenTypedata that are themselves clickable.
    //No registration for JButton that are themselves clickable.
    if(comp != null &&
       (!(comp instanceof XOpenTypeViewer.XOpenTypeData) &&
        !(comp instanceof JButton)) )
        comp.addMouseListener(mouseListener);
}
 
Example #4
Source File: OpList.java    From Cafebabe with GNU General Public License v3.0 6 votes vote down vote up
public OpList(OpcodeChooserDialog chooser, int... opcodes) {
	this.chooser = chooser;
	this.opcodes = opcodes;
	this.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
	LazyListModel<OpcodeNode> llm = new LazyListModel<OpcodeNode>();
	for (int opcode : opcodes) {
		llm.addElement(new OpcodeNode(opcode));
	}
	this.setModel(llm);
	for (MouseListener ml : this.getMouseListeners())
		this.removeMouseListener(ml);
	this.addMouseListener(new MouseAdapter() {
		public void mouseClicked(MouseEvent evt) {
			if (evt.getClickCount() >= 1) {
				int index = locationToIndex(evt.getPoint());
				OpcodeNode on = llm.getElementAt(index);
				chooser.setOpcode(on.opcode);
				setSelectedIndex(index);
				chooser.refresh();
			}
		}
	});

}
 
Example #5
Source File: XDataViewer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void registerForMouseEvent(Component comp,
                                         MouseListener mouseListener) {
    if(comp instanceof JScrollPane) {
        JScrollPane pane = (JScrollPane) comp;
        comp = pane.getViewport().getView();
    }
    if(comp instanceof Container) {
        Container container = (Container) comp;
        Component[] components = container.getComponents();
        for(int i = 0; i < components.length; i++) {
            registerForMouseEvent(components[i], mouseListener);
        }
    }

    //No registration for XOpenTypedata that are themselves clickable.
    //No registration for JButton that are themselves clickable.
    if(comp != null &&
       (!(comp instanceof XOpenTypeViewer.XOpenTypeData) &&
        !(comp instanceof JButton)) )
        comp.addMouseListener(mouseListener);
}
 
Example #6
Source File: ComponentsInjectionModule.java    From openAGV with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
  // Within this (private) module, there should only be a single tree panel.
  bind(BlocksTreeViewPanel.class)
      .in(Singleton.class);

  // Bind the tree panel annotated with the given annotation to our single
  // instance and expose only this annotated version.
  bind(AbstractTreeViewPanel.class)
      .to(BlocksTreeViewPanel.class);
  expose(BlocksTreeViewPanel.class);

  // Bind TreeView to the single tree panel, too.
  bind(TreeView.class)
      .to(BlocksTreeViewPanel.class);

  // Bind and expose a single manager for the single tree view/panel.
  bind(BlocksTreeViewManager.class)
      .in(Singleton.class);
  expose(BlocksTreeViewManager.class);

  bind(MouseListener.class)
      .to(BlockMouseListener.class);
}
 
Example #7
Source File: WebSocketMessagesView.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
protected MouseListener getMouseListener() {
    return new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {

            if (SwingUtilities.isRightMouseButton(e)) {

                // Select table item
                int row = view.rowAtPoint(e.getPoint());
                if (row < 0 || !view.getSelectionModel().isSelectedIndex(row)) {
                    view.getSelectionModel().clearSelection();
                    if (row >= 0) {
                        view.getSelectionModel().setSelectionInterval(row, row);
                    }
                }

                View.getSingleton().getPopupMenu().show(e.getComponent(), e.getX(), e.getY());
            }
        }
    };
}
 
Example #8
Source File: XDataViewer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void registerForMouseEvent(Component comp,
                                         MouseListener mouseListener) {
    if(comp instanceof JScrollPane) {
        JScrollPane pane = (JScrollPane) comp;
        comp = pane.getViewport().getView();
    }
    if(comp instanceof Container) {
        Container container = (Container) comp;
        Component[] components = container.getComponents();
        for(int i = 0; i < components.length; i++) {
            registerForMouseEvent(components[i], mouseListener);
        }
    }

    //No registration for XOpenTypedata that are themselves clickable.
    //No registration for JButton that are themselves clickable.
    if(comp != null &&
       (!(comp instanceof XOpenTypeViewer.XOpenTypeData) &&
        !(comp instanceof JButton)) )
        comp.addMouseListener(mouseListener);
}
 
Example #9
Source File: XDataViewer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void registerForMouseEvent(Component comp,
                                         MouseListener mouseListener) {
    if(comp instanceof JScrollPane) {
        JScrollPane pane = (JScrollPane) comp;
        comp = pane.getViewport().getView();
    }
    if(comp instanceof Container) {
        Container container = (Container) comp;
        Component[] components = container.getComponents();
        for(int i = 0; i < components.length; i++) {
            registerForMouseEvent(components[i], mouseListener);
        }
    }

    //No registration for XOpenTypedata that are themselves clickable.
    //No registration for JButton that are themselves clickable.
    if(comp != null &&
       (!(comp instanceof XOpenTypeViewer.XOpenTypeData) &&
        !(comp instanceof JButton)) )
        comp.addMouseListener(mouseListener);
}
 
Example #10
Source File: TransitionView.java    From PIPE with MIT License 6 votes vote down vote up
/**
 * Constructor
 *
 * @param model             underlying transition model
 * @param controller        Petri net controller of the Petri net the transition is housed in
 * @param parent            parent of the view
 * @param transitionHandler mouse listener actions for the transition when in edit mode
 * @param animationHandler  mouse listener actions for the transition when in animation mode
 */
public TransitionView(Transition model, PetriNetController controller, Container parent,
                      MouseInputAdapter transitionHandler, MouseListener animationHandler) {
    super(model.getId(), model, controller, controller.getTransitionController(model), parent,
            new Rectangle2D.Double(-model.getWidth()/2, -model.getHeight()/2, model.getWidth(), model.getHeight()));
    unrotated = new Rectangle2D.Double(-model.getWidth()/2, -model.getHeight()/2, model.getWidth(), model.getHeight());
    setChangeListener();

    highlighted = false;

    rotate(model.getAngle());
    //TODO: DEBUG WHY CANT CALL THIS IN CONSTRUCTOR
    //        changeToolTipText();

    setMouseListener(transitionHandler, animationHandler);

}
 
Example #11
Source File: ComponentsInjectionModule.java    From openAGV with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
  // Within this (private) module, there should only be a single tree panel.
  bind(GroupsTreeViewPanel.class)
      .in(Singleton.class);

  // Bind the tree panel annotated with the given annotation to our single
  // instance and expose only this annotated version.
  bind(AbstractTreeViewPanel.class)
      .to(GroupsTreeViewPanel.class);
  expose(GroupsTreeViewPanel.class);

  // Bind TreeView to the single tree panel, too.
  bind(TreeView.class)
      .to(GroupsTreeViewPanel.class);

  // Bind and expose a single manager for the single tree view/panel.
  bind(GroupsTreeViewManager.class)
      .in(Singleton.class);
  expose(GroupsTreeViewManager.class);

  bind(MouseListener.class)
      .to(GroupsMouseAdapter.class);
}
 
Example #12
Source File: MultipleSubscribersHotObs.java    From tutorials with MIT License 6 votes vote down vote up
private static Observable getObservable() {
    return Observable.create(subscriber -> {
        frame.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                subscriber.onNext(e.getX());
            }
        });
        subscriber.add(Subscriptions.create(() -> {
            LOGGER.info("Clear resources");
            for (MouseListener listener : frame.getListeners(MouseListener.class)) {
                frame.removeMouseListener(listener);
            }
        }));
    });
}
 
Example #13
Source File: ThreadedTableTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void installListeners() {
	MouseListener[] mouseListeners = header.getMouseListeners();
	for (MouseListener l : mouseListeners) {
		if (!(l instanceof GTableMouseListener)) {
			continue;
		}

		header.removeMouseListener(l);
		header.addMouseListener(new SpyMouseListenerWrapper(l, recorder));
	}

	model.addSortListener(spySortListener);
	model.addThreadedTableModelListener(spyLoadListener);
}
 
Example #14
Source File: AliquotOptionsDialog.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
/** Creates new form AliquotOptionsDialog
 * @param parent 
 * @param modal 
 * @param aliquotName
 * @param aliquotOptions  
 */
public AliquotOptionsDialog(java.awt.Frame parent,
        boolean modal, String aliquotName,
        Map<String, String> aliquotOptions) {

    super(parent, modal);

    setLocationRelativeTo(parent);
    setAlwaysOnTop(modal);

    initComponents();

    this.aliquotName = aliquotName;
    this.aliquotOptions = aliquotOptions;

    this.aliquotOptionsSaved = new HashMap<String, String>();
    aliquotOptionsSaved.putAll(aliquotOptions);

    alquotName_label.setText("Aliquot: " + getAliquotName());

    MouseListener myColorChooserListener =
            new ColorChooserListener(aliquotOptions);
    includedBorderColor_label.addMouseListener(myColorChooserListener);
    includedFillColor_label.addMouseListener(myColorChooserListener);
    includedCenterColor_label.addMouseListener(myColorChooserListener);
    excludedBorderColor_label.addMouseListener(myColorChooserListener);
    excludedFillColor_label.addMouseListener(myColorChooserListener);
    excludedCenterColor_label.addMouseListener(myColorChooserListener);


    initDialogContent();

}
 
Example #15
Source File: MainPanel.java    From java-swing-tips with MIT License 5 votes vote down vote up
private static void addListenerToJMenu(JMenuBar menuBar, MouseListener l) {
  // for (Component menu: menuBar.getComponents()) {
  for (MenuElement menu: menuBar.getSubElements()) {
    if (menu instanceof JMenu) {
      ((JMenu) menu).addMouseListener(l);
    }
  }
}
 
Example #16
Source File: GTree.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Need to override the removeMouseListener method of the JTree to defer to the
 *  delegate mouse listener.  The GTree uses a mouse listener delegate for itself
 *  and the JTree it wraps.  When the delegate was installed, it moved all the existing mouse
 *  listeners from the JTree to the delegate. All listener remove calls should also
 *  be moved to the delegate.   Otherwise, some Ghidra components that use a convention/pattern
 *  to avoid listener duplication by first removing a listener before adding it,
 *  don't work and duplicates get added.
 */
@Override
public synchronized void removeMouseListener(MouseListener l) {
	if (mouseListenerDelegate == null) {
		super.removeMouseListener(l);
	}
	else {
		mouseListenerDelegate.removeMouseListener(l);
	}
}
 
Example #17
Source File: SwingWrapperClickConsumer.java    From CrossMobile with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void mousePressed(MouseEvent e) {
    SwingGraphicsBridge.component.mousePressed(e);
    if (active)
        for (MouseListener mouse1 : mouse)
            mouse1.mousePressed(e);
}
 
Example #18
Source File: NodeContextModel.java    From jeddict with Apache License 2.0 5 votes vote down vote up
private static MouseListener getRemoveWidgetAction(final INodeWidget widget) {
    return new java.awt.event.MouseAdapter() {
        @Override
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            widget.remove(true);
            NBModelerUtil.hideContextPalette(widget.getModelerScene());
            widget.getModelerScene().getModelerPanelTopComponent().changePersistenceState(false);
        }
    };
}
 
Example #19
Source File: GameplayImagesPanel.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
GameplayImagesPanel(final MouseListener aListener) {

        // Card highlight setting.
        final JLabel highlightLabel = new JLabel(MText.get(_S41));
        final String[] Highlightchoices = {
            MText.get(_S42),
            MText.get(_S43),
            MText.get(_S44),
            MText.get(_S45)
        };
        highlightComboBox = new JComboBox<>(Highlightchoices);
        highlightComboBox.setSelectedItem(CONFIG.getHighlight());
        highlightComboBox.setToolTipText(MText.get(_S46));
        highlightComboBox.setFocusable(false);
        highlightComboBox.addMouseListener(aListener);

        mouseWheelPopupCheckBox = new MCheckBox(MText.get(_S28), CONFIG.isMouseWheelPopup());
        mouseWheelPopupCheckBox.setFocusable(false);
        mouseWheelPopupCheckBox.setToolTipText(MText.get(_S29));
        mouseWheelPopupCheckBox.addMouseListener(aListener);

        popupDelaySlider = new SliderPanel(MText.get(_S30), 0, 5000, 100, CONFIG.getPopupDelay());
        popupDelaySlider.setToolTipText(MText.get(_S31));
        popupDelaySlider.addMouseListener(aListener);

        pauseGamePopupCheckBox = new MCheckBox(MText.get(_S34), CONFIG.isGamePausedOnPopup());
        pauseGamePopupCheckBox.setFocusable(false);
        pauseGamePopupCheckBox.setToolTipText(MText.get(_S35));
        pauseGamePopupCheckBox.addMouseListener(aListener);

        setLayout(new MigLayout("flowx, wrap 2, insets 16, gapy 10"));
        add(highlightLabel);
        add(highlightComboBox);
        add(pauseGamePopupCheckBox.component(), "spanx 2");
        add(mouseWheelPopupCheckBox.component(), "spanx 2");
        add(popupDelaySlider, "w 100%, spanx 2");
    }
 
Example #20
Source File: SimpleTimeSlider.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void addMouseListener(MouseListener listener) {
    if(getCursor().getType() != Cursor.W_RESIZE_CURSOR) {
        setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    }
    super.addMouseListener(listener);
}
 
Example #21
Source File: Main_CustomersFrame.java    From Hotel-Properties-Management-System with GNU General Public License v2.0 5 votes vote down vote up
private MouseListener openCustomerListener() {
	final MouseAdapter adapter = new MouseAdapter() {
		@Override
		public void mousePressed(MouseEvent e) {

			if (e.getClickCount() == 2) {

				final int rowIndex = customerTable.getSelectedRow();
				final String name = customerTable.getValueAt(rowIndex, 2).toString();
				final String lastname = customerTable.getValueAt(rowIndex, 3).toString();

				theCustomer = customerDaoImpl.findCustomerByName(name, lastname);

				custWindow.setId(theCustomer.getCustomerId() + "");
				custWindow.setName(theCustomer.getFirstName());
				custWindow.setSurname(theCustomer.getLastName());
				custWindow.setDocument(theCustomer.getDocument());
				custWindow.setDocNo(theCustomer.getDocumentNo());
				custWindow.setCountry(theCustomer.getCountry());
				custWindow.setDateOfBirth(theCustomer.getDateOfBirth());
				custWindow.setEmail(theCustomer.getEmail());
				custWindow.setFatherName(theCustomer.getFatherName());
				custWindow.setMotherName(theCustomer.getMotherName());
				custWindow.setGender(theCustomer.getGender());
				custWindow.setPhone(theCustomer.getPhone());
				custWindow.setMariaggeStaus(theCustomer.getMaritalStatus());
				custWindow.setReservationId(theCustomer.getReservationId() + "");
				custWindow.setInfoMessage(" ");
				
				custWindow.setVisible(true);
				
				loggingEngine.setMessage("Displaying customer...");
				loggingEngine.setMessage("Displayed customer details : " + theCustomer.toString());
			}

			super.mousePressed(e);
		}
	};
	return adapter;
}
 
Example #22
Source File: JMapController.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
public JMapController(JMapViewer map) {
    this.map = map;
    if (this instanceof MouseListener)
        map.addMouseListener((MouseListener) this);
    if (this instanceof MouseWheelListener)
        map.addMouseWheelListener((MouseWheelListener) this);
    if (this instanceof MouseMotionListener)
        map.addMouseMotionListener((MouseMotionListener) this);
}
 
Example #23
Source File: BalloonManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void handleMouseOver( Container c, MouseListener ml ) {
    c.addMouseListener(ml);
    for( Component child : c.getComponents() ) {
        child.addMouseListener(ml);
        if( child instanceof Container )
            handleMouseOver((Container)child, ml);
    }
}
 
Example #24
Source File: MessageViewHolderCacheHelper.java    From xyTalk-pc with GNU Affero General Public License v3.0 5 votes vote down vote up
private void clearMouseListener(JComponent component)
{
    for (MouseListener l : component.getMouseListeners())
    {
        if (l instanceof MessageMouseListener)
        {
           component.removeMouseListener(l);
        }
    }
}
 
Example #25
Source File: PreferredSizePanel.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
private JComboBox<ImageSizePresets> getSizePresetsCombo(MouseListener aListener) {
    cboPresets.setModel(new DefaultComboBoxModel<>(ImageSizePresets.values()));
    cboPresets.getModel().setSelectedItem(CONFIG.getPreferredImageSize());
    cboPresets.setToolTipText(getTooltip());
    cboPresets.addMouseListener(aListener);
    return cboPresets;
}
 
Example #26
Source File: BalloonManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void handleMouseOver( Container c, MouseListener ml ) {
    c.addMouseListener(ml);
    for( Component child : c.getComponents() ) {
        child.addMouseListener(ml);
        if( child instanceof Container )
            handleMouseOver((Container)child, ml);
    }
}
 
Example #27
Source File: Game.java    From Lunar with MIT License 5 votes vote down vote up
/**
 * Clear all mouse listeners. NOTE: this method will also remove the default listener.
 */
public void clearMouseListeners() {
    MouseListener[] listeners = frame.getMouseListeners();
    for (MouseListener listener : listeners) {
        removeMouseListener(listener);
    }
}
 
Example #28
Source File: ThemesActionPanel.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
private JButton getThemeFolderButton(MouseListener aListener) {
    JButton btn = new JButton(getActionIcon(MagicIcon.OPEN));
    btn.setToolTipText(String.format("<b>%s</b><br>%s", MText.get(_S1), MText.get(_S2)));
    btn.addMouseListener(aListener);
    btn.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doOpenThemeFolder();
        }
    });
    return btn;
}
 
Example #29
Source File: CourseTabFactory.java    From tmc-intellij with MIT License 5 votes vote down vote up
public void createCourseSpecificTab(
        ObjectFinder finder,
        ProjectOpener opener,
        String course,
        JTabbedPane tabbedPaneBase,
        CourseAndExerciseManager courseAndExerciseManager) {
    logger.info("Creating course specific tab. @CourseTabFactory");
    final JBScrollPane panel = new JBScrollPane();
    final JBList list = new JBList();
    list.setCellRenderer(new ProjectListRenderer());

    DefaultListModel defaultListModel = new DefaultListModel();
    panel.setBorder(BorderFactory.createTitledBorder(""));

    ProjectListManagerHolder.get()
            .addExercisesToList(finder, course, defaultListModel, courseAndExerciseManager);

    if (defaultListModel.getSize() <= 0) {
        return;
    }

    list.setName(course);
    list.setModel(defaultListModel);

    MouseListener mouseListener = createMouseListenerForWindow(opener, panel, list);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.addMouseListener(mouseListener);

    panel.setName(course);
    panel.setViewportView(list);

    ProjectListManagerHolder.get().addList(list);
    tabbedPaneBase.addTab(course, panel);
    tabbedPaneBase.addMouseListener(tabMouseListener(tabbedPaneBase));
    setScrollBarToBottom(course, tabbedPaneBase, panel);
}
 
Example #30
Source File: ThemesPanel.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
private JPanel getThemeLayoutPanel(MouseListener aListener) {
    JPanel panel = new JPanel(new MigLayout("wrap 3, insets 0 0 10 0",
        "[][grow][]"));
    panel.add(themeComboBox, "spanx 2, w 100%");
    panel.add(new ThemesActionPanel(this, aListener));
    panel.add(rollOverColorButton, "w 24!");
    panel.add(new JLabel(MText.get(_S6)), "spanx 2");
    panel.setBorder(BorderFactory.createMatteBorder(
            0, 0, 1, 0, getBackground().darker()));
    return panel;
}