java - How can set location for my swt file dialog? -
i have application want display swt file dialog in defined location(i want display somewhere down).i not getting method that.any on appreciated...
currently api doesn't support set location of filedialog. there little hack/workaround that.
all need create invisible shell , set location. filedialog decides location based on parent.
it seems bit complex know exact coordinates setlocation on shell but, leave permutations , combinations know them.
here code solves problem
public static string opennewshelldialog(display display) { final shell shell = new shell(display , swt.application_modal); shell.setlayout(new gridlayout(1, false)); system.out.println(display.getprimarymonitor().getclientarea()); shell.setlocation(616, 500); //it seems location relative center of shell w.r.t client area shell.setsize(0,0); shell.setvisible(false); shell.open(); filedialog d = new filedialog(shell); string s = d.open(); shell.dispose (); while (!shell.isdisposed ()) { if (!display.readanddispatch ()) display.sleep (); } return s; }
Comments
Post a Comment