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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:31:30+00:00 2026-05-25T18:31:30+00:00

I am pretty sure this is very easy and that I am only missing

  • 0

I am pretty sure this is very easy and that I am only missing one line or two but I just cannot make this work despite searching for solutions over the internet. I am fairly new to java and my problem is in a desktop application.

I have a pretty simple desktop application with one text area, one menu bar with one menu and 3 menu item. I want to edit the text of the text area when I click on the Statistic menu item in a JFrame.

Here is the part of the code where I create the menu bar, menu and menu items (as well as their events):

//menu
        mnuRevision.setText("Revision");

    mnuitmStats.setText("Statistique");
    mnuitmStats.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            mnumnuitmStatsMouseClicked(evt);
        }
    });
    mnuRevision.add(mnuitmStats);

    mnuitmOrthographe.setText("Grammaire et orthographe");
    mnuitmOrthographe.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            mnuitmOrthographeMouseClicked(evt);
        }
    });
    mnuRevision.add(mnuitmOrthographe);

    mnuitmAnalyse.setActionCommand("Analyse");
    mnuitmAnalyse.setText("Analyse");
    mnuRevision.add(mnuitmAnalyse);

    jMenuBar1.add(mnuRevision);

    setJMenuBar(jMenuBar1);

Here is the Mousclicked function:

    private void mnumnuitmStatsMouseClicked(java.awt.event.MouseEvent evt){
        this.txtTexte.setText("asdf");
        this.repaint();

    }

What I want to do is when I click on mnuitemStats, the txtTexte will get the text “asdf” written in it. Somehow, this is not working. It looks like the program is not even getting into the function. I looked on some tutorials and they pretty much have the same code as me except for the objects names since most tutorials uses JButton instead of JMenuItem.

I can provide my whole code if it is needed, but I thought the rest would be irrelevant since it does not touch the menu bar or the textarea. I am using Eclipse Java EE IDE.

  • 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-25T18:31:31+00:00Added an answer on May 25, 2026 at 6:31 pm

    I usually write something like

    mnuitemStats.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent event)
        {// your logic here;
        }});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pretty sure that this question is very noob but I'm not used to
intro: I am pretty sure this is my fault. But I just don't see
Pretty sure this question counts as blasphemy to most web 2.0 proponents, but I
I'm pretty sure this is a simple question in regards to formatting but here's
I am pretty sure this is possible just not sure what is the term
I'm pretty sure this is some stupid mistake from me but i haven't been
For anyone that remembers the protocol Avatar, (I'm pretty sure this was it's name)
Firstly, I realise that this is a very similar question to this one: Which
I'm pretty sure this is impossible, but. . . I am trying to get
I am sure this is pretty standard stuff, but I can't seem to wrap

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.