Skip to content

Commit 583e2f7

Browse files
committed
call revalidate() with reflection to allow for 1.6 builds
1 parent 13ba491 commit 583e2f7

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

core/src/processing/core/PApplet.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ public class PApplet extends Applet
267267
boolean useStrategy = false;
268268
Canvas canvas;
269269

270+
Method revalidateMethod;
271+
272+
270273
// /**
271274
// * Usually just 0, but with multiple displays, the X and Y coordinates of
272275
// * the screen will depend on the current screen's position relative to
@@ -869,6 +872,12 @@ public void init() {
869872
useActive = false;
870873
}
871874

875+
if (javaVersion >= 1.7f) {
876+
try {
877+
revalidateMethod = getClass().getMethod("revalidate", new Class[] {});
878+
} catch (Exception e) { }
879+
}
880+
872881
// send tab keys through to the PApplet
873882
setFocusTraversalKeysEnabled(false);
874883

@@ -10260,7 +10269,21 @@ public void componentResized(ComponentEvent e) {
1026010269
if (!newBounds.equals(oldBounds)) {
1026110270
// the ComponentListener in PApplet will handle calling size()
1026210271
setBounds(newBounds);
10263-
revalidate(); // let the layout manager do its work
10272+
10273+
// In 0225, calling this via reflection so that we can still
10274+
// compile in Java 1.6. This is a trap since we really need
10275+
// to move to 1.7 and cannot support 1.6, but things like text
10276+
// are still a little wonky on 1.7, especially on OS X.
10277+
// This gives us a way to at least test against older VMs.
10278+
//revalidate(); // let the layout manager do its work
10279+
if (revalidateMethod != null) {
10280+
try {
10281+
revalidateMethod.invoke(this);
10282+
} catch (Exception ex) {
10283+
ex.printStackTrace();
10284+
revalidateMethod = null;
10285+
}
10286+
}
1026410287
}
1026510288
}
1026610289
}

0 commit comments

Comments
 (0)