Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3841860
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:42:42+00:00 2026-05-19T15:42:42+00:00

I have an annoying problem, and I don’t seem to understand where in comes

  • 0

I have an annoying problem, and I don’t seem to understand where in comes from. I have an application and a simple UI for it. The problem is that when I run the program buttons respond only to the second click. After they do what they have to do, buttons respond to the first click. I really don’t know what is the source of the problem. Here is some source code for binding jButton and actionlistener:

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jButton1.addActionListener(new SolutionListener());
}

And here is actionlistener itself (if it helps):

private class ListListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
        jTextArea1.setText(null);
        if (jTextField2.getText().equals("")) {
            jTextArea1.append("Input a value");
        }
        else {
            for (int i = 2; i <= Integer.valueOf(jTextField2.getText().trim()); i++) {
                if(isSquare(i) == true) {
                    continue;
                }
                else {
                    PE pe = new PE(i);
                    answer = pe.solve();
                    jTextArea1.append(i + "\t");
                    jTextArea1.append(answer[0].toString() + " ");
                    jTextArea1.append(answer[1].toString() + "\n");
                }
            }
        }
    }
}

I would really appreciate any help, thanks in advance!

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T15:42:42+00:00Added an answer on May 19, 2026 at 3:42 pm

    If you try this:

        jButton1.addActionListener(new ActionListener () {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                System.out.println("outside Action");
                jButton1.addActionListener(new ActionListener () {
                    public void actionPerformed(java.awt.event.ActionEvent evt2) {
                        System.out.println("inside Action");
                    }
                });
            }
       });
    

    One key click will print “outside Action” and the second will print “inside Action”.

    You only need one ActionListener per JButton.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple but annoying problem and I don't understand the reason. I
I have built a simple Android application to solve an annoying problem. Whenever you
I have this annoying problem, that Im pretty sure happens to all of you
We have a little annoying problem with our delphi 2007 IDE, from time to
I have encountered a most annoying problem that occurs on the PWD variable when
I have an annoying problem: I'm fetching a lot of GeoJSON data from a
I have an app that is nearly finished but encountered an annoying problem. In
I have to write a program that is required to run several other programs
I have an annoying error that's been popping up, and I don't know where
I have a real annoying problem and I can't seem to find it. Only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.