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 6 of 6

Thread: Event Handler Question

  1. #1
    Member
    Join Date
    Oct 2012
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Event Handler Question

    Hi Guys, Is it possible to go from one method to another when a jbutton is clicked? Or is there another solution. Please Help.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Event Handler Question

    Yes, one method can call another method from the listener method.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Oct 2012
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Event Handler Question

    Then how can I call the other method from another class?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Event Handler Question

    To call a method in a class, you need a reference to the class that the method is in.
    referenceToCiass.theMethodInTheClass();
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Member
    Join Date
    Oct 2012
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Event Handler Question

    Thanks I figured it out

  6. #6
    Junior Member
    Join Date
    Apr 2014
    Location
    Mohali
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Event Handler Question

    make the method static that you want to call. and simply call by classname.method()
    classname is the name of class from where you want to call the method

Similar Threads

  1. Button event handler from another class
    By Scorliss in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 6th, 2013, 06:41 PM
  2. Event Handler For a JTextField
    By JamesdTurnham in forum What's Wrong With My Code?
    Replies: 8
    Last Post: June 17th, 2013, 06:16 PM
  3. JButton event handler
    By gkelly642 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 3rd, 2013, 09:01 PM
  4. Separate Event Handler Class
    By beer-in-box in forum AWT / Java Swing
    Replies: 2
    Last Post: April 1st, 2013, 09:19 AM
  5. JButton event handler
    By Jsri in forum AWT / Java Swing
    Replies: 1
    Last Post: October 25th, 2011, 07:02 AM