Java Code Examples for com.alee.utils.SwingUtils#isLeftMouseButton()

The following examples show how to use com.alee.utils.SwingUtils#isLeftMouseButton() . 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: WebCheckBoxTree.java    From weblaf with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void mousePressed ( @NotNull final MouseEvent e )
{
    if ( isCheckingByUserEnabled () && SwingUtils.isLeftMouseButton ( e ) )
    {
        final N node = getNodeForLocation ( e.getPoint () );
        if ( node != null && isCheckBoxVisible ( node ) && isCheckBoxEnabled ( node ) )
        {
            final Rectangle checkBoxBounds = getCheckBoxBounds ( node );
            if ( checkBoxBounds != null && checkBoxBounds.contains ( e.getPoint () ) )
            {
                invertCheck ( node );
            }
        }
    }
}
 
Example 2
Source File: WLinkUI.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void installListeners ()
{
    super.installListeners ();

    linkExecutionListener = new MouseAdapter ()
    {
        private boolean pressed;

        @Override
        public void mousePressed ( final MouseEvent e )
        {
            if ( label.isEnabled () && SwingUtils.isLeftMouseButton ( e ) &&
                    BoundsType.margin.bounds ( label ).contains ( e.getPoint () ) )
            {
                pressed = true;
                if ( label.isFocusable () )
                {
                    label.requestFocusInWindow ();
                }
            }
        }

        @Override
        public void mouseReleased ( final MouseEvent e )
        {
            if ( SwingUtils.isLeftMouseButton ( e ) )
            {
                if ( label.isEnabled () && pressed && BoundsType.margin.bounds ( label ).contains ( e.getPoint () ) )
                {
                    label.fireLinkExecuted ();
                }
                pressed = false;
            }
        }
    };
    label.addMouseListener ( linkExecutionListener );
}
 
Example 3
Source File: WebStepProgress.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void mousePressed ( final MouseEvent e )
{
    if ( isEnabled () && isSelectionEnabled () && SwingUtils.isLeftMouseButton ( e ) )
    {
        selecting = true;
        updateProgress ( e.getPoint () );
    }
}
 
Example 4
Source File: WebStepProgress.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void mouseDragged ( final MouseEvent e )
{
    if ( selecting && SwingUtils.isLeftMouseButton ( e ) )
    {
        updateProgress ( e.getPoint () );
    }
}
 
Example 5
Source File: WebStepProgress.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void mouseReleased ( final MouseEvent e )
{
    if ( selecting && SwingUtils.isLeftMouseButton ( e ) )
    {
        selecting = false;
    }
}
 
Example 6
Source File: AbstractListCellEditor.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Installs start edit actions in the list.
 *
 * @param list list to process
 */
protected void installStartEditActions ( final JList list )
{
    mouseAdapter = new MouseAdapter ()
    {
        @Override
        public void mouseClicked ( final MouseEvent e )
        {
            if ( getClicksToEdit () > 0 && e.getClickCount () == getClicksToEdit () && SwingUtils.isLeftMouseButton ( e ) )
            {
                final Point point = e.getPoint ();
                final int index = list.getUI ().locationToIndex ( list, point );
                if ( index >= 0 && index < list.getModel ().getSize () )
                {
                    final Rectangle cell = list.getCellBounds ( index, index );
                    if ( cell.contains ( point ) )
                    {
                        startEdit ( list, index );
                    }
                }
            }
        }
    };
    list.addMouseListener ( mouseAdapter );

    keyAdapter = new KeyAdapter ()
    {
        @Override
        public void keyReleased ( final KeyEvent e )
        {
            if ( Hotkey.F2.isTriggered ( e ) )
            {
                startEdit ( list, list.getSelectedIndex () );
            }
        }
    };
    list.addKeyListener ( keyAdapter );
}