Results 1 to 3 of 3
  1. #1
    schilwan is offline Member
    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0

    Default Making a button default after an action being performed

    I'm looking for some advice on how i can tackle an issue I have.

    Hopefully this thread will make sense as typing away on my iPhone as presently got no access to the net and its not easy on this small screen :(

    I have a Search Class and its primarily purpose is to do a Search, this class creates a Search Button, and the search button gets enabled as soon as some text is entered into a textfield which I will call "inputText", this is handled using a modifylistener. Some snippet below:

    Java Code:
    final Button searchButton = new Button();
    /*More code defining button*/
    textField.addModifyListener(new ModifyListener(){
    
    public void modifyText(ModifyEvent arg0) {
    /* Code enabling the Search button when more then 'x' number of characters are inserted
    */
    searchButton.enabled(true);
    }});
    At present when a user clicks search and this is a valid search criteria it will return some data where a user can then highlight 'x' number of rows in a list and then click add this adds the selected records in another grid and this enables an ok button and provides focus to this. Whilst this functionality is ok what I want is when the user gets focus back to inputText whether its using a mouse or tabs to it I want the searchButton to get focus and be the default button when the return key is pressed. As currently if a user was to enter another search criteria and hit the return key it closes the screen since the OK button has the focus. It becomes the default button as it gets enabled at the point when a user selects 'x' number of records to the grid.

    Problem i have is whilst I can set searchButton.setFocus() it will not allow me to edit my search criteria in inputText, is there a way of having a dual focus? I was hoping there was a way to set the defaultButton to searchButton when a user gets focus to the textfield.

    Just to note I don't expect anyone to provide code as i know this is usually frowned upon and since I am unable to get example of my code here due to issues with the net i'm hoping the scenario i've highlighted makes some sense. I was hoping that someone can advise if there was a way to handle such functionality in Java, i'm currently learning my way round this language.

    Is there a particular listener that would be more useful in handling this behaviour where a button becomes the default when an action is performed such as selecting a text field.

    Thanks for all responses and apologise for not having more code as examples.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,455
    Rep Power
    20

    Default Re: Making a button default after an action being performed

    Moved from New to Java.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    schilwan is offline Member
    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0

    Default Re: Making a button default after an action being performed

    Got this resolved shell.setDefaultButton(searchButton)

Similar Threads

  1. Help with Action Performed method
    By program junkie in forum New To Java
    Replies: 8
    Last Post: 12-10-2012, 03:24 AM
  2. action performed method for
    By thousif291989 in forum AWT / Swing
    Replies: 3
    Last Post: 04-21-2011, 06:08 PM
  3. Replies: 3
    Last Post: 08-08-2008, 03:53 AM
  4. JXTaskPane Action performed
    By Rama Koti Reddy in forum AWT / Swing
    Replies: 0
    Last Post: 12-10-2007, 02:27 PM

Posting Permissions

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