Results 1 to 18 of 18
  1. #1
    Sarge is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default Create a tab called LengthCalc that converts millimeters, meters, yards, feet, and in

    I just need some help in the right direction. Thanks

    The Length Calc tab offers the user a length converter (millimeters, meters, yards, feet, and inches).


    Shannon
    Last edited by Sarge; 04-21-2011 at 12:31 AM. Reason: insert picture

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Wow, with such a plethora of information I'm sure people will be showering you with help.
    [/sarcasm]

  3. #3
    Sarge is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default

    I wanted to add this pic to the origanial message, this is what the applet should look like

    thanks
    Attached Thumbnails Attached Thumbnails Create a tab called LengthCalc that converts millimeters, meters, yards, feet, and in-lengthcalc.jpg  

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Oooh goodie a picture!

    Now if only we had a specific question we could answer

  5. #5
    Sarge is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default

    bascially how do I code this? thanks

  6. #6
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Are you serious?

    I want to build a car. Do you think I could walk up to the Chairman of Ford, show him a drawing and ask "How do I do this?"

  7. #7
    Sarge is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default

    Sorry, so basically here is what I have so far.

    //create LengthCalc function
    public void createLengthCalc()
    {
    LengthCalc = new JPanel();
    LengthCalc.setLayout(null);

    JLabel millimetersLabel = new JLabel("Millimeters:");
    millimetersLabel.setBounds(0, 15, 260, 10);
    LengthCalc.add( millimetersLabel );

    JTextField lengthText3 = new JTextField();
    lengthText3.setBounds(10, 15, 150, 20);
    LengthCalc.add( lengthText );
    JLabel metersLabel = new JLabel("Meters:");
    metersLabel.setBounds(10, 40, 260, 20);
    LengthCalc.add( metersLabel );
    JTextField widthText2 = new JTextField();
    widthText2.setBounds(10, 40, 150, 20);
    LengthCalc.add( widthText );
    JLabel yardsLabel = new JLabel("Yards:");
    yardsLabel.setBounds(10, 65, 200, 20);
    LengthCalc.add( yardsLabel );
    JTextField depthText2 = new JTextField();
    depthText2.setBounds(10, 65, 150, 20);
    LengthCalc.add( depthText );
    JLabel feetLabel = new JLabel("Feet:");
    feetLabel.setBounds(10, 100, 260, 20);
    LengthCalc.add( feetLabel );
    JLabel inchesLabel = new JLabel("Inches:");
    inchesLabel.setBounds(10, 150, 260, 20);
    LengthCalc.add( inchesLabel );

    }

    the part where im struggling is with the conversion part. thanks

  8. #8
    Sarge is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default

    Any help with this would be great. Thanks

  9. #9
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Continuing my analogy

    The part I'm struggling with is the steering.

  10. #10
    ra4king's Avatar
    ra4king is offline Senior Member
    Join Date
    Apr 2011
    Location
    Atlanta, Georgia, US
    Posts
    396
    Rep Power
    4

    Default

    @Junky
    ROFL!

    @Sarge
    Do you know how to write code that works together? Do you know how to use listeners? More importantly, do you know how to do basic mathematical conversions?

    Please ask us a specific question, not just: "I don't know what to do, please post some code."

  11. #11
    Sarge is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default

    //create lengthCalc function
    public void createLengthCalc()
    {
    LengthCalc = new JPanel();
    LengthCalc.setLayout( null );

    JButton convertButton = new JButton("Convert");
    convertButton.addActionListener(new ConvertListener());
    this.setLayout(new FlowLayout());
    this.add(new JLabel("Millimeters"));
    this.add(millimetersField);
    this.add(new JLabel("Meters"));
    this.add(metersField);
    this.add(new JLabel("Yards"));
    this.add(yardsField);
    this.add(new JLabel("Feet"));
    this.add(feetField);
    this.add(new JLabel("Inches"));
    this.add(inchesField);

    }
    class ConvertListener implements ActionListener
    {
    public void actionPerformed(ActionEvent e)
    {
    try
    {
    double millVal = Double.parseDouble(millimetersField.getText());
    double meterVal = Double.parseDouble(metersField.getText());
    double yardVal = Double.parseDouble(yardsField.getText());
    double feetVal = Double.parseDouble(feetField.getText());
    double inchVal = Double.parseDouble(inchesField.getText());
    }
    }
    }

    this is where im at now

  12. #12
    ra4king's Avatar
    ra4king is offline Senior Member
    Join Date
    Apr 2011
    Location
    Atlanta, Georgia, US
    Posts
    396
    Rep Power
    4

    Default

    So now what do you think is left to do?

  13. #13
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Java Code:
    double millVal = Double.parseDouble(millimetersField.getText());
    double meterVal = Double.parseDouble(metersField.getText());
    double yardVal = Double.parseDouble(yardsField.getText());
    double feetVal = Double.parseDouble(feetField.getText());
    double inchVal = Double.parseDouble(inchesField.getText());
    See here is the part where I was hoping you could provide some additional information such as what exactly is the program supposed to do?

    Your code is getting values from ALL textfields but my assumption is that it should only get the value in one field (all the other should be blank). You then perform the calculations and display the results in the other fields. You have the assignment not us so only you know what the requirements are because you are reluctant to provide any details.

  14. #14
    Sarge is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default

    Thanks for you help if feet is entered then all other fields automatically generate the conversion.

    Here is your assignment: You work for a Landscape architect. They have asked you to be a part of their team as they need a computer programmer, analyst, and designer to aid them in calculating engineering specification. Specifically, you have been assigned to the Pools, Hot Tubs and Spas section of their landscaping team. Your skills will be needed in creating a GUI program that calculates engineering specifications.

  15. #15
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Quote Originally Posted by Sarge View Post
    You work for a Landscape architect. They have asked you to be a part of their team as they need a computer programmer, analyst, and designer to aid them in calculating engineering specification. Specifically, you have been assigned to the Pools, Hot Tubs and Spas section of their landscaping team. Your skills will be needed in creating a GUI program that calculates engineering specifications.
    Is that it? None of that mentions the LengthCalc function.

  16. #16
    Sarge is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default

    attached is the sample program with screen shots of what the assignment should look like.

    The tab i'm struggling with is the LengthCalc tab. which in my code is the createLengthCalc function. This function converts millimeters, meters, yards, feet and inches. Any field recieves an input number on the GUI and the rest of the field are automatically populated.

  17. #17
    Sarge is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default

    I can't get the doc to attach the file is to big even when compressed.

  18. #18
    ra4king's Avatar
    ra4king is offline Senior Member
    Join Date
    Apr 2011
    Location
    Atlanta, Georgia, US
    Posts
    396
    Rep Power
    4

    Default

    What remains right now is to do the calculations and set the textfields to the updated values: "textField.setText(String)".

Similar Threads

  1. How do I create a class called Dog in Java?
    By rahilz in forum New To Java
    Replies: 19
    Last Post: 12-19-2010, 10:08 PM
  2. conversion between feet and meters
    By Latanyar in forum New To Java
    Replies: 7
    Last Post: 10-10-2010, 08:20 PM
  3. program with converting feet to meters
    By Smitty300 in forum New To Java
    Replies: 5
    Last Post: 03-16-2010, 11:41 AM
  4. Getting my feet wet (looking for a mentor as well)
    By fresh83 in forum New To Java
    Replies: 9
    Last Post: 12-18-2009, 06:12 AM
  5. Converts from Fahrenheit to Celsius
    By trill in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 05:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •