本文整理汇总了Java中org.netbeans.api.visual.action.WidgetAction.WidgetMouseEvent.getButton方法的典型用法代码示例。如果您正苦于以下问题:Java WidgetMouseEvent.getButton方法的具体用法?Java WidgetMouseEvent.getButton怎么用?Java WidgetMouseEvent.getButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.visual.action.WidgetAction.WidgetMouseEvent
的用法示例。
在下文中一共展示了WidgetMouseEvent.getButton方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mousePressed
import org.netbeans.api.visual.action.WidgetAction.WidgetMouseEvent; //导入方法依赖的package包/类
public State mousePressed (Widget widget, WidgetMouseEvent event) {
if (isLocked ())
return State.createLocked (widget, this);
if (event.getButton () == MouseEvent.BUTTON1 && event.getClickCount () == 1) {
movingWidget = widget;
initialMouseLocation = event.getPoint ();
setModifiers(event.getModifiers());
setModifiersEx(event.getModifiersEx());
originalSceneLocation = provider.getOriginalLocation (widget);
if (originalSceneLocation == null)
originalSceneLocation = new Point ();
dragSceneLocation = widget.convertLocalToScene (event.getPoint ());
provider.movementStarted (widget);
if (provider instanceof ReportAlignWithMoveStrategyProvider)
{
((ReportAlignWithMoveStrategyProvider)provider).setAction(this);
}
return State.createLocked (widget, this);
}
return State.REJECTED;
}
示例2: mousePressed
import org.netbeans.api.visual.action.WidgetAction.WidgetMouseEvent; //导入方法依赖的package包/类
@Override
public State mousePressed(Widget widget, WidgetMouseEvent event) {
if (event.getClickCount() == 1) {
if (event.getButton() == MouseEvent.BUTTON1 || event.getButton() == MouseEvent.BUTTON2) {
addNode("node" + nodeCounter++).setPreferredLocation(widget.convertLocalToScene(event.getPoint()));
return State.CONSUMED;
}
}
return State.REJECTED;
}
示例3: mouseClicked
import org.netbeans.api.visual.action.WidgetAction.WidgetMouseEvent; //导入方法依赖的package包/类
@Override
public State mouseClicked(Widget widget, WidgetMouseEvent event) {
if (event.getButton() == MouseEvent.BUTTON1) {
JDialog dialog = new JDialog((Frame) null, "Mouse Clicked " + event.getClickCount());
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
dialog.setBounds((screenSize.width - WIDTH) / 2, (screenSize.height - HEIGHT) / 2, WIDTH, HEIGHT);
dialog.setVisible(true);
return State.CONSUMED;
}
return State.REJECTED;
}
示例4: mousePressed
import org.netbeans.api.visual.action.WidgetAction.WidgetMouseEvent; //导入方法依赖的package包/类
@Override
public State mousePressed(Widget widget, WidgetMouseEvent event) {
// TODO: Solve this differently?
if (event.getButton() != MouseEvent.BUTTON2) {
return innerAction.mousePressed(widget, new WidgetMouseEvent(event.getEventID(), new MouseEvent(panel, (int) event.getEventID(), event.getWhen(), event.getModifiersEx(), event.getPoint().x, event.getPoint().y, event.getClickCount(), event.isPopupTrigger(), MouseEvent.BUTTON1)));
} else {
return super.mousePressed(widget, event);
}
}
示例5: mousePressed
import org.netbeans.api.visual.action.WidgetAction.WidgetMouseEvent; //导入方法依赖的package包/类
public State mousePressed (Widget widget, WidgetMouseEvent event) {
if (isLocked ())
return State.createLocked (widget, this);
if (event.getButton () == MouseEvent.BUTTON1 || event.getButton () == MouseEvent.BUTTON3)
{
rightButton = event.getButton () == MouseEvent.BUTTON3;
widget.getScene().getView().requestFocus();
invertSelection = (event.getModifiersEx () & MouseEvent.CTRL_DOWN_MASK) != 0;
Point localLocation = event.getPoint ();
if (provider.isSelectionAllowed (widget, localLocation, invertSelection)) {
aiming = provider.isAimingAllowed (widget, localLocation, invertSelection);
if (aiming) {
updateState (widget, localLocation);
return State.createLocked (widget, this);
} else {
provider.select (widget, localLocation, invertSelection);
// check if the widget is still selected...
Object object = null;
if (widget instanceof SelectionWidget)
{
object = ((ObjectScene)widget.getScene()).findObject ( ((SelectionWidget)widget).getRealWidget() );
}
else
{
object = ((ObjectScene)widget.getScene()).findObject (widget);
}
if (!((ObjectScene)widget.getScene()).getSelectedObjects().contains (object))
{
return State.CONSUMED;
}
return State.CHAIN_ONLY;
}
}
}
return State.REJECTED;
}
示例6: mouseReleased
import org.netbeans.api.visual.action.WidgetAction.WidgetMouseEvent; //导入方法依赖的package包/类
public State mouseReleased (final Widget widget, final WidgetMouseEvent event) {
if (aiming) {
Point point = event.getPoint ();
updateState (widget, point);
if (aimedWidget != null)
provider.select (widget, point, invertSelection);
updateState (null, null);
aiming = false;
if (event.getButton() == MouseEvent.BUTTON3 && rightButton)
{
// if there is a PopupMenuAction, use it..
List<WidgetAction> actions = widget.getActions().getActions();
for (final WidgetAction action : actions)
{
if (action.getClass().getName().contains("PopupMenuAction"))
{
SwingUtilities.invokeLater(new Runnable() {
public void run() {
action.mousePressed(widget, event);
action.mouseReleased(widget, event);
}
});
break;
}
}
}
return State.CONSUMED;
}
return super.mouseReleased (widget, event);
}