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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:10:59+00:00 2026-05-27T19:10:59+00:00

I have a type game in which you have to type the words that

  • 0

I have a type game in which you have to type the words that appear as fast as possible before the time limit runs out, but every time you type a word, you must move the mouse and click enter and click back into the user input to type the next word. I was just hoping if there was way to use “keyCode.VK_Enter” to issue an Action Command called by the JButton.

Some snippets of my code:

The Enter button and user input and output:

enter = new JButton("Enter");
    enter.setFont(serif);  //serif is specified earlier
    enter.setActionCommand("Enter");
    enter.addActionListener(this);
    container.add(enter);

userOutput = new JTextField(50);
    userOutput.setFont(serif);
    container.add(userOutput);
    userOutput.setEditable(false);

userInput = new JTextField(43);
    userInput.setFont(serif);
    container.add(userInput);
    userInput.setEditable(false);

The actionPerformed method getting the enter button’s action command:

if(userInput.getText().equals(userOutput.getText())){
            userInput.setText("");
            score += 100;
  • 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-27T19:10:59+00:00Added an answer on May 27, 2026 at 7:10 pm

    Why don’t you just add an actionlistener to the JTextField (which would be triggered when the user hits enter).

    userInput.addActionListener(new ActionListener() {
    
        public void actionPerformed(ActionEvent e) {
            // Do something
        }
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this type which is basically a struct { int x,y,z; } that
I have a struct which has several arrays within it. The arrays have type
I have an type of document which users should not be able to read
I have a type and an interface and I need to verify that the
I am developing a Quiz game application which is being developed completely but at
So i have an assignment in which i have to make a guessing game
I'm basically creating a trivia type of game. Where you have a question and
I have an android game which loads a list of 'games' the user has
I have a small card game at Facebook (and few Russian social networks), which
I'm making a Tic-tac-toe game and i have a board class which contains 9

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.