Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Native GUI elements disappearing when resizing



Hey all,

I have a mostly swing app which has problems such as AWT, QTJ and com.apple.eawt.CocoaComponent components don't redraw after a resize or layout change. In the very simple code below, which just utilizes an AWT component, I sometimes have trouble. Sometimes the AWT button shows up, sometimes it doesn't. AWT components are always supposed to draw on top of swing (http://java.sun.com/products/jfc/tsc/articles/ mixing/) so this looks like a pretty serious bug to me. I don't care so much about AWT, or even QTJ (which exhibits similar behavior in my app, but as soon as the user hits play all is well again) but I'm having serious trouble with my custom cocoa components.

	Anyone know a workaround?

-------------

public static void main( String[] args ) {
System.setProperty ( "com.apple.eawt.CocoaComponent.CompatibilityMode", "false" );
final JFrame f = new JFrame( "TestWindow" );
f.getContentPane().setBackground( java.awt.Color.YELLOW );


		JPanel p = new JPanel();
		p.add( new JLabel( "JLabel" ) );
		p.add( new Button( "Button" ) );
		f.getContentPane().add( p );
		f.pack();
		f.show();
		Thread t = new Thread() {
			public void run() {
				easySleep( 1000 );
				SwingUtilities.invokeLater( new Runnable() {
					public void run() {
						f.hide();
					}
				} );
				easySleep( 1000 );
				SwingUtilities.invokeLater( new Runnable() {
					public void run() {
						f.show();
					}
				} );
				easySleep( 1000 );
				SwingUtilities.invokeLater( new Runnable() {
					public void run() {
						f.setSize( 500, 400 );
						//f.repaint();
						//f.invalidate();
						//f.validate();
					}
				} );
			}
			public void easySleep( long ms )
			{
				try{ sleep(ms); } catch(InterruptedException ie) {}
			}
		};
		t.start();
	}



-----------------------------
Bjorn Roche
XO Wave
Digital Audio Production and Post-Production Software
http://www.xowave.com
http://blog.bjornroche.com
http://myspace.com/xowave


_______________________________________________ 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


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.