Example usage for java.awt.event MouseAdapter MouseAdapter

List of usage examples for java.awt.event MouseAdapter MouseAdapter

Introduction

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

Prototype

MouseAdapter

Source Link

Usage

From source file:Main.java

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

From source file:Main.java

public Colors() {
    addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent me) {
            change();/*from  ww w. ja  va2 s  . co m*/
        }
    });
    rectangular = false;
    super.setPreferredSize(new Dimension(200, 100));
    change();
}

From source file:Main.java

public Main() {
    loadArray();/*from ww  w  .  j  a v a 2 s.  c  o m*/
    addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (shuffle)
                loadArray();
            selectionSort(numbers);
            shuffle = true;
        }
    });
}

From source file:Highlights.java

public Highlights() {
    addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent me) {
            firstHit = textLayout.hitTestChar(me.getX() - x, me.getY() - y);
            secondHit = null;//from   ww  w. jav a 2  s.c  o m
        }

        public void mouseReleased(MouseEvent me) {
            secondHit = textLayout.hitTestChar(me.getX() - x, me.getY() - y);
            repaint();
        }
    });
    addMouseMotionListener(new MouseMotionAdapter() {
        public void mouseDragged(MouseEvent me) {
            secondHit = textLayout.hitTestChar(me.getX() - x, me.getY() - y);
            repaint();
        }
    });

}

From source file:MainClass.java

public MouseMotionAnonymous() {
    setBackground(Color.white);/*from ww  w.j  a v a2s. c om*/
    addMouseListener(new MouseAdapter() {
        public void mouseReleased(MouseEvent me) {
            setBackground(Color.white);
            repaint();
        }
    });
    addMouseMotionListener(new MouseMotionAdapter() {
        public void mouseDragged(MouseEvent me) {
            setBackground(Color.cyan);
            repaint();
        }
    });
}

From source file:Main.java

public Main() {
    image = Toolkit.getDefaultToolkit().getImage("A.jpg");
    theta = 0;//from  www  . ja va 2  s .co  m
    addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent me) {
            theta = (theta + 15) % 360;
            repaint();
        }
    });
}

From source file:MainClass.java

public MyCanvas() {
    addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent me) {
            TextHitInfo hit = mTextLayout.hitTestChar(me.getX() - mX, me.getY() - mY);
            System.out.println(hit.getCharIndex());
            System.out.println(hit.getInsertionIndex());
            System.out.println(hit.isLeadingEdge());
        }/*from   w w  w  .  j  a v a  2 s.c  o m*/
    });

}

From source file:Main.java

Main() {
    shapes.add(new Ellipse2D.Double(10, 10, 20, 30));
    MouseAdapter listener = new MouseAdapter() {

        @Override// www  .  ja v  a  2  s .  com
        public void mouseClicked(MouseEvent me) {
            mouse = me.getPoint();
            drawImage();
        }
    };
    l.addMouseListener(listener);
    drawImage();

    JOptionPane.showMessageDialog(null, l);
}

From source file:Main.java

public Main(JTree jt) {
    super();//from   w  w  w. j  av  a  2  s. c o  m
    tree = jt;
    getContentPane().add(tree);
    tree.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent event) {
            if (((event.getModifiers() & InputEvent.BUTTON3_MASK) != 0) && (tree.getSelectionCount() > 0)) {
                showMenu(event.getX(), event.getY());
            }
        }
    });
}

From source file:MouseDragActionPanel.java

public MouseDragActionPanel() {
    addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent evt) {
            int x = evt.getX();
            int y = evt.getY();
            currentSquareIndex = getSquare(x, y);
            if (currentSquareIndex < 0) // not inside a square
                add(x, y);//from   w  ww.  j av a2s  .  com
        }

        public void mouseClicked(MouseEvent evt) {
            int x = evt.getX();
            int y = evt.getY();

            if (evt.getClickCount() >= 2) {
                remove(currentSquareIndex);
            }
        }
    });
    addMouseMotionListener(this);
}