I wrote some JNI that seems to work well. I wanted to animated
resizing, but the flicker drove me crazy. After a lot of digging, I
wrote the following. It requires you to do a bit of belly dancing,
but works on both Tiger and Leopard. It relies on the
_StartLiveResize and _EndLiveResize methods that are defined in the
NSWindow class. The challenges are:
1. you need to call _StartLiveResize and _EndLiveResize on the AppKit
thread
2. you need to call your Java code on the EDT
3. you have to code it up slightly different on 10.4 and 10.5
I have a subclass of JFrame, where code is:
public void setBoundsNoFlicker(int x, int y, int width, int
height) {
if (Platform.isMacOSX(10, 5)) {
setBoundsNoFlicker_10_5(x, y, width, height);
} else if (Platform.isMacOSX(10, 4)) {
setBoundsNoFlicker_10_4(x, y, width, height);
} else { // Don't have an implementation for Windows or
earlier/later MacOS X
super.setBounds(x, y, width, height);
}
}
private void setBoundsNoFlicker_10_5(int x, int y, int width,
int height) {
NSWindowJNI.library().StartLiveResize(nswindow); // will
call on AppKit thread
super.setBounds(x, y, width, height);
NSWindowJNI.library().EndLiveResize(nswindow); // will call
on AppKit thread
}
private void setBoundsNoFlicker_10_4(int x, int y, int width,
int height) {
NSWindowJNI.library().SetMacBoundsNoFlicker10point4
(nswindow, x, y, width, height); // will call on AppKit thread
super.setBounds(x, y, width, height);
}
NOTE: I have glue code that ensures that those C methods are run on
the AppKit thread using performSelectorOnMainThread: passing YES on
the waitUntilDone:
At some point I'll have time to post my entire library but hopefully
that snippet will help.
-- John
On Sep 23, 2008, at 7:43 PM, Ken Orr wrote:
Is there any way to programmatically resize a Window via setSize
without causing a horrendous looking flicker? Its impossible to
create a custom window resize widget that reacts to mouseDragged
events with the current state of affairs. If there is *any* way to
do this, even with platform specific casting, I'm willing to do it.
I'm hoping one of the Apple guys chimes in!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden