我有一個Java Swing應用程序,使用Java 1.5在Mac OS X 10.5上開發。Swing中的自定義光標JDialog
我想讓用戶在對話框中的某些文本上移動鼠標時出現自定義光標。但是光標不會改變。
當我不使用JFrame而不是JDialog時,遊標確實會改變。但是,我必須自己編寫所有的對話框代碼。
如何讓光標出現?
這裏我可以創建演示此問題的最簡單的代碼:
import javax.swing.*;
import java.awt.*;
public class CursorTest {
public static void main(String[] args) {
JLabel label = new JLabel("Move mouse here for hand cursor");
label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
JOptionPane pane = new JOptionPane(label);
pane.setOptions(new Object[]{"OK"});
JDialog dialog = pane.createDialog(null, "Test Dialog");
dialog.setVisible(true);
}
}
non null?無論如何你給了一個null的變量? 〜對不起,我試圖理解你的線程...... :( – gumuruh 2011-08-15 10:03:22