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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:56:29+00:00 2026-06-10T21:56:29+00:00

In Swing we use a label control to indicate the user what information is

  • 0

In Swing we use a label control to indicate the user what information is requested in -generally- the following “entry” control. This entry control can be an entry, listbox, password etc.

We can inform a displayedMnemonic to instruct the user that holding down Alt key together with an accelerator key will select the associated entry control.

This is how I am designing a form, but when I press Alt+A, for example, the “associated” control doesn’t get selected, sure, because I don’t know how to bind the two controls using the IDE (Netbeans in this case).

I know I can trap the event generated by the label control and programmatically select whatever next control I need, but really do I? Isn’t there an “implicit” way to make the binding/coupling between the two controls?

As an example, I work with another programming language, Clarion for Windows. In Clarion we can define a complex data structure of the type Window, like so:

MyWindow     WINDOW( 'Test' ), GRAY, DOUBLE, CENTER
               PROMPT( '&File Name:' ), AT( 10, 10 )
               ENTRY( @S127 ), USE( szFileName ), AT( 10, 20 )
               PROMPT( '&Status:' ), AT( 50, 10 )
               LIST, FROM( 'Open|#0|Closed|#1' ), USE( ?lstStatus ), AT( 50, 20, 100, 20 )
             END 

In the above example, the PROMPT control is implicitly bound to the ENTRY control because it appears immediatelly before the later, and the same happens between the “Status” and “?lstStatus” controls.

The RTL takes care of handling Alt+F to make the selection of the szFileName control, generating the events etc. No need to say that this is a major time saving feature for the programmer, as he/she doesn’t need to program every selection for every prompt that appears on the window.

This is what I’m looking for in Swing. Any ideas?

  • 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-10T21:56:31+00:00Added an answer on June 10, 2026 at 9:56 pm

    You’ll want to use JLabel.setLabelFor

    This will associate the label with the specified control & allow you to select the control using the labels short cuts

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

Sidebar

Related Questions

What Swing class can I use to implement something like this? Add To List
In a swing GUI application, where MVC pattern is applied, how can we use
I want to use this Swing snippet to create an image from a text
first of all, this is the first week that I use swing, then sorry
In Swing, its possible to use HTML to style the words on a label.
I am trying to use Swing Timer and I wanted to start from a
I would like to use Swing to program a simple learning game. I am
I want to use QCombobox as a the Combobox of Swing in Java .
I'm trying to create a Java swing application and I'm trying to use a
I am creating one GUI in swing Java. I have to use one button

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.