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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:04:19+00:00 2026-06-17T05:04:19+00:00

First, let me try to clarify that what I mean by control flow is

  • 0

First, let me try to clarify that what I mean by “control flow” is the way the user navigates through my UI. (This may very well not be the correct term for what I’m describing, so please suggest a better one if you know any!)

Most modern applications seem to let the user decide what to do when. The self-contained units of control mostly involve some text entry and a mouse click at most.

For the application I’m working on, I want something different (please see the end of this post for the answer to the inevitable ‘Why would you want that, that’s not good design?’). The picture below shows a sample GUI which is quite close to what I’m doing, it’s just stripped down and the business domain has been changed to make it easy to understand:

Sample UI picture

The intended control flow is the following:

1 user enters name of recipe, presses Enter
2 user enters ingredient, presses Enter
3 if ingredient field is empty, we're done: go to 9
4 dialog window shows up, queries database with user input and lets him select from a list of possible ingredients
5 if nothing was selected, go to 2
6 user enter amount, presses Enter
7 add this ingredient to an observable collection which is bound to the list
8 go to 2
9 dialog window shows up, prompts user for price of the mixture

My current code for this is based on KeyListeners attached to all of those controls which intercept Enter key presses, call the logic involved and then manually setFocus() the appropriate next text field/other control.
This works, but the code looks hard to maintain, and it feels a painful lot like the code I used to write in VB5 a few decades ago.

Is there a better approach to achieving this? I am interested both in general design patterns and in specific solutions that may be offered by frameworks such as WPF, JavaFX or Swing.


Why would anyone want that?

Two reasons:

  • This particular application has always worked this way and is used by many people with very little computer experience. Giving them too much choice of what to do how and when only adds unnecessary confusion.
  • For simple tasks like this (it is more or less just data entry) manual navigation with the mouse is bound to be slower and more error-prone than a pre-defined pathway through the entry mask.
  • 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-17T05:04:20+00:00Added an answer on June 17, 2026 at 5:04 am

    Problems

    You are overloading the Enter key. A preferred method would be to have buttons represent actions.

    Your amount field is in the wrong place, if it relates to the entire recipe rather than an ingredient. Move it down after the ingredient list.

    Buttons

    Back to the buttons. You could have a button after the name field, after the ingredient field, and after the amount field on the bottom. This allows the user to be specific about what they want to update.

    State Pattern

    You could use a state pattern to keep track of what the user has already done, and what the user can do next. If the user does things out of order, you would return an error message somewhere on your screen, guiding the user as to what to do next.

    You would have to enumerate all of the different possibilities of user actions. With 3 buttons, that makes 6 combinations.

    • name, ingredient, amount (what you described)
    • name, amount, ingredient
    • ingredient, name, amount
    • ingredient, amount, name
    • amount, name, ingredient
    • amount, ingredient, name

    You would decide which combinations are valid, and which are invalid. The state tree has a further complication in that your user is probably going to enter multiple ingredients.

    OK and Cancel Buttons

    Rather than manage state, you could add a pair of buttons to the bottom of your GUI, OK and Cancel. This allows your user to fill out the fields in any order they choose. You don’t check for validity until the OK button is left clicked.

    The OK button is the button that’s usually tied to the Enter key.

    You would still have to have a button after the ingredient field, to allow the user to enter more than one ingredient.

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

Sidebar

Related Questions

Let me clarify it first that I am still a very amateur android developer
First let me mention that I've gone through many suggested questions and found no
First let me say that I did see this article: How to remove AspxAutoDetectCookieSupport
First let me say i dont know if this is possible the way im
I can't figure this one out. At first let me say that my cache
I know that this might seem like a strange question, but let me try
Let me first clarify my question. I am doing this,parsing datas (Using DOM) and
Let me try this again since the first post got mangled... I've seen a
Let me try to set the scenario here first. This is done using ASP.NET
First let me say I have read this useful article thoroughly and am using

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.