java - Something wrong with JDialog -
i'm trying print message user in program i'm making, somehow result not expected. used, example, oracles sugestion message dialog, wich is:
joptionpane.showmessagedialog(frame, "eggs not supposed green."); i (notice missing dot @ end , missing k in button):

is possible wrong jdk or jre? also, don't know if can important or not, i'm programming on eclipse platform, running on windows 7.
edit number1: sugested, tried simpler example , got same result. here code simpler example:
public class samplegui { public static void main(string[] args) { swingutilities.invokelater(new runnable() { @override public void run() { joptionpane.showmessagedialog( null, "eggs not supposed green."); } }); } } edit number2: make things weirder, seem able avoid outcome connecting laptop outlet. seems tremendously stupid, , can assume wrong computer. make happen?
update on edit2: not seem work every time. reasons cannot explain, have tried few minutes ago laptop charging , i'm getting same results.
edit number3: have configured dual-boot windows 7 , ubuntu 14.04 , unable reproduce error on ubuntu.
i'd amend question first, because recognize dialog box, , source can explain got idea code way did:
http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html
now, impulse put joptionpane.showmessagedialog invokelater correct, though example program doesn't; example program spawns dialog in response mouseevent/actionevent, thread safety ensured. code starts static context on new thread, invokelater right.
what happens next interesting because swing might causing problem it's meant avoid: current eventdispatchthread stalls , new event pump begins handle events on dialog. since drawing happens on edt, have sneaking suspicion either paint or layout getting lost on original edt.
instead of calling convenience method, try intermediate version:
public class samplegui { public static void main(string[] args) { swingutilities.invokelater(new runnable() { @override public void run() { joptionpane optionpane = new joptionpane("eggs not supposed green."); jdialog generateddialog = optionpane.createdialog("message"); generateddialog.setvisible(true); } }); } } the above should equivalent in every way http://developer.classpath.org/doc/javax/swing/joptionpane-source.html (line 926, call line 368)
except have jdialog can poke repaint, invalidate, or pack make sure displays properly.
Comments
Post a Comment