java.awt.event.MouseMotionListener#java.awt.event.MouseListener源码实例Demo

下面列出了java.awt.event.MouseMotionListener#java.awt.event.MouseListener 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * 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);
}
 
源代码2 项目: openAGV   文件: ComponentsInjectionModule.java
@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);
}
 
源代码3 项目: openAGV   文件: ComponentsInjectionModule.java
@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);
}
 
源代码4 项目: openjdk-8-source   文件: XDataViewer.java
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);
}
 
源代码5 项目: dragonwell8_jdk   文件: XDataViewer.java
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);
}
 
源代码6 项目: Cafebabe   文件: OpList.java
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();
			}
		}
	});

}
 
源代码7 项目: zap-extensions   文件: WebSocketMessagesView.java
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());
            }
        }
    };
}
 
源代码8 项目: tutorials   文件: MultipleSubscribersHotObs.java
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);
            }
        }));
    });
}
 
源代码9 项目: PIPE   文件: TransitionView.java
/**
 * 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);

}
 
源代码10 项目: jdk8u-jdk   文件: XDataViewer.java
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);
}
 
源代码11 项目: openjdk-jdk8u   文件: XDataViewer.java
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);
}
 
源代码12 项目: netbeans   文件: LinkButtonPanel.java
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());
}
 
源代码13 项目: netbeans   文件: PropertySheetOperator.java
/**
 * Dispatch mouse event directly in org.openide.explorer.propertysheet.PSheet
 * to make it more reliable.
 */
@Override
public void clickForPopup() {
    final Component eventsHandleComponent = findSubComponent(new ComponentChooser() {

        @Override
        public boolean checkComponent(Component comp) {
            return comp.getClass().getSimpleName().equals("PSheet");  //NOI18N
        }

        @Override
        public String getDescription() {
            return "org.openide.explorer.propertysheet.PSheet";  //NOI18N
        }
    });
    if (eventsHandleComponent != null) {
        runMapping(new MapVoidAction("mousePressed") {

            @Override
            public void map() {
                ((MouseListener) eventsHandleComponent).mousePressed(
                        new MouseEvent(getSource(),
                        MouseEvent.MOUSE_PRESSED,
                        System.currentTimeMillis(),
                        0,
                        getCenterXForClick(),
                        getCenterYForClick(),
                        1,
                        true));
            }
        });
    } else {
        super.clickForPopup();
    }
}
 
源代码14 项目: magarena   文件: GameplayImagesPanel.java
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");
    }
 
源代码15 项目: BurpTabEssentials   文件: TabWatcher.java
private void removeListenerFromTabbedPanels(JTabbedPane tabbedPane, Component tabComponent){
    int componentIndex = tabbedPane.indexOfComponent(tabComponent);
    if(componentIndex == -1) {
        return;
    }
    String componentTitle = tabbedPane.getTitleAt(componentIndex);
    if(!supportedTabTitles.contains(componentTitle)) return;

    for (MouseListener mouseListener : tabComponent.getMouseListeners()) {
        if(mouseListener instanceof TabClickHandler){
            tabComponent.removeMouseListener(mouseListener);
        }
    }
}
 
private MouseListener customMouseEvent() {
	final MouseAdapter adapter = new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent e) {
			selectedRowIndex = companiesTable.getSelectedRow();
			if(selectedRowIndex >= 0) {
				
				selectedCompanyName = companiesTable.getValueAt(selectedRowIndex, 0).toString(); 
			}
			super.mouseClicked(e);
		}
	};
	return adapter;
}
 
源代码17 项目: freecol   文件: ConstructionPanel.java
/**
 * Removes PropertyChangeListeners and MouseListeners
 */
public void cleanup() {
    if (colony != null) {
        colony.removePropertyChangeListener(EVENT, this);
    }
    for (MouseListener listener : getMouseListeners()) {
        removeMouseListener(listener);
    }
}
 
源代码18 项目: Course_Generator   文件: JMapController.java
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);
}
 
