java - Not Always Showing Wait Cursor on Mac -
i implementing "load file" functionality in java application - file might on network share can take little while read. once user has selected file load, changing mouse cursor cursor.wait_cursor. works fine on windows, getting strange results on both java 7u75 , 8u45 on mac os 10.9.5. have tried changing cursor on both jframe component glasspane, seeing same results.
basically, on mac os, if mouse interacts jfilechooser in way cursor isn't changed, if use keyboard select file works expected , cursor changed.
this looks bit bug like, lookig wisdom might have come across before , conquered it? have put sscce below demonstrate problem.
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class sscce extends jframe implements actionlistener { private final sscce t = this; private component gp = getrootpane().getglasspane(); private jmenubar mbar; private jmenu mfile; private jmenuitem miload; public sscce() { settitle("sscce"); setsize(960, 640); setdefaultcloseoperation(exit_on_close); mbar = new jmenubar(); mfile = new jmenu("file"); miload = new jmenuitem("load"); miload.addactionlistener(this); mfile.add(miload); mbar.add(mfile); setjmenubar(mbar); setlocationrelativeto(null); setvisible(true); } @override public void actionperformed(actionevent e) { if (e.getsource() == miload) { jfilechooser fc = new jfilechooser(); fc.showdialog(this, "test"); updatecursor(cursor.wait_cursor); new swingworker<void, void>() { @override protected void doinbackground() { try { thread.sleep(5000); } catch (exception e) { e.printstacktrace(); } return null; } @override protected void done() { updatecursor(cursor.default_cursor); joptionpane.showmessagedialog(t, "ok", "status", joptionpane.plain_message); } }.execute(); } } private void updatecursor(final int c) { gp.setcursor(cursor.getpredefinedcursor(c)); gp.setvisible(c != cursor.default_cursor); } public static void main(string[] args) { swingutilities.invokelater(new runnable() { @override public void run() { new sscce(); } }); } }
Comments
Post a Comment