List of usage examples for java.awt.event MouseAdapter MouseAdapter
MouseAdapter
From source file:Main.java
public Main() { setLayout(null);// w w w . ja va 2 s. c o m add(button); button.setSize(button.getPreferredSize()); button.setLocation(20, 20); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { System.out.println(e.getButton() == MouseEvent.BUTTON2); } }); }
From source file:Main.java
public Main() { setLayout(null);//from w ww .jav a 2 s. com add(button); button.setSize(button.getPreferredSize()); button.setLocation(20, 20); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { button.setLocation(e.getX(), e.getY()); } }); }
From source file:Main.java
public Main() { setLayout(null);//w w w . j a va2 s.c o m add(button); button.setSize(button.getPreferredSize()); button.setLocation(20, 20); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { System.out.println(e.getButton() == MouseEvent.BUTTON3); } }); }
From source file:Main.java
public Main() { setLayout(null);//w ww . j a v a2 s .com 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:Main.java
public Main() { setLayout(null);// ww w.j a v a 2s .c om add(button); button.setSize(button.getPreferredSize()); button.setLocation(20, 20); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { System.out.println(e.getButton() == MouseEvent.NOBUTTON); } }); }
From source file:Main.java
public Main() { setSize(300, 300);/*w w w .j a va 2 s . co m*/ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JTextArea textArea = new JTextArea(); textArea.setText("Click Me!"); textArea.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.NOBUTTON) { textArea.setText("No button clicked..."); } else if (e.getButton() == MouseEvent.BUTTON1) { textArea.setText("Button 1 clicked..."); } else if (e.getButton() == MouseEvent.BUTTON2) { textArea.setText("Button 2 clicked..."); } else if (e.getButton() == MouseEvent.BUTTON3) { textArea.setText("Button 3 clicked..."); } System.out.println("Number of click: " + e.getClickCount()); System.out.println("Click position (X, Y): " + e.getX() + ", " + e.getY()); } }); getContentPane().add(textArea); }
From source file:Main.java
public Main() { setLayout(null);// w ww. ja va2 s .c om add(button); button.setSize(button.getPreferredSize()); button.setLocation(20, 20); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { System.out.println(e.getLocationOnScreen()); } }); }
From source file:Main.java
public Main() { setLayout(null);/*from ww w . java 2 s . c om*/ add(button); button.setSize(button.getPreferredSize()); button.setLocation(20, 20); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { System.out.println(MouseEvent.getMouseModifiersText(event.getModifiers())); } }); }
From source file:Main.java
public Main() { setLayout(null);/*from www .jav a2 s . c o m*/ add(button); button.setSize(button.getPreferredSize()); button.setLocation(20, 20); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { System.out.println(event.getXOnScreen()); } }); }
From source file:Main.java
public Main() { setLayout(null);//from w w w . ja v a2 s. c om add(button); button.setSize(button.getPreferredSize()); button.setLocation(20, 20); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { System.out.println(event.getPoint()); } }); }