当前位置: 首页>>代码示例>>Java>>正文


Java MouseEvent.getComponent方法代码示例

本文整理汇总了Java中java.awt.event.MouseEvent.getComponent方法的典型用法代码示例。如果您正苦于以下问题:Java MouseEvent.getComponent方法的具体用法?Java MouseEvent.getComponent怎么用?Java MouseEvent.getComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.event.MouseEvent的用法示例。


在下文中一共展示了MouseEvent.getComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleEntryClick

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
public void handleEntryClick(final MouseEvent mouseEvent) {
	if (!mouseEvent.isPopupTrigger() || !(mouseEvent.getComponent() instanceof JTree)) {
		return;
	}

	JTree treeDir = (JTree)mouseEvent.getComponent();
       final TreePath path = treeDir.getClosestPathForLocation(mouseEvent.getX(), mouseEvent.getY());
       if (path == null) {
       	return;
       }
   	treeDir.setSelectionPath(path);
   	
   	boolean hasStream;
   	try {
   		ByteArrayEditableData data = treeObservable.getBinarySource().getBinaryData();
   		hasStream = (data.getDataSize() > 0);
   	} catch (Exception e) {
   		hasStream = false;
   	}

   	saveStream.setEnabled(hasStream);
   	
   	show(treeDir, mouseEvent.getX(), mouseEvent.getY());
}
 
开发者ID:kiwiwings,项目名称:poi-visualizer,代码行数:25,代码来源:POIContextMenu.java

示例2: mouseReleased

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public final void mouseReleased(final MouseEvent e) {
	FixedMouseAdapter.this.mouseReleased(e);
	final int b = e.getButton() - 1;
	if (b >= 0 && b < NUM_BUTTONS
			&& startPoints[b] != null
			&& startPoints[b].distanceSq(e.getLocationOnScreen()) <= CLICK_SENSITIVITY_SQ) {
		
		if (e.getWhen() > lastClickTime[b] + MULTI_CLICK_SENSITIVITY_MS
				|| lastClickPos[b] == null || lastClickPos[b].distanceSq(e.getLocationOnScreen()) > CLICK_SENSITIVITY_SQ)
			clickCounts[b] = 1;
		else
			clickCounts[b]++;
		
		lastClickPos[b] = e.getLocationOnScreen();
		lastClickTime[b] = e.getWhen();
		
		final MouseEvent newEvent = new MouseEvent(e.getComponent(), MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), e.getY(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), clickCounts[b], false, b + 1);
		FixedMouseAdapter.this.mouseClicked(newEvent);
		
		startPoints[b] = null;
	}
}
 
开发者ID:Njol,项目名称:Motunautr,代码行数:24,代码来源:FixedMouseAdapter.java

