Java Code Examples for java.awt.event.MouseEvent#BUTTON1_MASK

The following examples show how to use java.awt.event.MouseEvent#BUTTON1_MASK . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: pdfxtk   File: DocNavigateUI.java    License: Apache License 2.0 6 votes vote down vote up
public void mouseClicked(MouseEvent e) {
	DocNode mouseOverN = (DocNode) tgPanel.getMouseOverN();
    DocEdge mouseOverE = (DocEdge) tgPanel.getMouseOverE();
    DocNode select = (DocNode) tgPanel.getSelect();
    if ((e.getModifiers() & MouseEvent.BUTTON1_MASK)!=0) { 
        if (mouseOverN != null) {                    
            if (e.getClickCount()==1) {
               // docGBPanel.setSelect(mouseOverN);
            	tgPanel.setSelect(mouseOverN);                        
            }
            else {                   
                tgPanel.setSelect(mouseOverN);                    
                docGBPanel.setLocale(mouseOverN);
            }
        }
        /*
        else if (mouseOverE != null)
        {
        	tgPanel.setSelect(mouseOverE);
        }
        */
    }   
}
 
Example 2
Source Project: ontopia   File: NavigateUI.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void mouseClicked(MouseEvent e) {
  TMAbstractNode mouseOverN = (TMAbstractNode)tgPanel.getMouseOverN();

  if (e.getModifiers() == MouseEvent.BUTTON1_MASK) {
    if (mouseOverN != null) {
      if (e.getClickCount() == 2) {
        this.killSingleClick();
        this.performOperation(controller.getConfigurationManager()
            .getGeneralDoubleClick(), mouseOverN);
      } else if (e.getClickCount() == 1) {
        this.spawnSingleClick(mouseOverN);
      }
    }
  }
}
 
Example 3
Source Project: pdfxtk   File: Block.java    License: Apache License 2.0 6 votes vote down vote up
/**
    * Mouse clicked - calls the "clickX" handler
    *
    * @param context Current browser context
    * @param event Mouse event
    */    
   public boolean mouseClickedAction(MouseEvent event) {
     if ((click1Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON1_MASK))) {
context.actionFactory.handleAction(click1Handler, click1HandlerOpt, this, context);
return true;
     }
     if ((click2Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON2_MASK))) {
context.actionFactory.handleAction(click2Handler, click2HandlerOpt, this, context);
return true;
     }
     if ((click3Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON3_MASK))) {
context.actionFactory.handleAction(click3Handler, click3HandlerOpt, this, context);
return true;
     }
     return super.mouseClickedAction(event);
   }
 
Example 4
Source Project: pdfxtk   File: Block.java    License: Apache License 2.0 6 votes vote down vote up
/**
    * Mouse pressed - calls the "pressX" handler
    *
    * @param context Current browser context
    * @param event Mouse event
    */
   public boolean mousePressedAction(MouseEvent event) {
     if ((press1Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON1_MASK))) {
context.actionFactory.handleAction(press1Handler, press1HandlerOpt, this, context);
return true;
     }
     if ((press2Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON2_MASK))) {
context.actionFactory.handleAction(press2Handler, press2HandlerOpt, this, context);
return true;
     }
     if ((press3Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON3_MASK))) {
context.actionFactory.handleAction(press3Handler, press3HandlerOpt, this, context);
return true;
     }
     return false;
   }
 
Example 5
Source Project: pdfxtk   File: DocWrapperUI.java    License: Apache License 2.0 6 votes vote down vote up
public void mouseClicked(MouseEvent e) {
    DocNode mouseOverN = (DocNode) tgPanel.getMouseOverN();
    DocEdge mouseOverE = (DocEdge) tgPanel.getMouseOverE();
    //DocNode select = (DocNode) tgPanel.getSelect();
    if ((e.getModifiers() & MouseEvent.BUTTON1_MASK)!=0) { 
        if (mouseOverN != null) {                    
            if (e.getClickCount()==1) {
               // docGBPanel.setSelect(mouseOverN);
            	tgPanel.setSelect(mouseOverN);                        
            }
            else {                   
                tgPanel.setSelect(mouseOverN);                    
                docGBPanel.setLocale(mouseOverN);
            }
        }
        else if (mouseOverE != null)
        {
        	tgPanel.setSelect(mouseOverE);
        }
    }   
}
 
