Announcement Announcement Module
Collapse
No announcement yet.
default button for view, eg ENTER in login Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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

      Comment


      • #4
        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

        Comment

        Working...
        X