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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:00:03+00:00 2026-06-18T15:00:03+00:00

this program suppose to create a window that has a status bar under it

  • 0

this program suppose to create a window that has a status bar under it that shows how many times the mouse was clicked without being moved on the screen. when you move the mouse and click it suppose to start a new count. it also distinguishes different mouse buttons. I’ve followed this code exactly as a tutorial I saw, but it doesn’t work. I just get the window with a status bar that never changes.

public class Adapter_class extends JFrame {

    private String details;
    private JLabel statusBar;
    public Adapter_class() {

        super("Adapter mouse:");

        this.statusBar = new JLabel("Default");
        add(this.statusBar, BorderLayout.SOUTH);

        addMouseListener(new MouseClass());
    }

    private class MouseClass extends MouseAdapter {
        public void MouseClicked (MouseEvent event) {
            details = String.format("You clicked the mouse %d", event.getClickCount());


            //this is for using a mouse from a mac
            if (event.isMetaDown())
            details += " with the right mouse button";
            else if (event.isAltDown())
            details += " with the center mouse button";
            else
            details += " with the left mouse button";

            statusBar.setText(details);
        }
    }
}

this is the main:

import javax.swing.JFrame;

public class Adapter_main {

    public static void main(String[] args) {

        Adapter_class window = new Adapter_class();
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        window.setSize(400, 300);
        window.setVisible(true);
    }
}
  • 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-18T15:00:06+00:00Added an answer on June 18, 2026 at 3:00 pm
    public abstract class MouseAdapter implements MouseListener, MouseWheelListener, MouseMotionListener {
        /**
         * {@inheritDoc}
         */
        public void mouseClicked(MouseEvent e) {}
    

    Use this:

    private class MouseClass extends MouseAdapter {
        public void mouseClicked (MouseEvent event){
    

    Here the function you have to write is **mouseClicked** not **MouseClicked**

    Thats why it helps to use annotations.
    @Override would have helped you immediately.

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

Sidebar

Related Questions

Suppose I have this: <Window stuff Icon=Resources\myicon.ico> If I run the program on Windows
Say suppose I am running a java program through command line. And this program
This program is supposed to determine how many units are stored in the value
I wrote this short program which has a tiny GUI. Its supposed to allow
This program I use has it's own variables to set when you run it,
This program stores pairs in a map, counting the number of times a word
For homework, I'm trying to create a CustomButton that has a frame and in
My program is suppose to make a GUI that calculates the square root of
I'm trying to use this example to create a program which will list all
I am supposed to modified this Sierpinski's triangle program to count the number of

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.