Java Code Examples for javax.swing.SwingUtilities#isLeftMouseButton()

The following examples show how to use javax.swing.SwingUtilities#isLeftMouseButton() . 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 check out the related API usage on the sidebar.
Example 1
Source Project: pdfxtk   File: MultiColumnListUI.java    License: Apache License 2.0 6 votes vote down vote up
public void mouseDragged(MouseEvent e) {
     if (!SwingUtilities.isLeftMouseButton(e)) {
return;
     }

     if (!list.isEnabled()) {
return;
     }

     if (e.isShiftDown() || e.isControlDown()) {
return;
     }
    
     int row = MultiColumnListUI.this.locationToIndex(e.getX(), e.getY());
     if (row != -1) {
Rectangle cellBounds = getCellBounds(list, row, row);
if (cellBounds != null) {
  list.scrollRectToVisible(cellBounds);
  list.setSelectionInterval(row, row);
}
     }
   }
 
Example 2
Source Project: chipster   File: TreePanel.java    License: MIT License 6 votes vote down vote up
@Override
  public void mousePressed(MouseEvent e) {

maybeShowPopup(e);
  	// double click
  	if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() > 1) {
  		
  		DataItem selectedItem = this.getSelectedElementFrom(e);
  		
  		if (selectedItem instanceof DataBean) {        			
  			application.visualiseWithBestMethod(FrameType.MAIN);
  			
  		} else if (selectedItem instanceof DataFolder) {
  			// select all child beans
  			DataFolder folder = (DataFolder)selectedItem;
  			application.getSelectionManager().clearAll(false, this);
  			application.getSelectionManager().selectMultiple(folder.getChildren(), this);
  		}
  	} 
  }
 
Example 3
Source Project: chipster   File: EditableHeaderUI.java    License: MIT License 6 votes vote down vote up
public void mousePressed(MouseEvent e) {
	if (!SwingUtilities.isLeftMouseButton(e)) {
		return;
	}
	super.mousePressed(e);

	if (header.getResizingColumn() == null) {
		Point p = e.getPoint();
		TableColumnModel columnModel = header.getColumnModel();
		int index = columnModel.getColumnIndexAtX(p.x);
		if (index != -1) {
			if (header.editCellAt(index, e)) {
				setDispatchComponent(e); 
				repostEvent(e); 
			}
		}
	}
}
 
Example 4
@Override
public void mouseClicked(MouseEvent e) {
    JTableHeader header = (JTableHeader) e.getSource();
    JTable table = header.getTable();
    TableColumnModel columnModel = table.getColumnModel();
    int vci = columnModel.getColumnIndexAtX(e.getX());
    int mci = table.convertColumnIndexToModel(vci);
    if (mci == targetColumnIndex) {
        if (SwingUtilities.isLeftMouseButton(e)) {
            TableColumn column = columnModel.getColumn(vci);
            Object v = column.getHeaderValue();
            boolean b = Status.DESELECTED.equals(v);
            TableModel m = table.getModel();
            for (int i = 0; i < m.getRowCount(); i++) {
                m.setValueAt(b, i, mci);
            }
            column.setHeaderValue(b ? Status.SELECTED : Status.DESELECTED);
        } else if (SwingUtilities.isRightMouseButton(e)) {
            if (popupMenu != null) {
                popupMenu.show(table, e.getX(), 0);
            }
        }
    }
}
 
Example 5
Source Project: FlatLaf   File: FlatTitlePane.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void mouseClicked( MouseEvent e ) {
	if( e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton( e ) ) {
		if( e.getSource() == iconLabel ) {
			// double-click on icon closes window
			close();
		} else if( !hasJBRCustomDecoration() &&
			window instanceof Frame &&
			((Frame)window).isResizable() )
		{
			// maximize/restore on double-click
			Frame frame = (Frame) window;
			if( (frame.getExtendedState() & Frame.MAXIMIZED_BOTH) != 0 )
				restore();
			else
				maximize();
		}
	}
}
 
Example 6
@Override
public MouseEvent mouseDragged(MouseEvent mouseEvent)
{
	if (!SwingUtilities.isLeftMouseButton(mouseEvent))
	{
		return mouseEvent;
	}

	int nco = getCharOffset(mouseEvent);
	if (selectionStart != -1)
	{
		selectionEnd = nco;
		cursorAt(selectionStart, selectionEnd);
	}

	return mouseEvent;
}
 
Example 7
Source Project: netbeans   File: TimelinePanel.java    License: Apache License 2.0 5 votes vote down vote up
public void mouseDragged(MouseEvent e){
    if (!SwingUtilities.isLeftMouseButton(e)) return;
    if (draggingRow != null) {
        boolean checkStep = (e.getModifiers() & Toolkit.getDefaultToolkit().
                             getMenuShortcutKeyMask()) == 0;
        chart.setRowHeight(draggingRow.getIndex(), baseHeight + e.getY() - baseY, checkStep);
    }
}
 
