javax.swing.JComponent#addMouseListener ( )源码实例Demo

下面列出了javax.swing.JComponent#addMouseListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: littleluck   文件: LuckComboBoxUI.java
/**
 * <pre>
 * 初始化边框焦点监听器
 *
 * Initializes the border focus listener
 * <pre>
 *
 * @param c
 */
protected void installFocusListener(JComponent c)
{
    handle = new LuckComboboxFocusHandle();

    isFocusBorder = UIManager.getBoolean(LuckComboBoxUIBundle.ISFOCUSBORDER);

    if (isFocusBorder)
    {
        contentShape = new RoundRectangle2D.Float(0, 0, 0, 0, 8, 8);

        borderShape = new RoundRectangle2D.Float(0, 0, 0, 0, 8, 8);

        c.addMouseListener(handle);

        c.addFocusListener(handle);
    }
}
 
源代码2 项目: audiveris   文件: Rubber.java
/**
 * Actually register the rubber as the mouse listener for the provided component.
 *
 * @param component the related component
 */
public final void connectComponent (JComponent component)
{
    // Clean up if needed
    disconnectComponent(this.component);

    // Remember the related component (to get visible rect, etc ...)
    this.component = component;

    if (component != null) {
        // To be notified of mouse clicks
        component.removeMouseListener(this); // No multiple notifications
        component.addMouseListener(this);

        // To be notified of mouse mouvements
        component.removeMouseMotionListener(this); // No multiple notifs
        component.addMouseMotionListener(this);

        // To be notified of mouse  wheel mouvements
        component.removeMouseWheelListener(this); // No multiple notifs
        component.addMouseWheelListener(this);
    }
}
 
源代码3 项目: pumpernickel   文件: NavigationPanelUI.java
@Override
public void installUI(JComponent c) {
	super.installUI(c);

	spinner.addChangeListener(valueListener);
	label = createLabel();
	maybeAdd(label, "Label");
	UpdateLabelListener changeListener = new UpdateLabelListener(
			(JSpinner) c, label);
	changeListener.refreshLabel();
	c.putClientProperty(PROPERTY_LABEL_CHANGE_LISTENER, changeListener);
	((JSpinner) c).addChangeListener(changeListener);
	((JSpinner) c).addPropertyChangeListener(changeListener);
	c.addMouseListener(dragListener);
	c.addMouseMotionListener(dragListener);
	c.setBorder(null);
}
 
源代码4 项目: pumpernickel   文件: PaletteUI.java
@Override
public void installUI(JComponent c) {
	super.installUI(c);
	c.addPropertyChangeListener(JPalette.PROPERTY_COLORS,
			propertyLayoutListener);
	c.addPropertyChangeListener(PaletteUI.PROPERTY_HIGHLIGHT,
			propertyRepaintListener);
	c.setLayout(new PaletteLayoutManager());
	c.setRequestFocusEnabled(true);
	c.addMouseListener(mouseListener);
	c.addFocusListener(focusListener);
	c.addKeyListener(keyListener);
	c.setFocusable(true);
	Fields fields = getFields((JPalette) c, true);
	fields.install();
	c.setBorder(new CompoundBorder(new LineBorder(new Color(0xB0B0B0)),
			new FocusedBorder(getDefaultBorder())));
	relayoutCells((JPalette) c);
}
 
源代码5 项目: littleluck   文件: LuckFormattedTextFieldUI.java
/**
 * <pre>
 * 初始化边框焦点监听器
 *
 * Initializes the border focus listener
 * <pre>
 *
 * @param c
 */
protected void installFocusListener(JComponent c)
{
    handle = createFocusHandle();

    borderShape = new RoundRectangle2D.Float(0, 0, 0, 0, 8, 8);

    c.addMouseListener(handle);

    c.addFocusListener(handle);
}
 
源代码6 项目: ghidra   文件: CodeBrowserPlugin.java
@Override
public void addMarginProvider(MarginProvider marginProvider) {
	JComponent component = marginProvider.getComponent();

	// just in case we get repeated calls
	component.removeMouseListener(focusingMouseListener);
	component.addMouseListener(focusingMouseListener);
	connectedProvider.getListingPanel().addMarginProvider(marginProvider);
}
 
源代码7 项目: marathonv5   文件: CheckListItemPanel.java
protected void setMouseListener(JComponent c) {
    c.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (selectedItem != null)
                selectedItem.deselect();
            selectedItem = CheckListItemPanel.this;
            CheckListItemPanel.this.select();
        }
    });
}
 
