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

  • SEARCH
  • Home
  • 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 8166853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:01:18+00:00 2026-06-06T20:01:18+00:00

How do I use the action listeners that are attached to the buttons. And

  • 0

How do I use the action listeners that are attached to the buttons. And how would I make it work from a separate class file?

Edit:
This is what i have:

import java.awt.*; 

import java.awt.event.*;

public class Gui {

static boolean playerturn = true;

public static void main(String[] args) {

    Frame frame1 =new Frame("TickTacToe - By Fred");
    frame1.setLayout(null);
    frame1.setBounds(250,150,500,500);
    frame1.setVisible(true);
    frame1.addWindowListener(new WindowAdapter(){
        public void windowClosing(WindowEvent e){
            System.exit(0);
        }
    });

    final Button button11 = new Button("");
    button11.addActionListener(null);

    final Button button12 = new Button("");
    button11.addActionListener(null);

    final Button button13 = new Button("");
    button11.addActionListener(null);

    final Button button21 = new Button("");
    button11.addActionListener(null);

    final Button button22 = new Button("");
    button11.addActionListener(null);

    final Button button23 = new Button("");
    button11.addActionListener(null);

    final Button button31 = new Button("");
    button11.addActionListener(null);

    final Button button32 = new Button("");
    button11.addActionListener(null);

    final Button button33 = new Button("");
    button11.addActionListener(null);


    button11.setBounds(100, 100, 80, 70);
    button12.setBounds(100, 200, 80, 70);
    button13.setBounds(100, 300, 80, 70);
    button21.setBounds(200, 100, 80, 70);
    button22.setBounds(200, 200, 80, 70);
    button23.setBounds(200, 300, 80, 70);
    button31.setBounds(300, 100, 80, 70);
    button32.setBounds(300, 200, 80, 70);
    button33.setBounds(300, 300, 80, 70);

    frame1.add(button11); 
    frame1.add(button12); 
    frame1.add(button13); 
    frame1.add(button21); 
    frame1.add(button22); 
    frame1.add(button23); 
    frame1.add(button31); 
    frame1.add(button32);
    frame1.add(button33); 
}}

What i need is someway of being able to utilize the listeners.

  • 1 1 Answer
  • 0 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-06-06T20:01:21+00:00Added an answer on June 6, 2026 at 8:01 pm

    And how would i make it work form a different class file?

    Import it, if you need to, and then create an instance of it.

    how to use the action listeners that are attached to the buttons

    Place the logic that you’d like to be executed within the actionPerformed(ActionEvent e) method of the ActionListener class (or subclass).

    For more information, see How to Write an Action Listener.

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

Sidebar

Related Questions

I just started to learn how to use action listeners. To my understanding it
We have a file manager-like application where we use the action bar home button
This one is a long one, bellow is my primary class that holds the
I would like to declare in my class a set of events that get
I have a Java class that pertains to mouse listeners that I'm wanting to
I am trying to use jquery ajax to get data from a php file.
I have a php application that makes use of a Listener class, which basically
MVC use action attributes to map the same view for http get or post:
I am trying to use action caching to cache an action and then manually
Both are delegates and have the same signature, but I can not use Action

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.