SwingUtilities.getWindowAncestor(VideoPanel.this).toFront();
} else {
if (currentVideoPanel != null) {
currentVideoPanel.close();
}
final JOptionPane optionPane = new JOptionPane(this,
JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION,
null, new Object [] {this.createButton, this.saveButton, this.closeButton}, this.createButton);
if (parentView != null) {
optionPane.setComponentOrientation(((JComponent)parentView).getComponentOrientation());
}
final JDialog dialog = optionPane.createDialog(SwingUtilities.getRootPane((Component)parentView), this.dialogTitle);
dialog.setModal(false);
Component homeRoot = SwingUtilities.getRoot((Component)parentView);
if (homeRoot != null) {
// Restore location if it exists
Integer x = (Integer)this.home.getVisualProperty(VIDEO_DIALOG_X_VISUAL_PROPERTY);
Integer y = (Integer)this.home.getVisualProperty(VIDEO_DIALOG_Y_VISUAL_PROPERTY);
int windowRightBorder = homeRoot.getX() + homeRoot.getWidth();
Dimension screenSize = getToolkit().getScreenSize();
Insets screenInsets = getToolkit().getScreenInsets(getGraphicsConfiguration());
int screenRightBorder = screenSize.width - screenInsets.right;
// Check dialog isn't too high
int screenHeight = screenSize.height - screenInsets.top - screenInsets.bottom;
if (OperatingSystem.isLinux() && screenHeight == screenSize.height) {
// Let's consider that under Linux at least an horizontal bar exists
screenHeight -= 30;
}
int screenBottomBorder = screenSize.height - screenInsets.bottom;
int dialogWidth = dialog.getWidth();
if (dialog.getHeight() > screenHeight) {
dialog.setSize(dialogWidth, screenHeight);
}
int dialogHeight = dialog.getHeight();
if (x != null && y != null
&& x + dialogWidth <= screenRightBorder
&& y + dialogHeight <= screenBottomBorder) {
dialog.setLocation(x, y);
} else if (screenRightBorder - windowRightBorder > dialogWidth / 2
|| dialogHeight == screenHeight) {
// If there some space left at the right of the window
// move the dialog to the right of window
dialog.setLocationByPlatform(false);
dialog.setLocation(Math.min(windowRightBorder + 5, screenRightBorder - dialogWidth),
Math.max(Math.min(homeRoot.getY() + dialog.getInsets().top,
screenSize.height - dialogHeight - screenInsets.bottom), screenInsets.top));
} else {
dialog.setLocationByPlatform(true);
}
} else {
dialog.setLocationByPlatform(true);
}
dialog.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent ev) {
stopVideoCreation(false);
if (playbackTimer != null) {
pausePlayback();
}
if (videoFile != null) {
videoFile.delete();
}
currentVideoPanel = null;
}
});
updateAdvancedComponents();
ToolTipManager.sharedInstance().registerComponent(this.qualitySlider);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.addComponentListener(new ComponentAdapter() {
@Override
public void componentHidden(ComponentEvent ev) {
if (optionPane.getValue() != null
&& optionPane.getValue() != JOptionPane.UNINITIALIZED_VALUE) {
close();
}
}
@Override