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 9007853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:48:04+00:00 2026-06-16T01:48:04+00:00

anyone can tell why the class OpenMenuListener doesnt send a feedback when i click

  • 0

anyone can tell why the class OpenMenuListener doesnt send a feedback when i click the open button in my Gui ? The erase button works though. It sends me a feedback. I’m exausted.

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


public class DrawingApplication extends JFrame {

    JComponent drawingArea;

    class EraseButtonListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Clicked erase");
        }
    }

    class OpenMenuListener implements ActionListener{
        public void actionPerformed(ActionEvent e) {
            System.out.println("Clicked open");
    }
    }
        public DrawingApplication() {
        JPanel frame = new JPanel();
        add(frame);
        // panel1.add( new JButton(Figuur),BorderLayout.CENTER);

        drawingArea = new JLabel();
        // label1.add(drawingArea);
        frame.add(drawingArea);

        // Creates a menubar for a JFrame
        JMenuBar menuBar = new JMenuBar();
        // Add the menubar to the frame
        setJMenuBar(menuBar);
        JMenu fileMenu = new JMenu("File");
        menuBar.add(fileMenu);


        JMenu open = new JMenu("Open");
        fileMenu.add(open);
        fileMenu.addSeparator();
        JMenu save = new JMenu("Save");
        fileMenu.add(save);
        fileMenu.addSeparator();
        JMenu close  =new JMenu("Close");
        fileMenu.add(close);
        JMenu helpMenu = new JMenu("Help");

        menuBar.add(helpMenu);
        helpMenu.add(new JMenu("Info"));

        JPanel panel2 = new JPanel();
        add(BorderLayout.SOUTH, frame);
        frame.add(new JLabel("figuurkeuze"));
        frame.add(panel2);
        setVisible(true);

        JRadioButton rectButton = new JRadioButton("Rectangle");
        JRadioButton triangleButton = new JRadioButton("Triangle");
        JRadioButton circleButton = new JRadioButton("Circle");
        frame.add(rectButton);
        frame.add(triangleButton);
        frame.add(circleButton);

        JButton erase = new JButton("Erase");
        frame.add(erase);

        EraseButtonListener eraselistener = new EraseButtonListener();
        erase.addActionListener(eraselistener);

        OpenMenuListener openMenuListener = new OpenMenuListener();
        open.addActionListener(openMenuListener);



    }

    public static void main(String[] args) {

        DrawingApplication frame = new DrawingApplication();
        frame.setTitle("My prgram");
        frame.setSize(400, 300);

        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(EXIT_ON_CLOSE);

    }

}
  • 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-16T01:48:05+00:00Added an answer on June 16, 2026 at 1:48 am

    It seems a problem of name aliasing, you add the listener to the open variable which is declared as a JMenuItem, so you are adding the ActionListener to the menu item instead that to a button (that you never declare since there is no JButton open = new JButton("open") anywhere).

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

Sidebar

Related Questions

Can anyone tell me what class name to specify for an html button, e.g,
Can anyone tell me what the scope of the static variable in the class
Can anyone tell me what's wrong with this code? class Dataset < ActiveRecord::Base has_many
Can anyone tell me what is wrong with this code? public abstract class BoardTestBean{
Can anyone tell me why the output of this class is 'xa'? why the
Can anyone tell me if its possible to redeclare a C# class in IronPython?
Possible Duplicates: interface and abstract class. Abstract classes vs Interfaces Can anyone tell me
Can anyone tell me if this code: public class OvTester { @Override public int
Can anyone tell me how do i create drill down fusioncharts using PHP class
can anyone tell me how to create a class method and using that how

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.