עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

שינוי תמונת האייקון של העכבר ב-java

Featured Replies

פורסם

אני כותב תוכנה שפותרת סודוקו ב-java, ואני רוצה שהאייקון של העכבר ישתנה בהתאם לתזוזת העכבר, כך שיהיה מעבר עכבר על הטבלה העכבר ישתנה ל-hand cursor, וכשהוא יצא מהטבלה הוא יחזור ל-custom cursor, אבל כשאני מזיז את העכבר אני מקבל הודעת שגיאה. זה הקוד:




addMouseMotionListener (
new MouseMotionListener () {
public void mouseDragged(MouseEvent e) {


}


public void mouseMoved(MouseEvent e) {
if (e.getX()<551 && e.getY()<549 && e.getY()>99)
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
else
setCursor(Cursor.getPredefinedCursor(Cursor.CUSTOM_CURSOR));


}
}

}
);





הטבלה ברוחב 450 ובגובה 548, וממוקמת על 0,100. הנה הודעת השגיאה (היא חוזרת על עצמה המון פעמים בריצה):

54bd424ec6487.jpg

מישהו יכול לעזור? תודה לעונים

פורסם

אתה לא יכול להעביר CUSTOM_CURSOR לפוקציה getPredefinedCursor

פורסם
  • מחבר

ניסיתי להשתממש בקוד קצת שונה, אבל הוא עושה בדיוק אותו דבר.


addMouseMotionListener (
new MouseMotionListener () {
public void mouseDragged(MouseEvent e) {


}


public void mouseMoved(MouseEvent e) {
if (e.getX()<551 && e.getY()<549 && e.getY()>99)
setCursor(new Cursor(Cursor.HAND_CURSOR));
else
setCursor(new Cursor(Cursor.CUSTOM_CURSOR));

- - - תגובה אוחדה: - - -

תודה, הסתדרתי... גיליתי שהבעיה היא שניסיתי להגדיר את CUSTOM_CURSOR, ששווה -1, כאייקון של העכבר. מצאתי את הקוד הזה, מתוך האובייקט Frame:


public void setCursor(int cursorType) {
if (cursorType < DEFAULT_CURSOR || cursorType > MOVE_CURSOR) {
throw new IllegalArgumentException("illegal cursor type");
}
setCursor(Cursor.getPredefinedCursor(cursorType));
}

MOVE_CURSOR שווה 0, ולכן אני לא יכול להגדיר את CUSTOM_CURSOR כאייקון של העכבר.

DEFSULT_CURSOR הוא האייקון שאני צריך.

נערך על-ידי יפתח שלזינגר

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.