源代码19 项目: netbeans   文件: PalettePanel.java
private MouseListener mouseListener() {
    if( null == mouseListener ) {
        mouseListener = new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent event) {
                if( SwingUtilities.isRightMouseButton( event ) && null != model ) {
                    JPopupMenu popup = Utilities.actionsToPopup( model.getActions(), PalettePanel.this );
                    Utils.addCustomizationMenuItems( popup, getController(), getSettings() );
                    popup.show( (Component)event.getSource(), event.getX(), event.getY() );
                }
            }
        };
    }
    return mouseListener;
}
 
源代码20 项目: netbeans   文件: CompletionScrollPane.java
public CompletionScrollPane(JTextComponent editorComponent,
ListSelectionListener listSelectionListener, MouseListener mouseListener) {
    
    setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER);
    setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_AS_NEEDED);
    
    // Use maximumSize property to store the limit of the preferred size
    setMaximumSize(CompletionSettings.getInstance(editorComponent).completionPaneMaximumSize());
    // At least 2 items; do -1 for title height
    int maxVisibleRowCount = Math.max(2,
        getMaximumSize().height / CompletionLayout.COMPLETION_ITEM_HEIGHT - 1);

    // Add the completion view
    view = new CompletionJList(maxVisibleRowCount, mouseListener, editorComponent);

    // Apply selection colors as CompletionJList selecion also means focused
    Color selBg = UIManager.getColor("nb.completion.selectedBackground"); //NOI18N
    if (selBg != null) {
        view.setSelectionBackground(selBg);
    }
    Color selFg = UIManager.getColor("nb.completion.selectedForeground"); //NOI18N
    if (selFg != null) {
        view.setSelectionForeground(selFg);
    }

    if (listSelectionListener != null) {
        view.addListSelectionListener(listSelectionListener);
    }
    setViewportView(view);
    installKeybindings(editorComponent);
}
 
源代码21 项目: amidst   文件: ProfileSelectPanel.java
@CalledOnlyBy(AmidstThread.EDT)
private MouseListener createMouseListener() {
	return new MouseAdapter() {
		@CalledOnlyBy(AmidstThread.EDT)
		@Override
		public void mousePressed(MouseEvent e) {
			if (!isLoading()) {
				doMousePressed(e.getPoint());
			}
		}
	};
}
 
源代码22 项目: ET_Redux   文件: AliquotOptionsDialog.java
/** 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();

}
 
源代码23 项目: jeddict   文件: NodeContextModel.java
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);
        }
    };
}
 
源代码24 项目: pdfxtk   文件: Awt.java
public void handle(AsyncInvocation.Invocation i, AsyncInvocation.Result result) {
  if(i.object instanceof MouseListener) {
    MouseListener ml = (MouseListener)i.object;
    if(     check(i.method, "mouseClicked",  MouseEvent.class))	ml.mouseClicked( (MouseEvent)i.args[0]);
    else if(check(i.method, "mouseEntered",  MouseEvent.class))	ml.mouseEntered( (MouseEvent)i.args[0]);
    else if(check(i.method, "mouseExited",   MouseEvent.class))	ml.mouseExited(  (MouseEvent)i.args[0]);
    else if(check(i.method, "mousePressed",  MouseEvent.class))	ml.mousePressed( (MouseEvent)i.args[0]);
    else if(check(i.method, "mouseReleased", MouseEvent.class)) ml.mouseReleased((MouseEvent)i.args[0]);
    else throw new IllegalArgumentException("Unknown MouseListener method:" + i.method);
    result.set(null);
  } 
}
 
源代码25 项目: CrossMobile   文件: SwingWrapperClickConsumer.java
@Override
public void mousePressed(MouseEvent e) {
    SwingGraphicsBridge.component.mousePressed(e);
    if (active)
        for (MouseListener mouse1 : mouse)
            mouse1.mousePressed(e);
}
 
源代码26 项目: ghidra   文件: GTree.java
/**
 * 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);
	}
}
 
源代码27 项目: java-swing-tips   文件: MainPanel.java
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);
    }
  }
}
 
源代码28 项目: ghidra   文件: ThreadedTableTest.java
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);
}
 
源代码29 项目: wandora   文件: SimpleTimeSlider.java
@Override
public void addMouseListener(MouseListener listener) {
    if(getCursor().getType() != Cursor.W_RESIZE_CURSOR) {
        setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    }
    super.addMouseListener(listener);
}
 
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;
}