Results 1 to 4 of 4

Thread: default button for view, eg ENTER in login

  1. #1

    Default default button for view, eg ENTER in login

    Hi all,

    Anyone any ideas on how to retrieve the root Frame of the application?
    I want to set a default button for a view but cant get hold of the root frame to set that button, eg a login screen with a default "login" button

    I could always add listeners but would like to keep it simple...

    Rootpane always a null, so rfame seems to be?, and on focusgained seems like the only place where i could set a default button for a screen.

    Anyone managed to achieve this? any tips?

    Code:
     public void componentFocusGained() {
            clearUserNameAndPasswordFields();  
            getActiveWindow().getControl().getRootPane().setDefaultButton(_loginButton);       
    
        }
    cheers

    Alan

  2. #2
    Join Date
    Jul 2005
    Location
    Austria
    Posts
    105

    Cool Remove Default-Button

    Hi,

    I don't wan't to open a new thread about this topic. Sometimes it is necessary to enable the RETURN key to commit the form. In order to achieve this, I remove the default button in my TitledApplicationDialog like this:
    Code:
    getDialog().getRootPane().setDefaultButton(null);
    it works fine, but an interesting phenomenon occurs when I open the dialog. The dialog is shown on the top left corner. If i don't remove the default button, the dialog will be centered.

    Any ideas?

    markus

  3. #3
    Join Date
    Jul 2006
    Location
    Switzerland
    Posts
    21

    Default

    Hi Markus,

    This sounds like your code causes something that has an impact on the call of setLocationRelativeTo(parent) in the ApplicationDialog class. If the setLocationRelativeTo() is called and parent is null, the dialog is displayed centered on screen ... if not it is displayed relative to the parent component.
    But maybe another hint could help you: If you look at the addCancelByEscapeKey() method in the ApplicationDialog class you should be able to register the ENTER key for the finish command and you must no longer set the default button to null.

    I haven't tested this .... but I hope it helps with your problem.

    cheers,
    Andi

  4. #4
    Join Date
    Jul 2005
    Location
    Austria
    Posts
    105

    Wink

    thanks for the hint. I've also tried to remove the RETURN key from the input map, which is generated by ApplicationDialog. But in Swing a default button is automatically associated with the RETURN key.

    thank you again for the hint
    greetings, markus

Similar Threads

  1. Odd behaviour when injecting TransactionTemplate
    By damon311 in forum Container
    Replies: 3
    Last Post: Jul 23rd, 2005, 11:21 AM
  2. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM
  3. puzlle : can't change the default login url?
    By creatxr in forum Security
    Replies: 9
    Last Post: Apr 12th, 2005, 02:15 AM
  4. Cancel button on the login dialog
    By Scott Tavares in forum Swing
    Replies: 3
    Last Post: Feb 14th, 2005, 01:09 PM
  5. Acegi - Login Tapestry
    By john017 in forum Security
    Replies: 1
    Last Post: Feb 4th, 2005, 01:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •