Posted by
Kenneth Sloan-2 on
URL: http://imagej.273.s1.nabble.com/minor-UI-bug-tp5023271p5023274.html
Here’s a solution that works for me.
Most of my Java plugins have a “splash screen” announcing the name of the plugin, the version, etc. This has been displayed with showMessage(). There is little reason for the user to do anything other than click “OK”.
So…instead of showMessage(message), I now use:
// announce version
String message = ...
String title = ...
Point dialogLocation = new Point(dialogLocationX,
dialogLocationY);
Point dialogDrift = measureDialogDrift(programName,
message,
dialogLocation);
And
private Point measureDialogDrift(String title,
String message,
Point location)
{
int setX = location.x;
int setY = location.y;
int getX;
int getY;
NonBlockingGenericDialog gd
= new NonBlockingGenericDialog(title);
gd.addMessage(message);
gd.setLocation(setX, setY);
gd.showDialog();
getX = gd.getLocation().x;
getY = gd.getLocation().y;
Point result = new Point(getX-setX, getY-setY);
return result;
}
In my development environment (MacBook Pro), measureDialogDrift reliably returns (0, -21).
Heaven help the user who moves the splash screen before clicking on “OK”!
I had a dream that this would work without the showDialog(), but (of course?) that doesn’t work. The displayed location of the dialog depends on the screen boundaries. It would be *nice* if this were fixed at either the java.awt level or the ImageJ level, but I won’t hold my breath. Perhaps someone with a deep understanding of java.awt can suggest a method that does not require run-time experimentation, and works on all platforms.
Ah…it occurs to me that the reason there is no drift in X is that the size of the borders on the left and right is fixed, while the height of the banner at the top may depend on the font used.
On to more important issues...
--
Kenneth Sloan
[hidden email]
Vision is the art of seeing what is invisible to others.
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html