* @return The newly-created preview dialog.
* @throws OutputException For errors loading resources.
*/
protected PreviewDialog createPreviewDialog(final AWTRenderer renderer, final Translator res)
throws OutputException {
final PreviewDialog frame = new PreviewDialog(renderer, res);
frame.validate();
frame.addWindowListener(new WindowAdapter() {
public void windowClosed(final WindowEvent we) {
/* Checkstyle-GenericIllegalRegexp-Off. */
/* TODO: Is there a better way to handle this? */
System.exit(0);
/* Checkstyle-GenericIllegalRegexp-On. */
}
});
// center window
final Dimension screenSize = Toolkit.getDefaultToolkit()
.getScreenSize();
final Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
return frame;
}