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

The following examples show how to use java.awt.event.MouseEvent#BUTTON2_MASK . 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 check out the related API usage on the sidebar.
Example 1
Source File: Root.java    From pdfxtk with Apache License 2.0 6 votes vote down vote up
public boolean mouseDragged(MouseEvent event, double scale) {
     boolean m = super.mouseDragged(event, scale);

     if (!m && (0 != (event.getModifiers() & MouseEvent.BUTTON2_MASK))) {
Point distance = context.getDragDistance();

JScrollBar hb = context.browserPanel.getHorizontalScrollBar();
JScrollBar vb = context.browserPanel.getVerticalScrollBar();

hb.setValue(hb.getValue()-distance.x);
vb.setValue(vb.getValue()-distance.y);

// Compensate for the distance we have moved
event.translatePoint(-distance.x, -distance.y);

context.setMousePosition(event);
return true;
     }
     return m;
   }
 
Example 2
Source File: Block.java    From pdfxtk with 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 3
Source File: Block.java    From pdfxtk with 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 4
Source File: TextArea2.java    From pdfxtk with Apache License 2.0 6 votes vote down vote up
public boolean mouseClickedAction(MouseEvent event) {
   //	System.out.println("mouse clicked action; event = " + 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 5
Source File: TextArea2.java    From pdfxtk with 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 6
Source File: TabbedPaneContentUI.java    From consulo with 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 7
Source File: Root.java    From pdfxtk with Apache License 2.0 5 votes vote down vote up
public boolean mousePressed(MouseEvent event, double scale) {
     boolean m = super.mousePressed(event, scale);
     if (!m && (0 != (event.getModifiers() & MouseEvent.BUTTON2_MASK))) {
event.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
return true;
     }
     return m;
   }
 
Example 8
Source File: Root.java    From pdfxtk with Apache License 2.0 5 votes vote down vote up
public boolean mouseReleased(MouseEvent event, double scale) {
     boolean m = super.mouseReleased(event, scale);
     if (!m && (0 != (event.getModifiers() & MouseEvent.BUTTON2_MASK))) {
event.getComponent().setCursor(Cursor.getDefaultCursor());
return true;
     }
     return m;
   }
 
Example 9
Source File: Polygon.java    From pdfxtk with 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 File: Polygon.java    From pdfxtk with 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, 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 11
Source File: TextArea.java    From pdfxtk with 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 12
Source File: TextArea.java    From pdfxtk with 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 13
Source File: Block2.java    From pdfxtk with 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 14
Source File: Block2.java    From pdfxtk with 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 15
Source File: TextArea.java    From pdfxtk with 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 16
Source File: TextArea.java    From pdfxtk with 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;
   }