Skip to content

Commit 3e760b4

Browse files
hansonrhansonr
authored andcommitted
AWT Canvas preferred size to Component, not Container
1 parent 6e742ca commit 3e760b4

File tree

1 file changed

+12
-0
lines changed
  • sources/net.sf.j2s.java.core/src/swingjs/a2s

1 file changed

+12
-0
lines changed

sources/net.sf.j2s.java.core/src/swingjs/a2s/Canvas.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package swingjs.a2s;
22

33
import java.awt.Color;
4+
import java.awt.Dimension;
45
import java.awt.Graphics;
56
import java.awt.Graphics2D;
67
import java.awt.GraphicsConfiguration;
@@ -16,6 +17,17 @@ public Canvas() {
1617
_alwaysPaint = true;
1718
}
1819

20+
public Dimension getPreferredSize() {
21+
// must bypass JComponent here because we subclass Panel
22+
return preferredSize();
23+
}
24+
25+
public Dimension preferredSize() {
26+
// must bypass JComponent here because we subclass Panel
27+
return prefSizeComp();
28+
}
29+
30+
1931
@Override
2032
public void setBackground(Color c) {
2133
super.setBackground(c);

0 commit comments

Comments
 (0)