本文整理汇总了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());
}
示例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;
}
}
示例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);
}
示例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();
}
}
}
示例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;
}
}
示例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());
}
}
示例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 );
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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;
}
}
}
示例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);
}
}
示例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);
}
}
示例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();
}