發新話題

[JAVA] 改變component游標

[JAVA] 改變component游標

當滑鼠在一個component上時,游標的形狀會隨著component的游標特性改變
游標特性是可以透過Component.setCursor() 改變的
下面是一個簡單的例子:
複製內容到剪貼板
代碼:
    // Create a component
    Component comp = new Button("OK");
   
    // 這可以取得目前comp的游標特性,預設為Cursor.DEFAULT_CURSOR
    Cursor cursor = comp.getCursor();
   
    // 改變游標成別的形狀
    comp.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
更詳細的資訊可以參考Java API內的Cursor

TOP

發新話題

本站所有圖文均屬網友發表,僅代表作者的觀點與本站無關,如有侵權請通知版主會盡快刪除。