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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:14:49+00:00 2026-05-31T19:14:49+00:00

I know the title didnt say much, but here I go with a clearer

  • 0

I know the title didnt say much, but here I go with a clearer explanation:

I have made a tool/app in netbeans that extends JFrame. It has a button and i’ve added a keyListener when the button is pressed. It gets if the VK_DOWN button is pressed, if yes, it presses it 4 times and then presses enter. this works very fine, but I want to use this in a game. But when I have the app running, if i click on something else, it takes away the priority (i hope thats the right word here..), it doesnt work anymore unless I click on the app and make it top priority again..

Here is the code for the button:

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
    jButton1.addKeyListener(new KeyAdapter() {
    public void keyReleased(KeyEvent e) {

    }
    public void keyTyped(KeyEvent e) {
    // TODO: Do something for the keyTyped event
    }
    public void keyPressed(KeyEvent e) {
    // TODO: Do something for the keyPressed event
        if (e.getKeyCode() == e.VK_L){
            System.out.println("Works");
        }
        if (e.getKeyCode() == e.VK_DOWN){
            System.out.println("Down Arrow Pressed!");
            e.setKeyCode(e.VK_DOWN);
            e.setKeyCode(e.VK_DOWN);
            e.setKeyCode(e.VK_DOWN);
            e.setKeyCode(e.VK_DOWN);
            e.setKeyCode(e.VK_ENTER);

        }
    }
    });
}

I want to press the VK_DOWN arrow key in the game and let the app press it 4 times and then press enter by itself. This works only when I’m running the app on top of everything else; but if Im running the game, the game takes the higher priority and so the app dont work ..

Please help.

  • 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-31T19:14:50+00:00Added an answer on May 31, 2026 at 7:14 pm

    You cannot do what you are looking to do with Java unless you use some native code.

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

Sidebar

Related Questions

i didn't really know how to title this question, but here's a thing that
Folks, I know I didn't phrase that title very well, but here's the scenario.
Hey all, title may be abit misleading but i didnt know the correct way
I know the title makes this sound very easy, but I have a For
I know, great title right ;-) Anyway, lets say I have the following code
Sorry about the vague title, but i didnt know how to ask the question
I really didn't know what title to give this question, but I'll explain here:
Sorry for a title that bad, but i didn't know how to describe my
The title may sound confusing but it actually isn't, I just didn't know how
I know the title is ridiculously long, but I'm in need of some assistance

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.