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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:40:58+00:00 2026-05-13T11:40:58+00:00

(using netbeans and java) I have the following 1 text field named input 1

  • 0

(using netbeans and java)

I have the following
1 text field named input 1 (named x5)
1 text field named input 2 (named plus10)
1 text field named input 3 (named plus5perc)

1 answer field (an uneditable text field)

1 button

When a number is placed into either input a calculation is done when the calculate button is pressed e.g. if i put in 2 in input 1 and click the button = input1 * 5 and the answer is displayed in the answer field
when 2 is put into input 2 = (input 2 + 10) * 5
when 2 is put into input 3 = input 3 + 5%

instead of having 3 input fields i would like 1 drop down list and one input

so you choose from the drop down which you want and only have 1 input field.

i don’t know how to do dropdowns etc and any help would be appreciated


edit

anyone know how to on load hide the 3 inputs and then show the relivant input once it is selected from the combo box?

  • 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-13T11:40:58+00:00Added an answer on May 13, 2026 at 11:40 am

    I gave this a try (hope that’s what you want).

    With all that links and tutorials already provided, you should have been able to do that (IMO).

    That’s what it looks like:

    Screenshot http://img97.imageshack.us/img97/9557/socombobox.png

    It does not do proper exception handling, does not round the results and is not really object oriented (just uses hardcoded indexes, be careful when changing).


    Add the components (called txtInput, cmbChoose, btnDo and txtResult in my case.

    Edit the model property of your JComboBox, using Combo Box Model Editor and set it to

    x5
    plus10
    plus5perc
    

    This will generate the following source:

    cmbChoose.setModel(new javax.swing.DefaultComboBoxModel(
        new String[] { "x5", "plus10", "plus5perc" }));
    

    Put the following into your JButtons ActionPerformed method.

    try {
        float input = Float.valueOf(txtInput.getText());
        float output = 0;
    
        switch (cmbChoose.getSelectedIndex()) {
            case 0:
                output = input * 5; break;
            case 1:
                output = input + 10; break;
            case 2:
                output = input * 1.05f;
        }
    
        txtResult.setText(String.valueOf(output));
    } catch (Exception e) {
        txtResult.setText("[Error]");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 377k
  • Answers 377k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have you considered using Scripting Bridge? It's built into the… May 14, 2026 at 9:03 pm
  • Editorial Team
    Editorial Team added an answer Your math is wrong, your saying if the scrollbar position… May 14, 2026 at 9:03 pm
  • Editorial Team
    Editorial Team added an answer Define a new style for code - set an appropriate… May 14, 2026 at 9:03 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.