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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:18:55+00:00 2026-05-31T02:18:55+00:00

import java.awt.*; import java.awt.event.*; import javax.swing.*; public class test extends JFrame implements MouseListener {

  • 0
import java.awt.*;
import java.awt.event.*;
import javax.swing.*; 
public class test extends JFrame implements MouseListener
{
JFrame f;
JPanel p;
JButton b;
test()
{
    f=new JFrame("My Frame");
    p=new JPanel();
    f.add(p);
    b=new JButton("Button");
    p.add(b);
    f.setSize(100,100);
    f.setVisible(true);
    b.addMouseListener(new MouseListener()
    {
        public void mouseClicked(MouseEvent ae)
        {
            System.out.print("mouse clicked");
        }
    });
    b.addMouseListener(new MouseListener()
    {
        public void mouseEntered(MouseEvent ae)
        {
            System.out.print("mouse Entered");
        }
    });
    b.addMouseListener(new MouseListener()
    {
        public void mouseExited(MouseEvent ae)
        {
            System.out.print("mouse Exited");
        }
    });
    b.addMouseListener(new MouseListener()
    {
        public void mousePressed(MouseEvent ae)
        {
            System.out.print("mouse Pressed");
        }
    });
    b.addMouseListener(new MouseListener()
    {
        public void mouseReleased(MouseEvent ae)
        {
            System.out.print("mouse Released");
        }
    });
}
public static void main(String args[])
{
    new test();
}
}

Errors are as follows:

--------------------Configuration: <Default>--------------------
C:\Users\SHUBHENDU\Documents\test.java:19: <anonymous test$1> is not abstract and      does not override abstract method mouseExited(java.awt.event.MouseEvent) in        java.awt.event.MouseListener
        {
        ^
C:\Users\SHUBHENDU\Documents\test.java:26: <anonymous test$2> is not abstract and does not override abstract method mouseExited(java.awt.event.MouseEvent) in java.awt.event.MouseListener
        {
        ^
C:\Users\SHUBHENDU\Documents\test.java:33: <anonymous test$3> is not abstract and does not override abstract method mouseEntered(java.awt.event.MouseEvent) in java.awt.event.MouseListener
        {
        ^
C:\Users\SHUBHENDU\Documents\test.java:40: <anonymous test$4> is not abstract and does not override abstract method mouseExited(java.awt.event.MouseEvent) in java.awt.event.MouseListener
        {
        ^
C:\Users\SHUBHENDU\Documents\test.java:47: <anonymous test$5> is not abstract and does not override abstract method mouseExited(java.awt.event.MouseEvent) in java.awt.event.MouseListener
        {
        ^
5 errors
  • 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-05-31T02:18:56+00:00Added an answer on May 31, 2026 at 2:18 am

    If you have a concrete Java class (non-abstract class) you have to implement all the methods that an interface has, of course if your class implements that interface.
    So add unimplemented methods of MouseListener interface to your code. But you are adding a new MouseListener to the same button every time. That’s not the way it is used. You can/should implement all MouseListener methods in the same code body. Remove redundant MouseListener additions to your JButton b.

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

Sidebar

Related Questions

package test; import java.awt.*; import java.awt.event.*; import java.awt.geom.Ellipse2D; import java.awt.image.BufferedImage; import javax.swing.*; public class
Here I found this code: import java.awt.*; import javax.swing.*; public class FunWithPanels extends JFrame
Here is the code: import javax.swing.*; import java.awt.event.*; import java.awt.*; public class TestGrid {
Here is the code: import javax.swing.SwingUtilities; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JLabel; import java.awt.event.*;
import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.FileNotFoundException; import java.io.IOException; import javax.swing.JButton; import javax.swing.JFrame;
Here is my code: import javax.swing.*; import java.awt.*; public class PanelModel { public static
So I've got a JPanel implementing MouseListener and MouseMotionListener : import javax.swing.*; import java.awt.*;
import java.awt.*; import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.event.*;
Consider: import java.awt.*; import javax.swing.*; import java.awt.event.*; import javax.crypto.*; import javax.crypto.spec.*; import java.security.*; import
I have the following: import javax.swing.JFrame; public class Directions { public Directions(){ JFrame frame

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.