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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:48:10+00:00 2026-06-11T15:48:10+00:00

I am working on an application in JavaFX 2.2. I am logging on to

  • 0

I am working on an application in JavaFX 2.2. I am logging on to active directory with two fields (username and password) and have a log on button. It all works perfectly. However I have added a KeyEvent EventHandler to handle the key event of pressing ENTER which works. The problem is it also is used when the user presses the SHIFT Key. Below is the code for my Handler and there are no other KeyEvent Handlers being used in the application.

import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent; 
...   
private EventHandler<KeyEvent> keyListener = new EventHandler<KeyEvent>() {
    @Override
    public void handle(KeyEvent event) {
        if(event.getCode() == KeyCode.ENTER); {
            startLogin();
            getContext();
            try {
                checkUserLevel();
            } catch (Exception e) {
                actionTarget.setText("Unable to authenticate user\n" + userTextField.getText());
            }
            event.consume();
        } 
    }
};

Is this a bug in JavaFX?

  • 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-06-11T15:48:11+00:00Added an answer on June 11, 2026 at 3:48 pm

    You have to remove the semi-colon. From

    if(event.getCode() == KeyCode.ENTER); {
    

    To

    if(event.getCode() == KeyCode.ENTER) {
    

    Also, in Swing I know for sure you can add an ActionListener to a JTextBox directly, and it’ll trigger the action event when enter is pressed while the JTextBox as focus. It’ll prevent having your action being triggered in unrelated context. Hopefully something like that exist in JavaFX!

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

Sidebar

Related Questions

I have a java we application that is working with velocity. I get two
I was working on a small application using a simple binding in JavaFx 2.1
I have an working application. Now I want to change the table names of
I have a working application using python and zeromq and I would like to
I am working on splitting out an existing, working application that I currently have
I am working on application for Ipad.in this application i have a UIButton on
In my Fedora box i have JavaFX 2.0 working. But how can i now
I'm writing a very simple application in Javafx where there is a single button
I'm working on a Desktop JavaFX 2 application. We're using FXML, an MVC architecture
I'm working on a desktop (swing) application with Eclipse IDE. I have three comboboxes

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.