mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-22 15:12:28 +00:00
Extra option in Generic dialog to specify location on screen.
This commit is contained in:
parent
4984ee03e5
commit
cc3889a95f
@ -1,5 +1,8 @@
|
||||
package PamView.dialog;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
|
||||
import javax.swing.BoxLayout;
|
||||
@ -8,9 +11,9 @@ import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
public class GenericSwingDialog extends PamDialog {
|
||||
|
||||
|
||||
private boolean allOk;
|
||||
|
||||
|
||||
private PamDialogPanel[] dialogPanels;
|
||||
|
||||
private GenericSwingDialog(Window parentFrame, String title, PamDialogPanel ...dialogPanels) {
|
||||
@ -25,15 +28,48 @@ public class GenericSwingDialog extends PamDialog {
|
||||
}
|
||||
mainPanel.add(comp);
|
||||
}
|
||||
|
||||
|
||||
setDialogComponent(mainPanel);
|
||||
}
|
||||
|
||||
public static boolean showDialog(Window parentFrame, String title, PamDialogPanel ...dialogPanels) {
|
||||
|
||||
public static boolean showDialog(Window parentFrame, String title, PamDialogPanel ...dialogPanels) {
|
||||
return showDialog(parentFrame, title, null, dialogPanels);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show dialog at a specific location on the screen.
|
||||
* @param parentFrame
|
||||
* @param title
|
||||
* @param screenPoint
|
||||
* @param dialogPanels
|
||||
* @return
|
||||
*/
|
||||
public static boolean showDialog(Window parentFrame, String title, Point screenPoint, PamDialogPanel ...dialogPanels) {
|
||||
GenericSwingDialog swingDialog = new GenericSwingDialog(parentFrame, title, dialogPanels);
|
||||
swingDialog.setParams();
|
||||
swingDialog.pack();
|
||||
if (screenPoint != null) {
|
||||
try {
|
||||
// check we're not going too far off the screen.
|
||||
Dimension sz = swingDialog.getPreferredSize();
|
||||
Dimension screen = null;
|
||||
if (parentFrame != null) {
|
||||
screen = parentFrame.getSize();
|
||||
}
|
||||
else {
|
||||
screen = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
}
|
||||
screenPoint.y = Math.min(screenPoint.y, screen.height-sz.height-10);
|
||||
screenPoint.y = Math.max(screenPoint.y, 0);
|
||||
screenPoint.x = Math.min(screenPoint.x, screen.width-sz.width-10);
|
||||
screenPoint.x = Math.max(screenPoint.x, 0);
|
||||
|
||||
swingDialog.setLocation(screenPoint);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// shouldn't happen, but if it does, it doesn't matter much
|
||||
}
|
||||
}
|
||||
swingDialog.setVisible(true);
|
||||
return swingDialog.allOk;
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ public abstract class OverlayDataManager<TOverlayInfoType extends OverlayDataInf
|
||||
private ParameterType[] parameterTypes;
|
||||
|
||||
private ParameterUnits[] parameterUnits;
|
||||
|
||||
|
||||
/**
|
||||
* @param generalProjector
|
||||
|
Loading…
Reference in New Issue
Block a user