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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:34:16+00:00 2026-05-21T20:34:16+00:00

Basically I’ve been experimenting with the use of drop-boxes in a GUI I’m making

  • 0

Basically I’ve been experimenting with the use of drop-boxes in a GUI I’m making in netbeans. I know how easy it is to obtain a string variable from a text field using the .getText() method, however I would like to get a value that a user selects from a drop-down menu (i.e. the combo box), hits a ‘submit’ button (which the actionPerformed method is attached to) and place it in a string variable.

This would allow me to use this string variable to pass into a set() method in another class.

This is an annoying little problem but I expected there to be a few when I started.

Any help appreciated.

  • 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-21T20:34:17+00:00Added an answer on May 21, 2026 at 8:34 pm

    Try

    jComboBox.getSelectedItem()
    

    And perhaps the following snipped might be useful to get the string.

    Object selectedItem = comboBox.getSelectedItem();
    if (selectedItem != null)
    {
        String selectedItemStr = selectedItem.toString();
        Foo(selectedItemStr); // Some method that takes a string parameter.
    }
    

    to get the selected item.

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

Sidebar

Related Questions

Basically I'm making a filter for my portfolio so that you can click on
Basically my question is, if I have a number string, and i'm going to
Basically, I am making a XML stylesheet. So I am using the below method:
Basically I need to know how to make this work. I removed one of
Basically I'm trying to improve on the Ghosts in a Pacman game I'm making.
Basically I want to know how to set center alignment for a cell using
Basically what I'm trying to do is generate an alphanumeric string, which is passed
Basically, I've been trying nXhtml mode, and it's terribly slow and buggy in Emacs
Basically I need to get older version of a file in the repository without
Basically I want to check the extended permissions the user has granted my app.

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.