Skip to content

Commit 750010f

Browse files
committed
JFrame fix for Window->JComponent
1 parent 64195f9 commit 750010f

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed
896 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/java/awt/Container.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,10 @@ public Dimension getPreferredSize() {
16491649
@Override
16501650
@Deprecated
16511651
public Dimension preferredSize() {
1652+
return preferredSizeContainer();
1653+
}
1654+
1655+
protected Dimension preferredSizeContainer() {
16521656
/* Avoid grabbing the lock if a reasonable cached size value
16531657
* is available.
16541658
*/
@@ -1662,9 +1666,9 @@ public Dimension preferredSize() {
16621666
}
16631667
}
16641668
return (dim == null ? null : new Dimension(dim));
1665-
}
1669+
}
16661670

1667-
/**
1671+
/**
16681672
* Returns the minimum size of this container. If the minimum size has
16691673
* not been set explicitly by {@link Component#setMinimumSize(Dimension)}
16701674
* and this {@code Container} has a {@code non-null} {@link LayoutManager},
@@ -1858,12 +1862,7 @@ public void paintContainer(Graphics g) {
18581862
*/
18591863
@Override
18601864
public void update(Graphics g) {
1861-
if (isShowing()) {
1862-
// if (! (peer instanceof LightweightPeer)) {
1863-
g.clearRect(0, 0, width, height);
1864-
// }
1865-
paint(g);
1866-
}
1865+
updateContainer(g);
18671866
}
18681867

18691868
// /**
@@ -1901,7 +1900,17 @@ public void update(Graphics g) {
19011900
// }
19021901
// }
19031902

1904-
/**
1903+
protected void updateContainer(Graphics g) {
1904+
1905+
if (isShowing()) {
1906+
// if (! (peer instanceof LightweightPeer)) {
1907+
g.clearRect(0, 0, width, height);
1908+
// }
1909+
paint(g);
1910+
}
1911+
}
1912+
1913+
/**
19051914
* Paints each of the components in this container.
19061915
* @param g the graphics context.
19071916
* @see Component#paint

sources/net.sf.j2s.java.core/src/java/awt/Window.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,23 @@ public void paint(Graphics g) {
830830
paintContainer(g);
831831
}
832832

833+
@Override
834+
public void update(Graphics g) {
835+
updateContainer(g);
836+
}
837+
838+
@Override
839+
public void printAll(Graphics g) {
840+
// untested
841+
super.printAll(g);
842+
}
843+
844+
@Override
845+
public Dimension getPreferredSize() {
846+
return preferredSizeContainer();
847+
}
848+
849+
833850
/**
834851
* Shows or hides this {@code Window} depending on the value of parameter
835852
* {@code b}.

0 commit comments

Comments
 (0)