Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: ActionListener inside another ActionListener

  1. #1
    Member
    Join Date
    Mar 2012
    Posts
    36
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default delete

    deletedelete
    Last edited by kpat; March 29th, 2012 at 04:49 AM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,297
    Thanks
    180
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: ActionListener inside another ActionListener

    I don't understand why do you need to nest an ActionEvent? When the user hits the Submit JButton, the ActionListener code just needs to retrieve the selected value from the JComboBox

    (...and please read the nomenclature I use closely - we are programmers and our brains often work like compilers - meaning things like "combo box" and actionEvent quite often lead to confusion, resulting in a 'cannot find symbol' error)

  3. #3
    Member
    Join Date
    Mar 2012
    Posts
    36
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: ActionListener inside another ActionListener

    deletedelete
    Last edited by kpat; March 29th, 2012 at 04:50 AM.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,297
    Thanks
    180
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: ActionListener inside another ActionListener

    So i want to search the 'type' the user has selected in the database once they have clicked on the 'searchButton'.
    Then why not just get the value of jTypeDDB?

    if (e.getSource() == searchButton) {
        String type = jTypeDDB.getSelectedItem().toString();
    }

    ...and please read the note in post #2. Combo Box != JComboBox. Like I said, using shorthand for class names can lead to confusion. So why even leave the possibility of confusion?

  5. #5
    Member
    Join Date
    Mar 2012
    Posts
    36
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: ActionListener inside another ActionListener

    deletedelete
    Last edited by kpat; March 29th, 2012 at 04:50 AM.

  6. #6
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,297
    Thanks
    180
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: ActionListener inside another ActionListener

    Quote Originally Posted by kpat View Post
    Thank you for your quick reply copeg.

    That works if i only have 1 JCombobox but i have 4 JCombobox's how would implement that for 4 JCombobox's. I've tried the code for each one but it doesn't gel.

    Thanks
    That works for as many JComboBox's as you have, provided you use the appropriate references to the object to get the selected value.

  7. #7
    Member
    Join Date
    Mar 2012
    Posts
    36
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: ActionListener inside another ActionListener

    Thanks a lot copeg it looks like its working how its suppose to.

Similar Threads

  1. Help with ActionListener please
    By knightmetal in forum AWT / Java Swing
    Replies: 3
    Last Post: August 23rd, 2011, 05:41 PM
  2. ActionListener help
    By hello_world in forum What's Wrong With My Code?
    Replies: 10
    Last Post: July 27th, 2011, 11:45 PM
  3. ActionListener help
    By QBird in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 1st, 2011, 11:25 AM
  4. [SOLVED] ActionListener help
    By kbwalker87 in forum What's Wrong With My Code?
    Replies: 13
    Last Post: October 14th, 2010, 06:57 PM
  5. ActionListener Help?
    By Drag01 in forum AWT / Java Swing
    Replies: 1
    Last Post: March 30th, 2010, 08:21 PM