源代码8 项目: pumpernickel   文件: BreadCrumbUI.java
@Override
public void installUI(JComponent c) {
	super.installUI(c);

	c.addMouseListener(mouseListener);
	c.addPropertyChangeListener(JBreadCrumb.PATH_KEY, refreshUIListener);
	c.addPropertyChangeListener(JBreadCrumb.FORMATTER_KEY,
			refreshUIListener);
	c.addPropertyChangeListener(PROPERTY_SEPARATOR_ICON, refreshUIListener);
	refreshUI((JBreadCrumb<?>) c);
}
 
源代码9 项目: Rails   文件: HexHighlightMouseListener.java
/**
 * @param pf Portfolio which is dynamically evaluated at mouse-even-time for
 * any contained private companies
 */
public static void addMouseListener(JComponent c,ORUIManager orUIManager,PortfolioModel pf) {
    if (isEnabled(false)) {
        HexHighlightMouseListener l = new HexHighlightMouseListener(orUIManager);
        l.portfolio = pf;
        c.addMouseListener(l);
    }
}
 
源代码10 项目: Rails   文件: HexHighlightMouseListener.java
/**
 * @param tileId ID of the tile the occurrences of which should be highlighted on
 * the map
 * @param enableIrrespectiveOfHighlightConfig If true, the mouse listener is
 * enabled irrespective of the base configuration. Needed since some highlighting
 * should not be disabled by configuration.
 */
public static void addMouseListener(JComponent c,ORUIManager orUIManager, Tile tile,boolean enableIrrespectiveOfHighlightConfig) {
    if (isEnabled(enableIrrespectiveOfHighlightConfig)) {
        HexHighlightMouseListener l = new HexHighlightMouseListener(orUIManager);
        l.tile = tile;
        c.addMouseListener(l);
    }
}
 
源代码11 项目: Rails   文件: HexHighlightMouseListener.java
/**
 * @param p Public company the hexes associated to it (home, destination, ...) are
 * to be highlighted (in case of events)
 * @param enableIrrespectiveOfHighlightConfig If true, the mouse listener is
 * enabled irrespective of the base configuration. Needed since some highlighting
 * should not be disabled by configuration.
 */
public static void addMouseListener(JComponent c,ORUIManager orUIManager,PublicCompany p,boolean enableIrrespectiveOfHighlightConfig) {
    if (isEnabled(enableIrrespectiveOfHighlightConfig)) {
        HexHighlightMouseListener l = new HexHighlightMouseListener(orUIManager);
        l.addToHexListDistinct(p.getHomeHexes());
        l.addToHexListDistinct(p.getDestinationHex());
        c.addMouseListener(l);
    }
}
 
public ComponentTitledBorder(Component comp, JComponent container,
        Border border) {
    this.comp = comp;
    this.container = container;
    this.border = border;
    container.addMouseListener(this);
}
 
源代码13 项目: PyramidShader   文件: MultiThumbSliderUI.java
@Override
public void installUI(JComponent slider) {
	slider.addMouseListener(this);
	slider.addMouseMotionListener(this);
	slider.addFocusListener(focusListener);
	slider.addKeyListener(keyListener);
	slider.addComponentListener(compListener);
	slider.addPropertyChangeListener(propertyListener);
	slider.addPropertyChangeListener(THUMB_SHAPE_PROPERTY, thumbShapeListener);
	calculateGeometry();
}
 
源代码14 项目: rcrs-server   文件: PanZoomListener.java
/**
   Construct a PanZoomListener that listens for events on a JComponent.
   @param component The component to listen for mouse events on.
*/
public PanZoomListener(JComponent component) {
    this.component = component;
    component.addMouseListener(this);
    component.addMouseMotionListener(this);
    component.addMouseWheelListener(this);
    panTriggerModifiers = InputEvent.BUTTON1_DOWN_MASK;
    zoomTriggerModifiers = InputEvent.BUTTON2_DOWN_MASK;
    zoomThreshold = DEFAULT_MOUSE_ZOOM_THRESHOLD;
    enabled = true;
}
 
源代码15 项目: littleluck   文件: LuckPasswordFieldUI.java
/**
 * <pre>
 * 初始化边框焦点监听器
 *
 * Initializes the border focus listener
 * <pre>
 *
 * @param c
 */