Example 6
Source Project: pdfxtk   File: TextArea2.java    License: Apache License 2.0 6 votes vote down vote up
public boolean mousePressedAction(MouseEvent event) {
   	//System.out.println("mouse pressed action; event = " + event);
     if ((press1Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON1_MASK))) {
context.actionFactory.handleAction(press1Handler, null, this, context);
return true;
     }
     if ((press2Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON2_MASK))) {
context.actionFactory.handleAction(press2Handler, null, this, context);
return true;
     }
     if ((press3Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON3_MASK))) {
context.actionFactory.handleAction(press3Handler, null, this, context);
return true;
     }
     return false;
   }
 
Example 7
public int mapMouseUpModifier(int code, int modifiers) {
    int mod = mapModifier(modifiers);
    switch (code) {
    case 0:
        mod = mod | MouseEvent.BUTTON1_MASK;
        break;
    case 2:
        mod = mod | MouseEvent.BUTTON3_MASK;
        break;
    default:
    }
    return mod;
}
 
Example 8
Source Project: consulo   File: TabbedPaneContentUI.java    License: Apache License 2.0 5 votes vote down vote up
protected void processMouseEvent(MouseEvent e) {
  if (e.isPopupTrigger()) { // Popup doesn't activate clicked tab.
    showPopup(e.getX(), e.getY());
    return;
  }

  if (!e.isShiftDown() && (MouseEvent.BUTTON1_MASK & e.getModifiers()) > 0) { // RightClick without Shift modifiers just select tab
    if (MouseEvent.MOUSE_RELEASED == e.getID()) {
      TabbedPaneUI ui = getUI();
      int index = ui.tabForCoordinate(this, e.getX(), e.getY());
      if (index != -1) {
        setSelectedIndex(index);
      }
      hideMenu();
    }
  }
  else if (e.isShiftDown() && (MouseEvent.BUTTON1_MASK & e.getModifiers()) > 0) { // Shift+LeftClick closes the tab
    if (MouseEvent.MOUSE_RELEASED == e.getID()) {
      closeTabAt(e.getX(), e.getY());
      hideMenu();
    }
  }
  else if ((MouseEvent.BUTTON2_MASK & e.getModifiers()) > 0) { // MouseWheelClick closes the tab
    if (MouseEvent.MOUSE_RELEASED == e.getID()) {
      closeTabAt(e.getX(), e.getY());
      hideMenu();
    }
  }
  else if ((MouseEvent.BUTTON3_MASK & e.getModifiers()) > 0 && SystemInfo.isWindows) { // Right mouse button doesn't activate tab
  }
  else {
    super.processMouseEvent(e);
  }
}
 
Example 9
Source Project: pdfxtk   File: Polygon.java    License: Apache License 2.0 5 votes vote down vote up
public boolean mouseClickedAction(MouseEvent event) {
     if ((click1Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON1_MASK))) {
context.actionFactory.handleAction(click1Handler, click1HandlerOpt, this, context);
return true;
     }
     if ((click2Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON2_MASK))) {
context.actionFactory.handleAction(click2Handler, click2HandlerOpt, this, context);
return true;
     }
     if ((click3Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON3_MASK))) {
context.actionFactory.handleAction(click3Handler, click3HandlerOpt, this, context);
return true;
     }
     return super.mouseClickedAction(event);
   }
 
Example 10
Source Project: pdfxtk   File: TextArea.java    License: Apache License 2.0 5 votes vote down vote up
public boolean mouseClickedAction(MouseEvent event) {
     if ((click1Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON1_MASK))) {
context.actionFactory.handleAction(click1Handler, null, this, context);
return true;
     }
     if ((click2Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON2_MASK))) {
context.actionFactory.handleAction(click2Handler, null, this, context);
return true;
     }
     if ((click3Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON3_MASK))) {
context.actionFactory.handleAction(click3Handler, null, this, context);
return true;
     }
     return super.mouseClickedAction(event);
   }
 
Example 11
Source Project: pdfxtk   File: TextArea.java    License: Apache License 2.0 5 votes vote down vote up
public boolean mousePressedAction(MouseEvent event) {
     if ((press1Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON1_MASK))) {
context.actionFactory.handleAction(press1Handler, null, this, context);
return true;
     }
     if ((press2Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON2_MASK))) {
context.actionFactory.handleAction(press2Handler, null, this, context);
return true;
     }
     if ((press3Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON3_MASK))) {
context.actionFactory.handleAction(press3Handler, null, this, context);
return true;
     }
     return false;
   }
 
Example 12
Source Project: pdfxtk   File: Block2.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Mouse clicked - calls the "clickX" handler
 * 
 * @param context
 *            Current browser context
 * @param event
 *            Mouse event
 */
