Mailing Lists: Apple Mailing Lists

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

Re: Default button



I have to correct myself. I just found out that every second time I display a dialog, the blue default is shown. But never the first time =(

This is how one of my dialogs are shown. It is created the first time it is requested to be showned (any time after the main JFrame is displayed):

<x-tad-bigger> </x-tad-bigger><x-tad-bigger>if</x-tad-bigger><x-tad-bigger> (</x-tad-bigger><x-tad-bigger>this</x-tad-bigger><x-tad-bigger>.appOpenDialog == </x-tad-bigger><x-tad-bigger>null</x-tad-bigger><x-tad-bigger>)
{
</x-tad-bigger><x-tad-bigger>this</x-tad-bigger><x-tad-bigger>.appOpenDialog = </x-tad-bigger><x-tad-bigger>new</x-tad-bigger><x-tad-bigger> OpenDialog(</x-tad-bigger><x-tad-bigger>this</x-tad-bigger><x-tad-bigger>);
}
</x-tad-bigger><x-tad-bigger>this</x-tad-bigger><x-tad-bigger>.appOpenDialog);
</x-tad-bigger><x-tad-bigger>true</x-tad-bigger><x-tad-bigger>);
</x-tad-bigger><x-tad-bigger>this</x-tad-bigger><x-tad-bigger>.appOpenDialog.enableDefaultButton();
</x-tad-bigger>

When the user press cancel or the close widget, it is disposed <x-tad-bigger>appOpenDialog.dispose()</x-tad-bigger>

According to Dustin's advice, I set it to be default after it is set visible:

<x-tad-bigger> </x-tad-bigger><x-tad-bigger>public</x-tad-bigger><x-tad-bigger> </x-tad-bigger><x-tad-bigger>void</x-tad-bigger><x-tad-bigger> enableDefaultButton()
{
</x-tad-bigger><x-tad-bigger>true</x-tad-bigger><x-tad-bigger>);
</x-tad-bigger><x-tad-bigger>this</x-tad-bigger><x-tad-bigger>.openButton);
}
</x-tad-bigger>

To me it is a mystery that it works every time except from the first time it is shown...

Josef

Op 7-apr-05 om 9:57 heeft Josef Henryson het volgende geschreven:

Dustin,

Your trick works fine for my JFrame. Thanks!

But for my JDialogs it doesn't happen except the first one that is a login dialog. It seems like something in my code is in conflict with this behaviour. I got it to work for the login dialog after removing the line 'dialog.dispose()' which I called last in the constructor and then I called 'dialog.setVisible()' to show it. So I removed all 'dispose()' calls on the other dialogs but without success.

Anyone else with experience on this?

Regards, Josef

Op 5-apr-05 om 23:20 heeft Dustin Sacks het volgende geschreven:

I have been able the get a default button to show the blue pulsing look on a JFrame. The key seems to be setting the default button after the frame is visible. e.g.:

jframe.show();
jframe.getRootPane().setDefaultButton(button);

If you show/hide the frame then you will have to set the default button every time it gets made visible.

--
Dustin Sacks
Sillysoft Games
http://sillysoft.net

On Apr 5, 2005, at 4:40 AM, email@hidden wrote:

The JButton needs to be on a JDialog.
If it is on a JFrame the Aqua Look and Feel will not change its appearance.
The behaviour should be correct though. Press the Enter key and the button
fires the action performed event.

_______________________________________________
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

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

This email sent to email@hidden

References: 
 >RE: Default button (From: email@hidden)
 >Re: Default button (From: Dustin Sacks <email@hidden>)
 >Re: Default button (From: Josef Henryson <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.