protected void installFocusListener(JComponent c)
{
    handle = createFocusHandle();

    borderShape = new RoundRectangle2D.Float(0, 0, 0, 0, 8, 8);

    c.addMouseListener(handle);

    c.addFocusListener(handle);
}
 
源代码16 项目: pumpernickel   文件: WritingTextArea.java
@Override
public void installUI(JComponent c) {
	super.installUI(c);
	c.addKeyListener(keyListener);
	c.addMouseListener(mouseListener);
	layout.addPropertyChangeListener(layoutListener);
}
 
源代码17 项目: pumpernickel   文件: MultiThumbSliderUI.java
@Override
public void installUI(JComponent slider) {
	slider.addMouseListener(this);
	slider.addMouseMotionListener(this);
	slider.addFocusListener(focusListener);
	slider.addKeyListener(keyListener);
	slider.addComponentListener(compListener);
	slider.addPropertyChangeListener(propertyListener);
	slider.addPropertyChangeListener(THUMB_SHAPE_PROPERTY,
			thumbShapeListener);
	calculateGeometry();
}
 
源代码18 项目: Rails   文件: HexMap.java
private void addMouseListener(MouseListener ml) {
    for (JComponent l : layers) {
        l.addMouseListener(ml);
    }
}
 
源代码19 项目: freecol   文件: Canvas.java
/**
 * Adds a component on this Canvas inside a frame.
 *
 * @param comp The component to add to the canvas.
 * @param toolBox Should be set to true if the resulting frame is
 *     used as a toolbox (that is: it should not be counted as a
 *     frame).
 * @param popupPosition A preferred {@code PopupPosition}.
 * @param resizable Whether this component can be resized.
 * @return The {@code JInternalFrame} that was created and added.
 */
private JInternalFrame addAsFrame(JComponent comp, boolean toolBox,
                                  PopupPosition popupPosition,
                                  boolean resizable) {
    final int FRAME_EMPTY_SPACE = 60;

    final JInternalFrame f = (toolBox) ? new ToolBoxFrame()
        : new JInternalFrame();
    Container con = f.getContentPane();
    if (con instanceof JComponent) {
        JComponent c = (JComponent)con;
        c.setOpaque(false);
        c.setBorder(null);
    }

    if (comp.getBorder() != null) {
        if (comp.getBorder() instanceof EmptyBorder) {
            f.setBorder(Utility.blankBorder(10, 10, 10, 10));
        } else {
            f.setBorder(comp.getBorder());
            comp.setBorder(Utility.blankBorder(5, 5, 5, 5));
        }
    } else {
        f.setBorder(null);
    }

    final FrameMotionListener fml = new FrameMotionListener(f);
    comp.addMouseMotionListener(fml);
    comp.addMouseListener(fml);
    if (f.getUI() instanceof BasicInternalFrameUI) {
        BasicInternalFrameUI biu = (BasicInternalFrameUI) f.getUI();
        biu.setNorthPane(null);
        biu.setSouthPane(null);
        biu.setWestPane(null);
        biu.setEastPane(null);
    }

    f.getContentPane().add(comp);
    f.setOpaque(false);
    f.pack();
    int width = f.getWidth();
    int height = f.getHeight();
    if (width > getWidth() - FRAME_EMPTY_SPACE) {
        width = Math.min(width, getWidth());
    }
    if (height > getHeight() - FRAME_EMPTY_SPACE) {
        height = Math.min(height, getHeight());
    }
    f.setSize(width, height);
    Point p = chooseLocation(comp, width, height, popupPosition);
    f.setLocation(p);
    this.addToCanvas(f, MODAL_LAYER);
    f.setName(comp.getClass().getSimpleName());

    f.setFrameIcon(null);
    f.setVisible(true);
    f.setResizable(resizable);
    try {
        f.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {}

    return f;
}
 
源代码20 项目: mzmine2   文件: ComponentToolTipManager.java
/**
 * Registers a component for tooltip management.
 * <p>
 * This will register key bindings to show and hide the tooltip text only if
 * <code>component</code> has focus bindings. This is done so that components that are not
 * normally focus traversable, such as <code>JLabel</code>, are not made focus traversable as a
 * result of invoking this method.
 * 
 * @param component a <code>JComponent</code> object to add
 * @see JComponent#isFocusTraversable
 */
public void registerComponent(JComponent component) {

  if (!(component instanceof ComponentToolTipProvider))
    return;

  component.addMouseListener(this);
  component.addMouseMotionListener(moveBeforeEnterListener);

  ToolTipManager.sharedInstance().unregisterComponent(component);

}