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


Java MouseEvent.getWhen方法代码示例

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


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

示例1: sendTreeHandleEvents

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
private void sendTreeHandleEvents(MouseEvent event) {
    int column = model.getTreeColumnIndex();
    int row = rowAtPoint(event.getPoint());
    
    MouseEvent mousePressed = new MouseEvent(treeRenderer,
            MouseEvent.MOUSE_PRESSED,
            event.getWhen(),
            event.getModifiers(),
            event.getX() - getCellRect(row, column, true).x,
            event.getY(),
            event.getClickCount(),
            event.isPopupTrigger());
    MouseEvent mouseReleased = new MouseEvent(treeRenderer,
            MouseEvent.MOUSE_RELEASED,
            event.getWhen(),
            event.getModifiers(),
            event.getX() - getCellRect(row, column, true).x,
            event.getY(),
            event.getClickCount(),
            event.isPopupTrigger());
    
    treeRenderer.dispatchEvent(mousePressed);
    treeRenderer.dispatchEvent(mouseReleased);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:NbiTreeTable.java

示例2: mouseClicked

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
    if( !list.isEnabled() )
        return;
    
    if( e.getClickCount() > 1 ) {
        selIndex = getValidIndex( e.getPoint() );
        if( selIndex >= 0 ) {
            list.setSelectedIndex( selIndex );
            Item item = (Item)list.getModel().getElementAt( selIndex );
            ActionEvent ae = new ActionEvent( e.getSource(), e.getID(), "doubleclick", e.getWhen(), e.getModifiers() );
            item.invokePreferredAction( ae );
            e.consume();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:CategoryList.java

示例3: mouseReleased

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
public void mouseReleased( MouseEvent evt ) {
	if( editShape==null ) {
		currentPoint = -1;
		return;
	}
	drawEdit();
	editShape = null;
	if( evt.isControlDown() || evt.getWhen()-when<500L ) {
		currentPoint = -1;
		return;
	}
	Point2D.Double p = (Point2D.Double)map.getScaledPoint( evt.getPoint() );
	double[] xyz = (double[])points.get( currentPoint );
	xyz[0] = p.x - currentOffset;
	xyz[1] = p.y;
	xyz[2] = getZ(p);
	fireTableRowsUpdated(currentPoint, currentPoint);
	dig.makeProfile();
	map.repaint();
	
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:22,代码来源:LineSegmentsObject.java

示例4: convertMouseEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
private MouseEvent convertMouseEvent( MouseEvent e ) {
    Point convertedPoint = SwingUtilities.convertPoint( (Component)e.getSource(),
            e.getPoint(), list );
    MouseEvent newEvent = new MouseEvent( (Component)e.getSource(),
            e.getID(),
            e.getWhen(),
            e.getModifiers(),
            convertedPoint.x,
            convertedPoint.y,
            e.getClickCount(),
            e.isPopupTrigger() );
    return newEvent;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:FileCompletionPopup.java

示例5: convertMouseEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
private MouseEvent convertMouseEvent(MouseEvent e) {
    Point convertedPoint = SwingUtilities.convertPoint((Component) e.getSource(),
            e.getPoint(), list);
    MouseEvent newEvent = new MouseEvent((Component) e.getSource(),
            e.getID(),
            e.getWhen(),
            e.getModifiers(),
            convertedPoint.x,
            convertedPoint.y,
            e.getClickCount(),
            e.isPopupTrigger());
    return newEvent;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:CompletionPopup.java

示例6: mousePressed

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void mousePressed(MouseEvent e) {
    if (e.isShiftDown()) return;
            
    e.getComponent().requestFocus();
    if (e.getButton() == MouseEvent.BUTTON1) {
        dragAnim.stop();
        bDragging = true;
        dragMem = e.getPoint();
        dragWhen = e.getWhen();
    }
}
 
开发者ID:iapafoto,项目名称:DicomViewer,代码行数:13,代码来源:PanelController.java

示例7: mouseClicked

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e) {
    // hide the balloon by any click
    hide();
    if (e.getButton() == MouseEvent.BUTTON1) {
        ActionEvent aev = new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
                                          liveArguments.getActionCommand(),
                                          e.getWhen(), e.getModifiers());
        XToolkit.postEvent(XToolkit.targetToAppContext(aev.getSource()), aev);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:InfoWindow.java

示例8: isCellEditable

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
/**
 * Overridden to return false, and if the event is a mouse event it is
 * forwarded to the tree.
 * <p>
 * The behavior for this is debatable, and should really be offered as a
 * property. By returning false, all keyboard actions are implemented in
 * terms of the table. By returning true, the tree would get a chance to
 * do something with the keyboard events. For the most part this is ok.
 * But for certain keys, such as left/right, the tree will
 * expand/collapse where as the table focus should really move to a
 * different column. Page up/down should also be implemented in terms of
 * the table. By returning false this also has the added benefit that
 * clicking outside of the bounds of the tree node, but still in the
 * tree column will select the row, whereas if this returned true that
 * wouldn't be the case.
 * <p>
 * By returning false we are also enforcing the policy that the tree
 * will never be editable (at least by a key sequence).
 */
public boolean isCellEditable(EventObject e) {
	if (e instanceof MouseEvent) {
		for (int counter = getColumnCount() - 1; counter >= 0; counter--) {
			if (getColumnClass(counter) == TreeTableModel.class) {
				MouseEvent me = (MouseEvent) e;
				MouseEvent newME = new MouseEvent(tree, me.getID(), me
						.getWhen(), me.getModifiers(), me.getX()
						- getCellRect(0, counter, true).x, me.getY(),
						me.getClickCount(), me.isPopupTrigger());
				tree.dispatchEvent(newME);
				break;
			}
		}
	}
	return false;
}
 
开发者ID:ser316asu,项目名称:Wilmersdorf_SER316,代码行数:36,代码来源:JTreeTable.java

示例9: createEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
private MouseEvent createEvent(final MouseEvent original) {
  return new MouseEvent(original.getComponent(), original.getID(), original.getWhen(), original.getModifiers(), (int) this.getLocation().getX(), (int) this.getLocation().getY(), original.getXOnScreen(), original.getYOnScreen(), original.getClickCount(), original.isPopupTrigger(),
      original.getButton());
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:5,代码来源:Mouse.java

示例10: redispatchComponent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
private boolean redispatchComponent(MouseEvent e) {
    Point p = e.getPoint();
    int index = list.locationToIndex(p);
    if (index < 0 || index >= list.getModel().getSize()) {
        return false;
    }

    ListCellRenderer renderer = list.getCellRenderer();
    if (null == renderer) {
        return false;
    }
    Component renComponent = renderer.getListCellRendererComponent(list, list.getModel().getElementAt(index), index, false, false);
    if (null == renComponent) {
        return false;
    }
    Rectangle rect = list.getCellBounds(index, index);
    if (null == rect) {
        return false;
    }
    renComponent.setBounds(0, 0, rect.width, rect.height);
    renComponent.doLayout();
    Point p3 = rect.getLocation();

    Point p2 = new Point(p.x - p3.x, p.y - p3.y);
    Component dispatchComponent =
            SwingUtilities.getDeepestComponentAt(renComponent,
            p2.x, p2.y);
    if ( e.isPopupTrigger() &&
         dispatchComponent instanceof LinkButton && 
         !((LinkButton)dispatchComponent).isHandlingPopupEvents() ) 
    {
        return false;
    } 
    if (dispatchComponent instanceof AbstractButton) {
        if (!((AbstractButton) dispatchComponent).isEnabled()) {
            return false;
        }
        Point p4 = SwingUtilities.convertPoint(renComponent, p2, dispatchComponent);
        MouseEvent newEvent = new MouseEvent(dispatchComponent,
                e.getID(),
                e.getWhen(),
                e.getModifiers(),
                p4.x, p4.y,
                e.getClickCount(),
                e.isPopupTrigger(),
                MouseEvent.NOBUTTON);
        dispatchComponent.dispatchEvent(newEvent);
        list.repaint(rect);
        e.consume();
        return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:54,代码来源:AbstractListUI.java

示例11: mouseEventHitTreeHandle

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
private boolean mouseEventHitTreeHandle(MouseEvent event) {
    if ((event.getID() != MouseEvent.MOUSE_PRESSED)) {
        return false;
    }
    
    int column = columnAtPoint(event.getPoint());
    int row = rowAtPoint(event.getPoint());
    
    if (column == model.getTreeColumnIndex()) {
        MouseEvent mousePressed = new MouseEvent(treeRenderer,
                MouseEvent.MOUSE_PRESSED,
                event.getWhen(),
                event.getModifiers(),
                event.getX() - getCellRect(row, column, true).x,
                event.getY(),
                event.getClickCount(),
                event.isPopupTrigger());
        MouseEvent mouseReleased = new MouseEvent(treeRenderer,
                MouseEvent.MOUSE_RELEASED,
                event.getWhen(),
                event.getModifiers(),
                event.getX() - getCellRect(row, column, true).x,
                event.getY(),
                event.getClickCount(),
                event.isPopupTrigger());
        
        TreePath targetPath = treeRenderer.getPathForRow(row);
        
        boolean currentState = treeRenderer.isExpanded(targetPath);
        
        // dispatch the event and see whether the node changed its state
        model.consumeNextExpansionEvent();
        treeRenderer.dispatchEvent(mousePressed);
        treeRenderer.dispatchEvent(mouseReleased);
        
        if (treeRenderer.isExpanded(targetPath) == currentState) {
            model.cancelConsume();
            return false;
        } else {
            model.consumeNextExpansionEvent();
            treeRenderer.dispatchEvent(mousePressed);
            treeRenderer.dispatchEvent(mouseReleased);
            return true;
        }
    } else {
        return false;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:49,代码来源:NbiTreeTable.java

示例12: isCellEditable

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
/**
 * This is overridden to forward the event to the tree and start editor timer.
 */
@Override
public boolean isCellEditable(EventObject e) {
    if (lastRow != -1) {
        TreePath tp = tree.getPathForRow(lastRow);
        org.openide.nodes.Node n = tp != null ? Visualizer.findNode(tp.getLastPathComponent()) : null;

        if ((n == null) || !n.canRename()) {
            //return false;
            canEdit = false;
        }
    }

    if (canEdit && (e != null) && (e.getSource() instanceof Timer)) {
        return true;
    }

    if (canEdit && shouldStartEditingTimer(e)) {
        startEditingTimer();
    } else if (shouldStopEditingTimer(e)) {
        timer.stop();
    }

    if (e instanceof MouseEvent) {
        MouseEvent me = (MouseEvent) e;
        int column = getTreeColumnIndex();

        if (SwingUtilities.isLeftMouseButton(me) && (me.getClickCount() == 2)) {
            TreePath path = tree.getPathForRow(TreeTable.this.rowAtPoint(me.getPoint()));
            Rectangle r = tree.getPathBounds(path);

            if ((me.getX() < (r.x - positionX)) || (me.getX() > (r.x - positionX + r.width))) {
                me.translatePoint(r.x - me.getX(), 0);
            }
        }

        MouseEvent newME = new MouseEvent(
                TreeTable.this.tree, me.getID(), me.getWhen(), me.getModifiers()+me.getModifiersEx(),
                me.getX() - getCellRect(0, column, true).x + positionX, me.getY(), me.getClickCount(),
                me.isPopupTrigger()
            );
        TreeTable.this.tree.dispatchEvent(newME);
    }

    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:49,代码来源:TreeTable.java

示例13: getToolTipText

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public String getToolTipText(MouseEvent event) {
    try {
        // Required to really get the tooltip text:
        putClientProperty("ComputingTooltip", Boolean.TRUE);

        toolTip = null;
        String tipText = null;
        Point p = event.getPoint();

        // Locate the renderer under the event location
        int hitColumnIndex = columnAtPoint(p);
        int hitRowIndex = rowAtPoint(p);

        if ((hitColumnIndex != -1) && (hitRowIndex != -1)) {
            //Outline tbl = (Outline) table;
            if (convertColumnIndexToModel(hitColumnIndex) == 0) {   // tree column index
                // For tree column get the tooltip directly from the renderer data provider
                RenderDataProvider rendata = getRenderDataProvider();
                if (rendata != null) {
                    Object value = getValueAt(hitRowIndex, hitColumnIndex);
                    if (value != null) {
                        String toolT = rendata.getTooltipText(value);
                        if (toolT != null && (toolT = toolT.trim ()).length () > 0) {
                            tipText = toolT;
                        }
                    }
                }
            }

            TableCellRenderer renderer = getCellRenderer(hitRowIndex, hitColumnIndex);
            Component component = prepareRenderer(renderer, hitRowIndex, hitColumnIndex);

            // Now have to see if the component is a JComponent before
            // getting the tip
            if (component instanceof JComponent) {
                // Convert the event to the renderer's coordinate system
                Rectangle cellRect = getCellRect(hitRowIndex, hitColumnIndex, false);
                p.translate(-cellRect.x, -cellRect.y);
                MouseEvent newEvent = new MouseEvent(component, event.getID(),
                                          event.getWhen(), event.getModifiers(),
                                          p.x, p.y,
                                          event.getXOnScreen(),
                                          event.getYOnScreen(),
                                          event.getClickCount(),
                                          event.isPopupTrigger(),
                                          MouseEvent.NOBUTTON);

                if (tipText == null) {
                    tipText = ((JComponent)component).getToolTipText(newEvent);
                }
                toolTip = ((JComponent)component).createToolTip();
            }
        }

        // No tip from the renderer get our own tip
        if (tipText == null)
            tipText = getToolTipText();

        if (tipText != null) {
            tipText = tipText.trim();
            if (tipText.length() > MAX_TOOLTIP_LENGTH &&
                !tipText.regionMatches(false, 0, "<html>", 0, 6)) {   // Do not cut HTML tooltips

                tipText = tipText.substring(0, MAX_TOOLTIP_LENGTH) + "...";
            }
        }
        return tipText;
    } finally {
        putClientProperty("ComputingTooltip", Boolean.FALSE);
    }
    //return super.getToolTipText(event);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:74,代码来源:Outline.java

示例14: isCellEditable

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
/**
 * Overridden to return false, and if the event is a mouse event it is
 * forwarded to the tree.
 * <p>
 * The behavior for this is debatable, and should really be offered as a
 * property. By returning false, all keyboard actions are implemented in
 * terms of the table. By returning true, the tree would get a chance to
 * do something with the keyboard events. For the most part this is ok.
 * But for certain keys, such as left/right, the tree will
 * expand/collapse where as the table focus should really move to a
 * different column. Page up/down should also be implemented in terms of
 * the table. By returning false this also has the added benefit that
 * clicking outside of the bounds of the tree node, but still in the
 * tree column will select the row, whereas if this returned true that
 * wouldn't be the case.
 * <p>
 * By returning false we are also enforcing the policy that the tree
 * will never be editable (at least by a key sequence).
 */
public boolean isCellEditable(EventObject e) {
    if (e instanceof MouseEvent) {
        for (int counter = getColumnCount() - 1; counter >= 0; counter--) {
            if (getColumnClass(counter) == TreeTableModel.class) {
                MouseEvent me = (MouseEvent) e;
                MouseEvent newME = new MouseEvent(tree, me.getID(), me
                        .getWhen(), me.getModifiers(), me.getX()
                        - getCellRect(0, counter, true).x, me.getY(),
                        me.getClickCount(), me.isPopupTrigger());
                tree.dispatchEvent(newME);
                break;
            }
        }
    }
    return false;
}
 
开发者ID:ser316asu,项目名称:Reinickendorf_SER316,代码行数:36,代码来源:TaskTable.java

示例15: RelativeMouseEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
public RelativeMouseEvent(MouseEvent event, Point point, Point relative) {
	super(event.getComponent(), event.getID(), event.getWhen(), event.getModifiers(),
			point.x-relative.x, point.y-relative.y, point.x, point.y,
			event.getClickCount(), event.isPopupTrigger(), event.getButton());
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:6,代码来源:Guitilities.java


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