Java MouseEvent .getMouseModifiersText (int modifiers)
Syntax
MouseEvent.getMouseModifiersText(int modifiers) has the following syntax.
public static String getMouseModifiersText(int modifiers)
Example
In the following code shows how to use MouseEvent.getMouseModifiersText(int modifiers) method.
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
// w ww. j a v a2s .c o m
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Main extends JPanel {
JButton button = new JButton("click frame not me");
public Main() {
setLayout(null);
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()));
}
});
}
public static void main(String[] args) {
JFrame frame = new JFrame("MoveButton");
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setSize(250, 200);
frame.setLocation(200, 200);
frame.setContentPane(new Main());
frame.setVisible(true);
}
}
Home »
Java Tutorial »
java.awt.event »
Java Tutorial »
java.awt.event »