public boolean mouseClickedAction(MouseEvent event)
{
	// added 13.11.06
	if (event.getModifiers() == MouseEvent.BUTTON1_MASK)
	{
		if (element.getAttribute("info") != null)
		{
			System.out.println(element.getAttribute("info"));
		}
		else
		{
			System.out.println("No information available for this item.");
		}
	}
	
	if ((click1Handler != null)
		&& (0 != (event.getModifiers() & MouseEvent.BUTTON1_MASK)))
	{
		context.actionFactory.handleAction(click1Handler,
			click1HandlerOpt, this, context);
		return true;
	}
	if ((click2Handler != null)
		&& (0 != (event.getModifiers() & MouseEvent.BUTTON2_MASK)))
	{
		context.actionFactory.handleAction(click2Handler,
			click2HandlerOpt, this, context);
		return true;
	}
	if ((click3Handler != null)
		&& (0 != (event.getModifiers() & MouseEvent.BUTTON3_MASK)))
	{
		context.actionFactory.handleAction(click3Handler,
			click3HandlerOpt, this, context);
		return true;
	}
	return super.mouseClickedAction(event);
}
 
Example 13
Source Project: pdfxtk   File: Block2.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Mouse pressed - calls the "pressX" handler
 * 
 * @param context
 *            Current browser context
 * @param event
 *            Mouse event
 */
public boolean mousePressedAction(MouseEvent event)
{
	//System.out.println("in mousePressedAction");
	if ((press1Handler != null)
		&& (0 != (event.getModifiers() & MouseEvent.BUTTON1_MASK)))
	{
		context.actionFactory.handleAction(press1Handler,
			press1HandlerOpt, this, context);
		return true;
	}
	if ((press2Handler != null)
		&& (0 != (event.getModifiers() & MouseEvent.BUTTON2_MASK)))
	{
		context.actionFactory.handleAction(press2Handler,
			press2HandlerOpt, this, context);
		return true;
	}
	if ((press3Handler != null)
		&& (0 != (event.getModifiers() & MouseEvent.BUTTON3_MASK)))
	{
		context.actionFactory.handleAction(press3Handler,
			press3HandlerOpt, this, context);
		return true;
	}
	return false;
}
 
Example 14
Source Project: pdfxtk   File: TextArea.java    License: Apache License 2.0 5 votes vote down vote up
public boolean mouseClickedAction(MouseEvent event) {
     if ((click1Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON1_MASK))) {
context.actionFactory.handleAction(click1Handler, null, this, context);
return true;
     }
     if ((click2Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON2_MASK))) {
context.actionFactory.handleAction(click2Handler, null, this, context);
return true;
     }
     if ((click3Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON3_MASK))) {
context.actionFactory.handleAction(click3Handler, null, this, context);
return true;
     }
     return super.mouseClickedAction(event);
   }
 
Example 15
Source Project: pdfxtk   File: TextArea.java    License: Apache License 2.0 5 votes vote down vote up
public boolean mousePressedAction(MouseEvent event) {
     if ((press1Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON1_MASK))) {
context.actionFactory.handleAction(press1Handler, null, this, context);
return true;
     }
     if ((press2Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON2_MASK))) {
context.actionFactory.handleAction(press2Handler, null, this, context);
return true;
     }
     if ((press3Handler != null) && (0 != (event.getModifiers() & MouseEvent.BUTTON3_MASK))) {
context.actionFactory.handleAction(press3Handler, null, this, context);
return true;
     }
     return false;
   }
 
Example 16
Source Project: pdfxtk   File: DocNavigateUI.java    License: Apache License 2.0 5 votes vote down vote up
public void mousePressed(MouseEvent e) {
    if (e.isPopupTrigger()) {
       triggerPopup(e);
    }
    else {
    	DocNode mouseOverN = (DocNode) tgPanel.getMouseOverN();            
        if (e.getModifiers() == MouseEvent.BUTTON1_MASK) { 
            if (mouseOverN == null) 
                hvDragUI.activate(e);
            else 
                dragNodeUI.activate(e);
        }
    }
}
 
Example 17
Source Project: pdfxtk   File: DocWrapperUI.java    License: Apache License 2.0 5 votes vote down vote up
public void mousePressed(MouseEvent e) {
    if (e.isPopupTrigger()) {
       triggerPopup(e);
    }
    else {
        DocNode mouseOverN = (DocNode) tgPanel.getMouseOverN();            
        if (e.getModifiers() == MouseEvent.BUTTON1_MASK) { 
            if (mouseOverN == null) 
                hvDragUI.activate(e);
            else 
                dragNodeUI.activate(e);
        }
    }
}
 
