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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:01:06+00:00 2026-05-28T14:01:06+00:00

This application needs to send a motor move command when a GUI button or

  • 0

This application needs to send a motor move command when a GUI button or an arrow key is pressed and a motor stop command when the GUI button or an arrow key is released.
These bindings work fine for the down arrow until the corresponding GUI button is pressed.
After the GUI button is pressed the arrow key is ignored.
If it is the focus change that killed the binding, how can bindings be programmed to be independent of focus chages?
If not, what is the real problem and how is it repaired?

Key Bindings

Action tiltStop = new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
        MotorStop(TILT_AXIS);
    }
};
mainPanel.getInputMap().put(KeyStroke
    .getKeyStroke(KeyEvent.VK_DOWN, 0, true), "tiltStop");
mainPanel.getActionMap().put("tiltStop", tiltStop);
Action tiltDown = new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
        MotorMove(TILT_AXIS, NEGATIVE_DIR);
    }
};
mainPanel.getInputMap().put(KeyStroke
    .getKeyStroke(KeyEvent.VK_DOWN, 0, false), "tiltDown");
mainPanel.getActionMap().put("tiltDown", tiltDown);

GUI buttons

private void jButtonAxisDownMousePressed(java.awt.event.MouseEvent evt) {
    MotorMove(TILT_AXIS, NEGATIVE_DIR);
}                                              
private void jButtonAxisDownMouseReleased(java.awt.event.MouseEvent evt) {
    MotorStop(TILT_AXIS);
}                                               
  • 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-28T14:01:07+00:00Added an answer on May 28, 2026 at 2:01 pm

    how can bindings be programmed to be independent of focus chages?

    Look at the getInputMap() method. There are 3 different InputMaps. You want the one that is an ancestor so it will work even when the component doesn’t have focus.

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

Sidebar

Related Questions

This is a GUI application (actually MFC). I need a command window with the
I have an application that needs to send e-mails. Currently, this is what I
I wrote a C++ application that needs to send emails. It does this by
I am writing a .NET 3.5 WPF application in C#. This application needs to
So I have this c# application that needs to ping my web server thats
I'm developing a Java application that uses java.util.logging for its logging needs. This application
I'm creating an iPad application which needs a UIPopoverController like this one (I mean,
I have a VB6 application that needs to update it's self. For this purpose,
I'm developing an application that needs to interact over FTP. For this communication I
I am developing a Java Desktop Application . This app needs a configuration to

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.