下面列出了javax.swing.SwingUtilities#isLeftMouseButton ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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);
}
}
}
@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);
}
}
}
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);
}
}
}
}
@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);
}
}
}
}
@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();
}
}
}
@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;
}
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);
}
}
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);
}
@Override
public void mousePressed(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e) && e.isShiftDown()) {
start = new Rectangle(e.getPoint());
map.setPanEnabled(false);
} else
start = null;
}
@Override
public void mouseReleased(MouseEvent e) {
super.mouseReleased(e);
// double-click actions.
if (e.getClickCount() > 1 && SwingUtilities.isLeftMouseButton(e)) {
showCardScriptScreen();
}
}
@Override
public void mouseDragged(MouseEvent e)
{
if (mouseLast != null)
{
if (SwingUtilities.isLeftMouseButton(e))
{
movePanelsUsingMouse(e.getPoint());
}
else if (SwingUtilities.isRightMouseButton(e))
{
rotatePanelsUsingMouse(e.getPoint());
}
}
}
private boolean isDefaultRightMouseButton(MouseEvent e) {
if (keyBindings.leftMouseClickCentersMap()) {
return SwingUtilities.isRightMouseButton(e);
} else {
return SwingUtilities.isLeftMouseButton(e);
}
}
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;
}
private void doMousePressedAction(MouseEvent e) {
if (isMouseRowSelected(e)) {
if (SwingUtilities.isLeftMouseButton(e)) {
doLeftClickAction();
} else if (SwingUtilities.isRightMouseButton(e)) {
doRightClickAction();
}
}
}
/**
* 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();
}
}
@Override
public void mousePressed(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e) && e.isAltDown()) {
start = createGeoRectangle(e.getPoint());
map.setPanEnabled(false);
} else
start = null;
mouseDragged = false;
}
@Override
public void mouseReleased(MouseEvent e)
{
if (SwingUtilities.isLeftMouseButton(e))
{
finishDragging();
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e)) {
setState(!isCollapsed(number));
}
}
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e) &&
e.getClickCount() == explorerTree.getToggleClickCount()) {
performDefaultAction();
}
}
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e)) handleClick(e);
if (SwingUtilities.isMiddleMouseButton(e)) handleMiddleClick(e);
}