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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:41:23+00:00 2026-05-28T01:41:23+00:00

Goo day I am doing a Swing application for a calculator as an exercise.

  • 0

Goo day

I am doing a Swing application for a calculator as an exercise. The problem I have is with the actual numbers display in the text field. The idea I had was to have a String value of say “1” for example and then every time the number one button is clicked to concatenate the value of “1” to the initial and then to parse the String value to Double so that one can work with the value.

private void butOneActionPerformed(java.awt.event.ActionEvent evt) {                                       
    String one;        
    Double doubleOne;
    if(operandOne.equals("0."))
    {
        one = "1";
        operandOne = ".";
        one += operandOne;
        txtDisplay.setText(one);
    }
    else
    {
        operandOne = "1";
        one = txtDisplay.getText();
        one += operandOne;
        txtDisplay.setText(one);

    }
    doubleOne = Double.parseDouble(one);
}                                     

Is there a perhaps another more effective way to do this. The fact that one needs to work with a floating point number makes it a bit trickey.

  • 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-28T01:41:23+00:00Added an answer on May 28, 2026 at 1:41 am

    There’s nothing wrong with the way you’ve done it, other than I would make the parsing of the double ‘lazy’; i.e. don’t convert the String to a double until a calculation is required, and get rid of the doubleOne field.

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

Sidebar

Related Questions

I have a problem, http://goo.gl/i82eA this is sample data that I have with the
So I have this regex: (^(\s+)?(?P<NAME>(\w)(\d{7}))((01f\.foo)|(\.bar|\.goo\.moo\.roo))$|(^(\s+)?(?P<NAME2>R1_\d{6}_\d{6}_)((01f\.foo)|(\.bar|\.goo\.moo\.roo))$)) Now if I try and do a match
Assume I have arrays like: $arr['foo']['bar']['test'] = 'value'; $arr['noo']['boo'] = 'value'; $arr['goo'] = 'value';
I have a tag like this <order>foo,bar,goo,doo,woo</order> that I need to validate with an
input: ['abc', 'cab', 'cafe', 'face', 'goo'] output: [['abc', 'cab'], ['cafe', 'face'], ['goo']] The problem
Suppose I have the following code snippets, i.e. goo call foo, DataTable created by
Let, <span onclick=foo() onfocus=goo()>Have Event</span> Here I give this just for example. Here with
i want to check how much element have class goo. are i can check
I have an input file like this: SomeSection.Foo OtherSection.Foo OtherSection.Goo ...and there is another
I have a site name www.goo.com and i used to save cookie without declaring

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.