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

Thread: Using jdb how do I stop in the actionPerformed method?

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Using jdb how do I stop in the actionPerformed method?

    ]import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;

    class Test implements ActionListener
    {
    static JFrame myFrame;
    static JButton myButton;
    static JLabel messageLabel;

    public static void main( String[] args )
    {
    int width = 100, height = 100;

    Test myReference = new Test();

    myButton = new JButton( "Button #1" );
    messageLabel = new JLabel();

    myFrame = new JFrame ( "My Game" );
    myFrame.setSize ( width, height );
    myFrame.setLayout ( new FlowLayout() );
    myFrame.add ( myButton );
    myFrame.add ( messageLabel );
    myFrame.setVisible ( true );

    myButton.addActionListener( myReference );
    }

    public void actionPerformed (ActionEvent referenceToTheActionEventClass )
    {
    int correctButtonNumber = 1;
    String chosenButtonText;

    chosenButtonText = referenceToTheActionEventClass.getActionCommand();

    // I want to stop here.
    correctButtonNumber = correctButtonNumber + 1;
    chosenButtonText = chosenButtonText + correctButtonNumber;
    messageLabel.setText( chosenButtonText );
    }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Using jdb how do I stop in the actionPerformed method?

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.

    What do you mean by "stop"?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Apr 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Using jdb how do I stop in the actionPerformed method?

    I want the program to suspend execution so I can examine the variables at that point,

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Using jdb how do I stop in the actionPerformed method?

    Sorry, I missed that this was a question about using a debugger. I've never used one in a java program.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Using actionPerformed method
    By Boitumelo in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 26th, 2013, 02:22 PM
  2. While Loop Confounds JDK's Command Line Debugger (jdb)
    By christerlin in forum Loops & Control Statements
    Replies: 4
    Last Post: August 16th, 2012, 02:10 PM
  3. actionPerformed Question.
    By TP-Oreilly in forum Java Theory & Questions
    Replies: 1
    Last Post: December 9th, 2011, 11:18 AM
  4. actionPerformed method
    By Deprogrammer in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 4th, 2010, 02:29 AM
  5. actionPerformed
    By Kumarrrr in forum Java Theory & Questions
    Replies: 5
    Last Post: November 23rd, 2010, 09:08 AM