summaryrefslogtreecommitdiff
path: root/sources/utils/VSFrame.java
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-19 16:01:10 +0000
committerPaul Buetow <paul@buetow.org>2008-05-19 16:01:10 +0000
commit3f40213c906b4017d56ef31a9a82f0b5d0905229 (patch)
tree97ba8b227db8cac7b61deded24414173376ca2f7 /sources/utils/VSFrame.java
parent7b7f671ed874b82141f3be9d1d071e2e2eaf9cef (diff)
more intelligent window positions
Diffstat (limited to 'sources/utils/VSFrame.java')
-rw-r--r--sources/utils/VSFrame.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/sources/utils/VSFrame.java b/sources/utils/VSFrame.java
index e5ff6a0..32392b8 100644
--- a/sources/utils/VSFrame.java
+++ b/sources/utils/VSFrame.java
@@ -23,8 +23,6 @@ public class VSFrame extends JFrame {
private void init(Component parent) {
this.parent = parent;
this.dispose = false;
-
- setLocation();
}
public void disposeWithParent() {
@@ -39,11 +37,11 @@ public class VSFrame extends JFrame {
dispose = true;
}
- private void setLocation() {
+ private void setCorrectLocation() {
int x = 0, y = 0;
+ final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
if (parent == null) {
- final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
x = (int) (screenSize.width - getWidth()) / 2;
y = 50;//(int) (screenSize.height - getHeight()) / 2;
@@ -53,6 +51,17 @@ public class VSFrame extends JFrame {
y = (int) location.getY() + Y_LOCATION_OFFSET;
}
- setLocation(x, y);
+ if (x + super.getWidth() >= screenSize.width)
+ x = screenSize.width - super.getWidth();
+
+ if (y + super.getHeight() >= screenSize.height)
+ y = screenSize.height - super.getHeight();
+
+ super.setLocation(x, y);
}
+
+ public void setSize(int width, int height) {
+ super.setSize(width, height);
+ setCorrectLocation();
+ }
}