示例3: mouseEntered

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void mouseEntered(MouseEvent e) {
  dismissDelay = toolTipManager.getDismissDelay();
  initialDelay = toolTipManager.getInitialDelay();
  reshowDelay = toolTipManager.getReshowDelay();
  enabled = toolTipManager.isEnabled();
  Component component = e.getComponent();
  if(feature != null && !isTooltipSet && component instanceof JLabel) {
    isTooltipSet = true;
    JLabel label = (JLabel)component;
    String toolTip = label.getToolTipText();
    toolTip =
            (toolTip == null || toolTip.equals("")) ? "" : toolTip
                    .replaceAll("</?html>", "") + "<br>";
    toolTip = "<html>" + toolTip + "Right click to get statistics.</html>";
    label.setToolTipText(toolTip);
  }
  // make the tooltip indefinitely shown when the mouse is over
  toolTipManager.setDismissDelay(Integer.MAX_VALUE);
  toolTipManager.setInitialDelay(0);
  toolTipManager.setReshowDelay(0);
  toolTipManager.setEnabled(true);
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:24,代码来源:LuceneDataStoreSearchGUI.java

示例4: eventDispatched

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void eventDispatched(AWTEvent e) {
	if (e instanceof MouseEvent) {
		MouseEvent me = (MouseEvent) e;
		if (!SwingUtilities.isDescendingFrom(me.getComponent(), target)) {
			return;
		}
		if (me.getID() == MouseEvent.MOUSE_RELEASED) {
			// stop when mouse released
			mouseOnScreenPoint = null;
			if (timer.isRunning()) {
				timer.stop();
			}
		} else if (me.getID() == MouseEvent.MOUSE_DRAGGED && me.getComponent() == target) {
			mouseOnScreenPoint = me.getLocationOnScreen();
		} else if (me.getID() == MouseEvent.MOUSE_PRESSED && me.getComponent() == target) {
			mouseOnScreenPoint = me.getLocationOnScreen();
			timer.start();
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:22,代码来源:PanningManager.java

示例5: mouseMoved

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void mouseMoved(MouseEvent e) {
	if(graphics !=null ){
		LinkedPanel panel = (LinkedPanel) e.getComponent();
		Graphics2D g = (Graphics2D) panel.getGraphics();
		g.setTransform(panel.getTransform());
		
		float timeOffset = LayerUtilities.pixelsToUnits(g, e.getX(), true);
		float time = cs.getMin(Axis.X) + timeOffset;
		float frequencyOffset = LayerUtilities.pixelsToUnits(g, panel.getHeight() - e.getY(), false);
		float frequency = cs.getMin(Axis.Y) + frequencyOffset;
		
		float timeDiameter = LayerUtilities.pixelsToUnits(g, 10, true) * 2f;
		float frequencyDiameter = LayerUtilities.pixelsToUnits(g, 10, false)* 2f;
		
	}
	
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:19,代码来源:QIFFTAudioInfoLayer.java

示例6: showPopup

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
private void showPopup(MouseEvent e) {
	if (networkTable.getSelectedRow() >= 0
			&& e.isPopupTrigger()
			&& e.getComponent() instanceof JTable) {
		this.menu.show(e.getComponent(), e.getX(), e.getY());
	}
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:8,代码来源:MultiAlgoScenarioWizard.java

示例7: mousePressed

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void mousePressed( MouseEvent e ) {

    Point p = e.getPoint();
    p = SwingUtilities.convertPoint( e.getComponent(), p, container );
    int tabIndex = container.indexAtLocation( p.x, p.y );

    SingleSelectionModel sel = container.getModel();
    //invoke possible selection change
    if( tabIndex >= 0 && e.getComponent() != container ) {
        CloseableTabComponent tab = ( CloseableTabComponent ) container.getTabComponentAt( tabIndex );
        if( tab.isInCloseButton( e ) ) {
            return;
        }
        tabIndex = container.indexOf( container.getComponentAt( tabIndex ) );
        boolean change = shouldPerformAction( TabDisplayer.COMMAND_SELECT,
                tabIndex, e );
        if( change ) {

            sel.setSelectedIndex( tabIndex );
            Component tc = container.getDataModel().getTab( tabIndex ).getComponent();
            if( null != tc && tc instanceof TopComponent && !(( TopComponent ) tc).isAncestorOf( KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner() ) ) {
                (( TopComponent ) tc).requestActive();
            }
        }
    }
    if( e.isPopupTrigger() ) {
        //Post a popup menu show request

        shouldPerformAction( TabDisplayer.COMMAND_POPUP_REQUEST, tabIndex, e );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:NBTabbedPaneController.java

示例8: mouseEntered

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
public void mouseEntered(MouseEvent e) {
    Component component = e.getComponent();
    if (component instanceof AbstractButton) {
        AbstractButton button = (AbstractButton) component;
        button.setBorderPainted(true);
    }
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:8,代码来源:ButtonTabComponent.java

示例9: mouseExited

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void mouseExited(final MouseEvent e) {
	final Component c = e.getComponent();
	if (c instanceof AbstractButton) {
		final AbstractButton ab = (AbstractButton) c;
		ab.setBorderPainted(false);
	}
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:9,代码来源:JTabPanel.java

示例10: mouseReleased

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public synchronized void mouseReleased(MouseEvent e)
{
	JComponent c = (JComponent) e.getComponent();
	c.setForeground(mTextNormal);
	c.setBackground(mBackgroundNormal);
	c.repaint();
}
 
开发者ID:equella,项目名称:Equella,代码行数:9,代码来源:FlatterCheckBoxUI.java

示例11: addStatistics

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
private void addStatistics(String kind, int count, int numRow,
        final MouseEvent e) {
  JLabel label = (JLabel)e.getComponent();
  if(!label.getToolTipText().contains(kind)) {
    // add the statistics to the tooltip
    String toolTip = label.getToolTipText();
    toolTip = toolTip.replaceAll("</?html>", "");
    toolTip = kind + " = " + count + "<br>" + toolTip;
    toolTip = "<html>" + toolTip + "</html>";
    label.setToolTipText(toolTip);
  }
  if(bottomSplitPane.getDividerLocation()
          / bottomSplitPane.getSize().getWidth() < 0.90) {
    // select the row in the statistics table
    statisticsTabbedPane.setSelectedIndex(1);
    oneRowStatisticsTable.setRowSelectionInterval(numRow, numRow);
    oneRowStatisticsTable.scrollRectToVisible(oneRowStatisticsTable
            .getCellRect(numRow, 0, true));
  } else {
    // display a tooltip
    JToolTip tip = label.createToolTip();
    tip.setTipText(kind + " = " + count);
    PopupFactory popupFactory = PopupFactory.getSharedInstance();
    final Popup tipWindow =
            popupFactory.getPopup(label, tip, e.getX()
                    + e.getComponent().getLocationOnScreen().x, e.getY()
                    + e.getComponent().getLocationOnScreen().y);
    tipWindow.show();
    Date timeToRun = new Date(System.currentTimeMillis() + 2000);
    Timer timer = new Timer("Annic statistics hide tooltip timer", true);
    timer.schedule(new TimerTask() {
      @Override
      public void run() {
        // hide the tooltip after 2 seconds
        tipWindow.hide();
      }
    }, timeToRun);
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:40,代码来源:LuceneDataStoreSearchGUI.java

示例12: eventDispatched

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void eventDispatched(AWTEvent event) {
    if (event instanceof MouseEvent) {
        MouseEvent e = (MouseEvent) event;
        if (e.getID() == MouseEvent.MOUSE_ENTERED) {
            mouseComponent = e.getComponent();
        } else if (e.getID() == MouseEvent.MOUSE_EXITED) {
            mouseComponent = null;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:EventDispatcher.java

示例13: mouseExited

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
public void mouseExited(MouseEvent e) {
    Component component = e.getComponent();
    if (component instanceof AbstractButton) {
        AbstractButton button = (AbstractButton) component;
        button.setBorderPainted(false);
    }
}
 
开发者ID:BlidiWajdi,项目名称:Mujeed-Arabic-Prolog,代码行数:8,代码来源:ButtonTabComponent.java

示例14: mouseDragged

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void mouseDragged(MouseEvent e) {
    Component component = e.getComponent();
    Component rootComponent = SwingUtilities.getRoot(component);
    if (!rectangle.isEmpty() && component instanceof FSWindowLabel && rootComponent instanceof Window) {
        FSWindowSide FSWindowSide = ((FSWindowLabel) component).side;
        updateRectangle(FSWindowSide, e.getX(), e.getY());
        rootComponent.setBounds(rectangle);
    }
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:11,代码来源:ResizeWindowMouseAdapter.java

示例15: mouseExited

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public synchronized void mouseExited(MouseEvent e)
{
	JComponent c = (JComponent) e.getComponent();
	c.setForeground(mTextNormal);
	c.setBackground(mBackgroundNormal);
	c.repaint();
}
 
开发者ID:equella,项目名称:Equella,代码行数:9,代码来源:FlatterCheckBoxUI.java


注:本文中的java.awt.event.MouseEvent.getComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。