summaryrefslogtreecommitdiffstats
path: root/src/newt/classes/com/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-02-20 14:30:50 +0100
committerSven Gothel <[email protected]>2013-02-20 14:30:50 +0100
commitcf3ecdb670c0dfecd1394d5b9d5d5588c1bf71f3 (patch)
tree218fdc81e19184812157626bc19ad9c20b949386 /src/newt/classes/com/jogamp
parent7d5c51b635e0795d9b170342bdebe8e7e0bbd01d (diff)
NewtCanvasAWT: Fix size determination, i.e. take newt-child's size into account if no preferred size is given.
Diffstat (limited to 'src/newt/classes/com/jogamp')
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index 6fc5a46ce..195f8af8c 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -432,19 +432,23 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
final int w;
final int h;
if(isPreferredSizeSet()) {
+ // 1st: Component's PreferedSize
java.awt.Dimension d = getPreferredSize();
w = d.width;
h = d.height;
} else {
- final java.awt.Dimension min;
+ final java.awt.Dimension min1, min2;
+ // 2nd: Component's Max( Max( comp.min, newt.size ), cont.size )
if(this.isMinimumSizeSet()) {
- min = getMinimumSize();
+ min1 = getMinimumSize();
} else {
- min = new java.awt.Dimension(0, 0);
+ min1 = new java.awt.Dimension(0, 0);
}
+ min2 = new java.awt.Dimension( Math.max( min1.width, newtChild.getWidth() ),
+ Math.max( min1.height, newtChild.getHeight() ) );
java.awt.Insets ins = cont.getInsets();
- w = Math.max(min.width, cont.getWidth() - ins.left - ins.right);
- h = Math.max(min.height, cont.getHeight() - ins.top - ins.bottom);
+ w = Math.max(min2.width, cont.getWidth() - ins.left - ins.right);
+ h = Math.max(min2.height, cont.getHeight() - ins.top - ins.bottom);
}
setSize(w, h);
newtChild.setSize(w, h);
@@ -455,7 +459,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
// force this AWT Canvas to be focus-able,
// since this it is completely covered by the newtChild (z-order).
- setFocusable(true);
+ setFocusable(true);
} else {
configureNewtChild(false);
newtChild.setVisible(false);