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

The Archive Base Latest Questions

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

I am having some issues with my code, I cant see whats wrong with

  • 0

I am having some issues with my code, I cant see whats wrong with the logic, but here it is. I want them to have the radio button to choose either or, and when one is selected(radio button) the text area isn’t available and vise versa. Here is the segment of the code. When I go back and forth on the radio buttons, both become not selectable, and I am unsure why.

 private void PriceTab()
 {
  pricePanel = new JPanel(new FlowLayout());


  final JRadioButton poolPrice= new JRadioButton("Pool");
  final JRadioButton tubPrice = new JRadioButton("Hot Tub");

  poolPrice.setSelected(true);

  ButtonGroup group = new ButtonGroup();
  group.add(poolPrice);
  group.add(tubPrice);

  pricePanel.add(poolPrice);
  pricePanel.add(tubPrice);


  final JLabel poolLabel = new JLabel("Enter the pool's volume:              ");
  final JTextField poolField = new JTextField(10);
  pricePanel.add(poolLabel);
  pricePanel.add(poolField);

  final JTextField tubField = new JTextField(10);
  final JLabel tubLabel = new JLabel ("Enter the tub's volume:     ");
  pricePanel.add(tubLabel);
  pricePanel.add(tubField);


  JButton calculatePrice = new JButton("Calculate Price");
  calculatePrice.setMnemonic('C');
  pricePanel.add(calculatePrice);
  pricePanel.add(createExitButton());

  pricePanel.add(new JLabel("The price is: "));
  final JTextField priceField = new JTextField(10);
  priceField.setEditable(false);
  pricePanel.add(priceField);

  final JTextArea messageArea = createMessageArea(1, 25,
  "*Please only select one section");
  pricePanel.add(messageArea);


  calculatePrice.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent e) {

     double pool = Double.parseDouble (poolField.getText());
     double tub = Double.parseDouble(tubField.getText());

     double price;
     if (poolPrice.isSelected()) {
      price = pool * 100;
     } else {
      price = tub * 75;
     }
     priceField.setText(df.format(price));
    }
  });



  ActionListener priceListener = new ActionListener() {
   public void actionPerformed(ActionEvent e) {
    if (e.getSource() == poolPrice) {
     tubLabel.setEnabled(false);
     tubField.setEnabled(false);
     messageArea.setVisible(false);
    } else if (e.getSource() == tubPrice) {
     poolLabel.setEnabled(false);
     poolField.setEnabled(false);
     messageArea.setVisible(false);
    }
    }
   };

  poolPrice.addActionListener(priceListener);
  tubPrice.addActionListener(priceListener);
 }
  • 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-16T07:57:35+00:00Added an answer on May 16, 2026 at 7:57 am
    ActionListener priceListener = new ActionListener() { 
            public void actionPerformed(ActionEvent e) { 
                if (e.getSource() == poolPrice) { 
                    tubLabel.setEnabled(false); 
                    tubField.setEnabled(false); 
                    // Re-enable the previously disabled labels
                    poolLabel.setEnabled(true);
                    poolField.setEnabled(true);
                    messageArea.setVisible(false); 
                } else if (e.getSource() == tubPrice) { 
                    poolLabel.setEnabled(false); 
                    poolField.setEnabled(false); 
                    // Re-enable disabled labels
                    tubLabel.setEnabled(true);
                    tubField.setEnabled(true);
    
                    messageArea.setVisible(false); 
                } 
                } 
            }; 
    

    You need to re-enable the buttons you disabled.

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

Sidebar

Related Questions

I am having some issues with a code that is occasionally and sporadically throwing
I'm having some issues with my code. This is probably due to some design
I'm having some issues with some jQuery code, and I'm hoping and thinking that
I'm having some issues getting file uploads to work correctly and the following code
I am having some issues passing commands through to flash from javascript. My code
I am having some issues with logging. After reviewing JBoss Seam source code, I
I'm trying to convert some VB.net code into C# and having issues trying to
I'm working with some OpenGL code for scientific visualization and I'm having issues getting
I'm having some issues using the following code on user input: htmlentities($string, ENT_COMPAT, 'UTF-8');
I have the following data, and am having some issues with the y axis

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.