Example usage for java.awt.event MouseEvent getClickCount

List of usage examples for java.awt.event MouseEvent getClickCount

Introduction

In this page you can find the example usage for java.awt.event MouseEvent getClickCount.

Prototype

public int getClickCount() 

Source Link

Document

Returns the number of mouse clicks associated with this event.

Usage

From source file:Main.java

public LoadingScreenDemo() {
    addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                dispose();/*from  w ww .j  a  v a2  s  .  co  m*/
            }
        }
    });
    panel.setBackground(Color.YELLOW);
    add(panel);
}

From source file:Main.java

public Main() {
    setLayout(null);//from  ww  w .  ja va 2 s  .co m
    add(button);
    button.setSize(button.getPreferredSize());
    button.setLocation(20, 20);
    addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            System.out.println(e.getClickCount());
        }
    });
}

From source file:com.mac.tarchan.desktop.event.DoubleClickHandler.java

/**
 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
 *///from   w w w.ja  va 2 s.c  o m
public void mouseClicked(MouseEvent e) {
    log.debug("click=" + e);
    if (e.getClickCount() == 2)
        fireDoubleClicked(e);
}

From source file:Main.java

public Main() {
    setSize(500, 500);//from ww  w. j  ava 2  s .  co m
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setLayout(new GridLayout(0, 1));
    JPanel buttonPanel = new JPanel();

    JButton addButton = new JButton("add");
    addButton.addActionListener(e -> addElementToArrayList());
    JButton removeButton = new JButton("remove");
    removeButton.addActionListener(e -> removeElementFromArrayList());

    tabbedPane = new JTabbedPane();
    tabbedPaneMouseListener = (new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e)) {
                if (e.getClickCount() == 1) {
                    System.out.println("Do Something");
                }
            }
        }
    });
    tabbedPane.addMouseListener(tabbedPaneMouseListener);

    buttonPanel.add(addButton);
    buttonPanel.add(removeButton);
    add(buttonPanel);
    this.add(tabbedPane);
}

From source file:events.MouseEventDemo.java

public void mousePressed(MouseEvent e) {
    eventOutput("Mouse pressed (# of clicks: " + e.getClickCount() + ")", e);
}

From source file:events.MouseEventDemo.java

public void mouseClicked(MouseEvent e) {
    eventOutput("Mouse clicked (# of clicks: " + e.getClickCount() + ")", e);
}

From source file:events.MouseEventDemo.java

public void mouseReleased(MouseEvent e) {
    eventOutput("Mouse released (# of clicks: " + e.getClickCount() + ")", e);
}

From source file:ColorSink.java

/** Create a new ColorSink object */
public ColorSink() {
    // Listen for double clicks.  Use them to trigger a paste action.
    addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                pastecolor();/*w ww.  j  a va2  s  . c  om*/
                e.consume();
            }
        }
    });

    // We have to create a DropTarget object to support Drag-and-Drop
    // It will listen for drops on top of us, and notify our DropTargetListener
    // methods when drag-and-drop related events occur.
    setDropTarget(new DropTarget(this, this));
}

From source file:test.uk.co.modularaudio.util.swing.rollpainter.RPGestureRecogniser.java

@Override
public void mouseClicked(MouseEvent e) {
    //      log.debug("mouseClicked");
    int clickCount = e.getClickCount();
    if (clickCount > 0) {
        log.debug("Have click count " + clickCount);
    }/* ww  w.ja  v a  2s.c o  m*/

}

From source file:uk.nhs.cfh.dsp.yasb.expression.builder.panels.ConceptPanel.java

/**
 * Inits the components./*from  w  ww.j  a  v a  2s. co m*/
 */
public synchronized void initComponents() {
    conceptLabel = new JXHyperlink();
    conceptLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                logger.debug("Mouse double clicked on concept expression label");
            }
        }
    });

    // set layout to box layout
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    add(conceptLabel);
}