Example 18
Source Project: netbeans   File: NonEditabilityTest.java    License: Apache License 2.0 4 votes vote down vote up
public void testClickInvokesCustomEditor() throws Exception {
    if( !ExtTestCase.canSafelyRunFocusTests() )
        return;
    
    Node n = new ANode();
    setCurrentNode (n, sheet);

    sleep();

    requestFocus (sheet.table);
    sleep();

    Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
    if (owner == sheet.table) { //sanity check to avoid random failures on some window managers

        System.out.println ("About to click cell");

        Rectangle r = sheet.table.getCellRect(1, 1, false);
        final MouseEvent me = new MouseEvent (sheet.table, MouseEvent.MOUSE_PRESSED,
            System.currentTimeMillis(), MouseEvent.BUTTON1_MASK, r.x + 3,
            r.y + 3, 2, false);

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                sheet.table.dispatchEvent(me);
            }
        });

        sleep();
        sleep();

        System.out.println ("Now checking focus");

        owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
        assertTrue ("Focus owner should be custom editor, not " + owner, owner instanceof JTextArea);

        JComponent jc = (JComponent) owner;
        assertTrue ("Custom editor should have been invoked, but focus owner's top level ancestor is not a dialog", jc.getTopLevelAncestor() instanceof Dialog);

        Dialog d = (Dialog) jc.getTopLevelAncestor();

        d.setVisible(false);
    }

    requestFocus (sheet.table);
    sleep();

    owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
    if (owner == sheet.table) { //sanity check to avoid random failures on some window managers
        pressKey(sheet.table, KeyEvent.VK_SPACE);
        sleep();

        owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
        assertTrue ("After pressing a key, focus owner should still be the table, not " + owner, sheet.table == owner);
    }

}
 
Example 19
/**
 * Processes all caught <code>MouseEvent</code>s.
 *
 * @param e the <code>MouseEvent</code>
 */
private void processMouseEvents(MouseEvent e) {
    int tabNumber = getUI().tabForCoordinate(this, e.getX(), e.getY());
    if (tabNumber < 0)
        return;
    CloseTabIcon icon = (CloseTabIcon) getIconAt(tabNumber);
    if (icon != null) {
        Rectangle rect = icon.getBounds();
        Point pos = headerViewport == null ? new Point() : headerViewport
                .getViewPosition();
        Rectangle drawRect = new Rectangle(rect.x - pos.x, rect.y - pos.y,
                rect.width, rect.height);

        if (e.getID() == MouseEvent.MOUSE_PRESSED) {
            icon.mousepressed = e.getModifiers() == MouseEvent.BUTTON1_MASK;
            repaint(drawRect);
        } else if (e.getID() == MouseEvent.MOUSE_MOVED
                || e.getID() == MouseEvent.MOUSE_DRAGGED
                || e.getID() == MouseEvent.MOUSE_CLICKED) {
            pos.x += e.getX();
            pos.y += e.getY();
            if (rect.contains(pos)) {
                if (e.getID() == MouseEvent.MOUSE_CLICKED) {
                    int selIndex = getSelectedIndex();
                    if (fireCloseTab(selIndex)) {
                        if (selIndex > 0) {
                            // to prevent uncatchable null-pointers
                            Rectangle rec = getUI().getTabBounds(this,
                                    selIndex - 1);

                            MouseEvent event = new MouseEvent((Component) e
                                    .getSource(), e.getID() + 1, System
                                    .currentTimeMillis(), e.getModifiers(),
                                    rec.x, rec.y, e.getClickCount(), e
                                    .isPopupTrigger(), e
                                    .getButton());
                            dispatchEvent(event);
                        }
                        // the tab is being closed
                        // removeTabAt(tabNumber);
                        remove(selIndex);
                    } else {
                        icon.mouseover = false;
                        icon.mousepressed = false;
                        repaint(drawRect);
                    }
                } else {
                    icon.mouseover = true;
                    icon.mousepressed = e.getModifiers() == MouseEvent.BUTTON1_MASK;
                }
            } else {
                icon.mouseover = false;
            }
            repaint(drawRect);
        }
    }
}
 
Example 20
Source Project: pumpernickel   File: ClickSensitivityControl.java    License: MIT License 4 votes vote down vote up
Key(Component c) {
	button = MouseEvent.BUTTON1;
	modifiers = MouseEvent.BUTTON1_MASK;
	component = new WeakReference<Component>(c);
}