Example 8
protected void processMouseEvent(MouseEvent e) {
    int index = indexAtLocation(e.getX(), e.getY());
    
    if (index != -1) {
        if (e.isPopupTrigger()) {
            // Show popup menu for the clicked tab
            final MouseEvent _e = e;
            final int _index = index;
            final Component _component = getComponentAt(index);
            
            SwingUtilities.invokeLater(new Runnable() {
                public void run() { showPopupMenu(_index, _component, _e); };
            });
            
            e.consume();
            return;
        } else if (e.getID() == MouseEvent.MOUSE_CLICKED && SwingUtilities.isMiddleMouseButton(e)) {
            // Close tab using middle button click
            if (isClosableAt(index)) closeTab(getComponentAt(index));
            
            e.consume();
            return;
        } else if (e.getID() == MouseEvent.MOUSE_PRESSED && !SwingUtilities.isLeftMouseButton(e)) {
            // Do not switch tabs using middle or right mouse button
            e.consume();
            return;
        }
    }
    
    super.processMouseEvent(e);
}
 
Example 9
Source Project: importer-exporter   File: ZoomPainter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void mousePressed(MouseEvent e) {
	if (SwingUtilities.isLeftMouseButton(e) && e.isShiftDown()) {
		start = new Rectangle(e.getPoint());
		map.setPanEnabled(false);
	} else
		start = null;
}
 
Example 10
@Override
public void mouseReleased(MouseEvent e) {
    super.mouseReleased(e);
    // double-click actions.
    if (e.getClickCount() > 1 && SwingUtilities.isLeftMouseButton(e)) {
        showCardScriptScreen();
    }
}
 
Example 11
Source Project: nanoleaf-desktop   File: PanelActionListener.java    License: MIT License 5 votes vote down vote up
@Override
public void mouseDragged(MouseEvent e)
{
	if (mouseLast != null)
	{
		if (SwingUtilities.isLeftMouseButton(e))
		{
			movePanelsUsingMouse(e.getPoint());
		}
		else if (SwingUtilities.isRightMouseButton(e))
		{
			rotatePanelsUsingMouse(e.getPoint());
		}
	}
}
 
Example 12
private boolean isDefaultRightMouseButton(MouseEvent e) {
	if (keyBindings.leftMouseClickCentersMap()) {
		return SwingUtilities.isRightMouseButton(e);
	} else {
		return SwingUtilities.isLeftMouseButton(e);
	}
}
 
Example 13
Source Project: netbeans   File: CodeFoldingSideBar.java    License: Apache License 2.0 5 votes vote down vote up
private Mark getClickedMark(MouseEvent e){
    if (e == null || !SwingUtilities.isLeftMouseButton(e)) {
        return null;
    }
    
    int x = e.getX();
    int y = e.getY();
    for (Mark mark : visibleMarks) {
        if (x >= mark.x && x <= (mark.x + mark.size) && y >= mark.y && y <= (mark.y + mark.size)) {
            return mark;
        }
    }
    return null;
}
 
Example 14
private void doMousePressedAction(MouseEvent e) {
    if (isMouseRowSelected(e)) {
        if (SwingUtilities.isLeftMouseButton(e)) {
            doLeftClickAction();
        } else if (SwingUtilities.isRightMouseButton(e)) {
            doRightClickAction();
        }
    }
}
 
Example 15
/**
 * Predicate to check if an additional selection is wanted.
 * Default is the typical selection (left button), while control key is pressed.
 *
 * @param e the mouse context
 * @return the predicate result
 */
public static boolean isAdditionWanted (MouseEvent e)
{
    if (WellKnowns.MAC_OS_X) {
        boolean command = e.isMetaDown();
        boolean left = SwingUtilities.isLeftMouseButton(e);

        return left && command && !e.isPopupTrigger();
    } else {
        return (SwingUtilities.isRightMouseButton(e) != SwingUtilities.isLeftMouseButton(e))
                       && e.isControlDown();
    }
}
 
Example 16
@Override
public void mousePressed(MouseEvent e) {
	if (SwingUtilities.isLeftMouseButton(e) && e.isAltDown()) {
		start = createGeoRectangle(e.getPoint());
		map.setPanEnabled(false);
	} else
		start = null;

	mouseDragged = false;
}
 
Example 17
@Override
public void mouseReleased(MouseEvent e)
{
	if (SwingUtilities.isLeftMouseButton(e))
	{
		finishDragging();
	}
}
 
Example 18
Source Project: netbeans   File: CommentsPanel.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void mouseClicked(MouseEvent e) {
    if (SwingUtilities.isLeftMouseButton(e)) {
        setState(!isCollapsed(number)); 
    } 
}
 
Example 19
public void mouseClicked(MouseEvent e) {
    if (SwingUtilities.isLeftMouseButton(e) &&
            e.getClickCount() == explorerTree.getToggleClickCount()) {
        performDefaultAction();
    }
}
 
Example 20
public void mouseClicked(MouseEvent e) {
    if (SwingUtilities.isLeftMouseButton(e)) handleClick(e);
    if (SwingUtilities.isMiddleMouseButton(e)) handleMiddleClick(e);
}