Results 1 to 3 of 3
  1. #1
    zhider is offline Member
    Join Date
    Oct 2012
    Posts
    37
    Rep Power
    0

    Default Swing calculate area not printing anything

    I am trying to get my swing program to calculate the area of one of the types of area (radio buttons) but when I run it, it seems to take the parameters correctly, but it doesnt print the area, which in the code below I used the code:cOutputLabel1.setText(strArea + " square inches"); . any ideas on why this wont work? I can post more code if needed.





    private void CalculateRadioButtonActionPerformed(java.awt.event .ActionEvent evt) {
    double area = 0;
    if (CircleRadioButton.isSelected()) {
    String strRadius = DimensionOneText.getText();
    int radius = Integer.parseInt(strRadius);
    area = areaCircle (radius);
    }else{
    if (rectangleRadioButton.isSelected()){
    String strBase = DimensionOneText.getText();
    int base = Integer.parseInt(strBase);
    String strHeight = DimensionTwoText.getText();
    int height = Integer.parseInt(strHeight);
    area = areaTriangle (base, height);
    }else{
    if (triangleRadioButton.isSelected()){
    String strBase = DimensionOneText.getText();
    int base = Integer.parseInt(strBase);
    String strHeight = DimensionTwoText.getText();
    int height = Integer.parseInt(strHeight);
    area = areaRectangle (base, height);
    }
    String strArea = String.valueOf(area);
    OutputLabel1.setText(strArea + " square inches");
    }

    }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Swing calculate area not printing anything

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default Re: Swing calculate area not printing anything

    Is this method ever called? Have it System.out.println() something to find out.

    And, please, format your code so that it's readable.

Similar Threads

  1. Printing a GUI form that used swing
    By Taron in forum AWT / Swing
    Replies: 3
    Last Post: 10-23-2012, 03:38 PM
  2. Replies: 0
    Last Post: 02-23-2012, 01:20 PM
  3. Swing Button and Text Area Function
    By ScoutDavid in forum AWT / Swing
    Replies: 13
    Last Post: 12-21-2010, 03:07 PM
  4. Printing in Swing
    By dhaivat in forum AWT / Swing
    Replies: 8
    Last Post: 03-04-2010, 04:55 PM
  5. Printing default Swing values
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-12-2008, 12:09 PM

Posting Permissions

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