Ruang penulis
← Kembali ke jurnal
AWT

How do I get the number of buttons on the mouse?

MouseInfo provides methods for getting information about the mouse, such as mouse pointer location and the number of mouse buttons. package org.kodejava.awt; import java.awt.*; public class MouseNumberOfButtons { public static void main(String[] args) { // Get the number of buttons on the mouse. On systems without a // mouse, returns -1. HeadlessException if // GraphicsEnvironment.isHeadless() […]

DWayan · 11 Mei 2009 · 1 menit baca

Artikel oleh Wayan · Sumber: Kode Java ↗

Terjemahan artikel ini belum tersedia. Isi asli ditampilkan.

MouseInfo provides methods for getting information about the mouse, such as mouse pointer location and the number of mouse buttons.

package org.kodejava.awt;

import java.awt.*;

public class MouseNumberOfButtons {
    public static void main(String[] args) {
        // Get the number of buttons on the mouse. On systems without a
        // mouse, returns -1. HeadlessException if
        // GraphicsEnvironment.isHeadless() returns true.
        int numberOfButtons = MouseInfo.getNumberOfButtons();
        System.out.println("Mouse Number Of Buttons = " + numberOfButtons);
    }
}

The output of the code snippet above:

Mouse Number Of Buttons = 5
← Jelajahi catatan lainnya