Solved

Area of circle.

Posted on 2001-06-27
13
392 Views
Last Modified: 2010-04-16
I someone to write an application that inputs from the user radius of circle and prints circle's diameter, circumference, area. Use the constant value 3.14159 for pi. Use the GUI technique. You may also use the predfefined constant Math.PI for the value of pi. Use the formulas (r is the radius): diametyer = 2r, circumference = 2(pi)r, area = pi(r squared).

Actually I know nothing of java but I'm very good in VB.

ASAP
0
Comment
Question by:AJAY CHADHA
13 Comments
 
LVL 8

Author Comment

by:AJAY CHADHA
ID: 6232000
I hope these are easy points for someone who know java syntax
0
 
LVL 1

Expert Comment

by:wgilster
ID: 6232158
You will have to have swing, but this will do it...
Have FUN :)


/**
 * Insert the type's description here.
 * Creation date: (6/27/2001 10:50:25 AM)
 * @author:
 */
class CircleTest extends javax.swing.JFrame {

class IvjEventHandler implements java.awt.event.MouseListener {
            public void mouseClicked(java.awt.event.MouseEvent e) {
                  if (e.getSource() == CircleTest.this.getButtonCompute())
                        connEtoC1(e);
            };
            public void mouseEntered(java.awt.event.MouseEvent e) {};
            public void mouseExited(java.awt.event.MouseEvent e) {};
            public void mousePressed(java.awt.event.MouseEvent e) {};
            public void mouseReleased(java.awt.event.MouseEvent e) {};
      };
      private javax.swing.JButton ivjButtonCompute = null;
      IvjEventHandler ivjEventHandler = new IvjEventHandler();
      private javax.swing.JPanel ivjJFrameContentPane = null;
      private javax.swing.JLabel ivjLabelArea = null;
      private javax.swing.JLabel ivjLabelCircumference = null;
      private javax.swing.JLabel ivjLabelDiameter = null;
      private javax.swing.JLabel ivjLabelRadius = null;
      private javax.swing.JTextField ivjTextArea = null;
      private javax.swing.JTextField ivjTextCircumference = null;
      private javax.swing.JTextField ivjTextDiameter = null;
      private javax.swing.JTextField ivjTextRadius = null;
/**
 * CircleTest constructor comment.
 */
public CircleTest() {
      super();
      initialize();
}
/**
 * CircleTest constructor comment.
 * @param title java.lang.String
 */
public CircleTest(String title) {
      super(title);
}
/**
 * Comment
 */
public void buttonCompute_MouseClicked(java.awt.event.MouseEvent mouseEvent) {
      double radius = Double.parseDouble(getTextRadius().getText());
      getTextArea().setText(2 * radius + "");
      getTextCircumference().setText(2 * Math.PI * radius + "");
      getTextDiameter().setText(Math.PI * radius * radius + "");
      return;
}
/**
 * connEtoC1:  (ButtonCompute.mouse.mouseClicked(java.awt.event.MouseEvent) --> CircleTest.buttonCompute_MouseClicked(Ljava.awt.event.MouseEvent;)V)
 * @param arg1 java.awt.event.MouseEvent
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC1(java.awt.event.MouseEvent arg1) {
      try {
            // user code begin {1}
            // user code end
            this.buttonCompute_MouseClicked(arg1);
            // user code begin {2}
            // user code end
      } catch (java.lang.Throwable ivjExc) {
            // user code begin {3}
            // user code end
            handleException(ivjExc);
      }
}
/**
 * Return the ButtonCompute property value.
 * @return javax.swing.JButton
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JButton getButtonCompute() {
      if (ivjButtonCompute == null) {
            try {
                  ivjButtonCompute = new javax.swing.JButton();
                  ivjButtonCompute.setName("ButtonCompute");
                  ivjButtonCompute.setText("Compute");
                  // user code begin {1}
                  // user code end
            } catch (java.lang.Throwable ivjExc) {
                  // user code begin {2}
                  // user code end
                  handleException(ivjExc);
            }
      }
      return ivjButtonCompute;
}
/**
 * Return the JFrameContentPane property value.
 * @return javax.swing.JPanel
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JPanel getJFrameContentPane() {
      if (ivjJFrameContentPane == null) {
            try {
                  ivjJFrameContentPane = new javax.swing.JPanel();
                  ivjJFrameContentPane.setName("JFrameContentPane");
                  ivjJFrameContentPane.setLayout(new java.awt.GridBagLayout());

                  java.awt.GridBagConstraints constraintsLabelRadius = new java.awt.GridBagConstraints();
                  constraintsLabelRadius.gridx = 0; constraintsLabelRadius.gridy = 0;
                  constraintsLabelRadius.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getLabelRadius(), constraintsLabelRadius);

                  java.awt.GridBagConstraints constraintsTextRadius = new java.awt.GridBagConstraints();
                  constraintsTextRadius.gridx = 1; constraintsTextRadius.gridy = 0;
                  constraintsTextRadius.fill = java.awt.GridBagConstraints.HORIZONTAL;
                  constraintsTextRadius.weightx = 1.0;
                  constraintsTextRadius.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getTextRadius(), constraintsTextRadius);

                  java.awt.GridBagConstraints constraintsLabelDiameter = new java.awt.GridBagConstraints();
                  constraintsLabelDiameter.gridx = 0; constraintsLabelDiameter.gridy = 1;
                  constraintsLabelDiameter.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getLabelDiameter(), constraintsLabelDiameter);

                  java.awt.GridBagConstraints constraintsTextDiameter = new java.awt.GridBagConstraints();
                  constraintsTextDiameter.gridx = 1; constraintsTextDiameter.gridy = 1;
                  constraintsTextDiameter.fill = java.awt.GridBagConstraints.HORIZONTAL;
                  constraintsTextDiameter.weightx = 1.0;
                  constraintsTextDiameter.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getTextDiameter(), constraintsTextDiameter);

                  java.awt.GridBagConstraints constraintsLabelCircumference = new java.awt.GridBagConstraints();
                  constraintsLabelCircumference.gridx = 0; constraintsLabelCircumference.gridy = 2;
                  constraintsLabelCircumference.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getLabelCircumference(), constraintsLabelCircumference);

                  java.awt.GridBagConstraints constraintsTextCircumference = new java.awt.GridBagConstraints();
                  constraintsTextCircumference.gridx = 1; constraintsTextCircumference.gridy = 2;
                  constraintsTextCircumference.fill = java.awt.GridBagConstraints.HORIZONTAL;
                  constraintsTextCircumference.weightx = 1.0;
                  constraintsTextCircumference.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getTextCircumference(), constraintsTextCircumference);

                  java.awt.GridBagConstraints constraintsLabelArea = new java.awt.GridBagConstraints();
                  constraintsLabelArea.gridx = 0; constraintsLabelArea.gridy = 3;
                  constraintsLabelArea.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getLabelArea(), constraintsLabelArea);

                  java.awt.GridBagConstraints constraintsTextArea = new java.awt.GridBagConstraints();
                  constraintsTextArea.gridx = 1; constraintsTextArea.gridy = 3;
                  constraintsTextArea.fill = java.awt.GridBagConstraints.HORIZONTAL;
                  constraintsTextArea.weightx = 1.0;
                  constraintsTextArea.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getTextArea(), constraintsTextArea);

                  java.awt.GridBagConstraints constraintsButtonCompute = new java.awt.GridBagConstraints();
                  constraintsButtonCompute.gridx = 1; constraintsButtonCompute.gridy = 4;
                  constraintsButtonCompute.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getButtonCompute(), constraintsButtonCompute);
                  // user code begin {1}
                  // user code end
            } catch (java.lang.Throwable ivjExc) {
                  // user code begin {2}
                  // user code end
                  handleException(ivjExc);
            }
      }
      return ivjJFrameContentPane;
}
/**
 * Return the LabelArea property value.
 * @return javax.swing.JLabel
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JLabel getLabelArea() {
      if (ivjLabelArea == null) {
            try {
                  ivjLabelArea = new javax.swing.JLabel();
                  ivjLabelArea.setName("LabelArea");
                  ivjLabelArea.setText("Area");
                  // user code begin {1}
                  // user code end
            } catch (java.lang.Throwable ivjExc) {
                  // user code begin {2}
                  // user code end
                  handleException(ivjExc);
            }
      }
      return ivjLabelArea;
}
/**
 * Return the LabelCircumference property value.
 * @return javax.swing.JLabel
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JLabel getLabelCircumference() {
      if (ivjLabelCircumference == null) {
            try {
                  ivjLabelCircumference = new javax.swing.JLabel();
                  ivjLabelCircumference.setName("LabelCircumference");
                  ivjLabelCircumference.setText("Circumference ");
                  // user code begin {1}
                  // user code end
            } catch (java.lang.Throwable ivjExc) {
                  // user code begin {2}
                  // user code end
                  handleException(ivjExc);
            }
      }
      return ivjLabelCircumference;
}
/**
 * Return the LabelDiameter property value.
 * @return javax.swing.JLabel
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JLabel getLabelDiameter() {
      if (ivjLabelDiameter == null) {
            try {
                  ivjLabelDiameter = new javax.swing.JLabel();
                  ivjLabelDiameter.setName("LabelDiameter");
                  ivjLabelDiameter.setText("Diameter");
                  // user code begin {1}
                  // user code end
            } catch (java.lang.Throwable ivjExc) {
                  // user code begin {2}
                  // user code end
                  handleException(ivjExc);
            }
      }
      return ivjLabelDiameter;
}
/**
 * Return the LabelRadius property value.
 * @return javax.swing.JLabel
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JLabel getLabelRadius() {
      if (ivjLabelRadius == null) {
            try {
                  ivjLabelRadius = new javax.swing.JLabel();
                  ivjLabelRadius.setName("LabelRadius");
                  ivjLabelRadius.setText("Radius");
                  // user code begin {1}
                  // user code end
            } catch (java.lang.Throwable ivjExc) {
                  // user code begin {2}
                  // user code end
                  handleException(ivjExc);
            }
      }
      return ivjLabelRadius;
}
/**
 * Return the TextArea property value.
 * @return javax.swing.JTextField
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JTextField getTextArea() {
      if (ivjTextArea == null) {
            try {
                  ivjTextArea = new javax.swing.JTextField();
                  ivjTextArea.setName("TextArea");
                  // user code begin {1}
                  // user code end
            } catch (java.lang.Throwable ivjExc) {
                  // user code begin {2}
                  // user code end
                  handleException(ivjExc);
            }
      }
      return ivjTextArea;
}
/**
 * Return the TextCircumference property value.
 * @return javax.swing.JTextField
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JTextField getTextCircumference() {
      if (ivjTextCircumference == null) {
            try {
                  ivjTextCircumference = new javax.swing.JTextField();
                  ivjTextCircumference.setName("TextCircumference");
                  // user code begin {1}
                  // user code end
            } catch (java.lang.Throwable ivjExc) {
                  // user code begin {2}
                  // user code end
                  handleException(ivjExc);
            }
      }
      return ivjTextCircumference;
}
/**
 * Return the TextDiameter property value.
 * @return javax.swing.JTextField
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JTextField getTextDiameter() {
      if (ivjTextDiameter == null) {
            try {
                  ivjTextDiameter = new javax.swing.JTextField();
                  ivjTextDiameter.setName("TextDiameter");
                  // user code begin {1}
                  // user code end
            } catch (java.lang.Throwable ivjExc) {
                  // user code begin {2}
                  // user code end
                  handleException(ivjExc);
            }
      }
      return ivjTextDiameter;
}
/**
 * Return the TextRadius property value.
 * @return javax.swing.JTextField
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JTextField getTextRadius() {
      if (ivjTextRadius == null) {
            try {
                  ivjTextRadius = new javax.swing.JTextField();
                  ivjTextRadius.setName("TextRadius");
                  // user code begin {1}
                  // user code end
            } catch (java.lang.Throwable ivjExc) {
                  // user code begin {2}
                  // user code end
                  handleException(ivjExc);
            }
      }
      return ivjTextRadius;
}
/**
 * Called whenever the part throws an exception.
 * @param exception java.lang.Throwable
 */
private void handleException(java.lang.Throwable exception) {

      /* Uncomment the following lines to print uncaught exceptions to stdout */
      // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
      // exception.printStackTrace(System.out);
}
/**
 * Initializes connections
 * @exception java.lang.Exception The exception description.
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initConnections() throws java.lang.Exception {
      // user code begin {1}
      // user code end
      getButtonCompute().addMouseListener(ivjEventHandler);
}
/**
 * Initialize the class.
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initialize() {
      try {
            // user code begin {1}
            // user code end
            setName("CircleTest");
            setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
            setSize(426, 240);
            setContentPane(getJFrameContentPane());
            initConnections();
      } catch (java.lang.Throwable ivjExc) {
            handleException(ivjExc);
      }
      // user code begin {2}
      // user code end
}
/**
 * main entrypoint - starts the part when it is run as an application
 * @param args java.lang.String[]
 */
public static void main(java.lang.String[] args) {
      try {
            CircleTest aCircleTest;
            aCircleTest = new CircleTest();
            aCircleTest.addWindowListener(new java.awt.event.WindowAdapter() {
                  public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                  };
            });
            aCircleTest.show();
            java.awt.Insets insets = aCircleTest.getInsets();
            aCircleTest.setSize(aCircleTest.getWidth() + insets.left + insets.right, aCircleTest.getHeight() + insets.top + insets.bottom);
            aCircleTest.setVisible(true);
      } catch (Throwable exception) {
            System.err.println("Exception occurred in main() of javax.swing.JFrame");
            exception.printStackTrace(System.out);
      }
}
}
0
 
LVL 3

Expert Comment

by:ibro
ID: 6232159
import java.lang.math;
...
...

double diameter=2*r;
double circumference=2*java.lang.math.PI*r;
double area=java.lang.math.PI*r*r;
..
...
0
 
LVL 8

Author Comment

by:AJAY CHADHA
ID: 6232562
Hello Wgilsater,

Thanx for your fast reply. but is there any way you could do this in an easier  way? Ofcourse they should be with swings.

Is that a GUI version.

I've added more points to this question for a GUI version

There must be a textbox where the user must type the radiud and there will be three command buttons, AREA, Circumfrene and DAIAMETER.

Clcikng the appropriate button must bring the value in the textbox.

I've increased the points to 75. SO, please be fast in coding and send it to me via email at chadhaajay@hotmail.com

ASAP

Good Luck...

Ajay Chadha .. :-)
0
 
LVL 8

Author Comment

by:AJAY CHADHA
ID: 6232564
Hello Wgilsater,

Thanx for your fast reply. but is there any way you could do this in an easier  way? Ofcourse they should
be with swings.

Is that a GUI version.

I've added more points to this question for a GUI version

There must be a textbox where the user must type the radiud and there will be three command buttons,
AREA, Circumfrene and DAIAMETER.

Clcikng the appropriate button must bring the value in the textbox.

I've increased the points to 75. SO, please be fast in coding and send it to me via email at chadhaajay@hotmail.com

ASAP

Good Luck...

Ajay Chadha .. :-)
0
 
LVL 8

Author Comment

by:AJAY CHADHA
ID: 6232568
Hello Wgilsater,

Thanx for your fast reply. but is there any way you could do this in an easier  way? Ofcourse they should
be with swings.

Is that a GUI version.

I've added more points to this question for a GUI version

There must be a textbox where the user must type the radiud and there will be three command buttons,
AREA, Circumfrene and DAIAMETER.

Clcikng the appropriate button must bring the value in the textbox.

I've increased the points to 75. SO, please be fast in coding and send it to me via email at chadhaajay@hotmail.com

ASAP

Good Luck...

Ajay Chadha .. :-)
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 1

Expert Comment

by:wgilster
ID: 6232691
The method to compute the values should actually look like this, sorry about the mistake.  Plus this will create one button to compute all three values, each in their coresponding text boxes.

public void buttonCompute_MouseClicked(java.awt.event.MouseEvent mouseEvent) {
     double radius = Double.parseDouble(getTextRadius().getText());
     getTextArea().setText(Math.PI * radius * radius + "");
     getTextCircumference().setText(2 * Math.PI * radius + "");
     getTextDiameter().setText(2 * radius + "");
     return;
}

I'm not sure how you want the code simplified, I could remove the error handling and implement the MouseListeners directly instead of creating an inner class, but I'm not sure that will make the code any more readable for you.

0
 
LVL 8

Author Comment

by:AJAY CHADHA
ID: 6232940
Ok, Do what you want to do so that it should be as simple as it can and send to me as fast as you can
0
 
LVL 1

Accepted Solution

by:
wgilster earned 75 total points
ID: 6233000
Hope this is easier...

class CircleTest extends javax.swing.JFrame implements java.awt.event.MouseListener {
      private javax.swing.JButton ivjButtonCompute = null;
      private javax.swing.JPanel ivjJFrameContentPane = null;
      private javax.swing.JLabel ivjLabelArea = null;
      private javax.swing.JLabel ivjLabelCircumference = null;
      private javax.swing.JLabel ivjLabelDiameter = null;
      private javax.swing.JLabel ivjLabelRadius = null;
      private javax.swing.JTextField ivjTextArea = null;
      private javax.swing.JTextField ivjTextCircumference = null;
      private javax.swing.JTextField ivjTextDiameter = null;
      private javax.swing.JTextField ivjTextRadius = null;
public CircleTest() {
      super();
      initialize();
}
public CircleTest(String title) {
      super(title);
}
private javax.swing.JButton getButtonCompute() {
      if (ivjButtonCompute == null) {
                   ivjButtonCompute = new javax.swing.JButton();
                  ivjButtonCompute.setName("ButtonCompute");
                  ivjButtonCompute.setText("Compute");
       }
      return ivjButtonCompute;
}
private javax.swing.JPanel getJFrameContentPane() {
      if (ivjJFrameContentPane == null) {
                   ivjJFrameContentPane = new javax.swing.JPanel();
                  ivjJFrameContentPane.setName("JFrameContentPane");
                  ivjJFrameContentPane.setLayout(new java.awt.GridBagLayout());

                  java.awt.GridBagConstraints constraintsLabelRadius = new java.awt.GridBagConstraints();
                  constraintsLabelRadius.gridx = 0; constraintsLabelRadius.gridy = 0;
                  constraintsLabelRadius.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getLabelRadius(), constraintsLabelRadius);

                  java.awt.GridBagConstraints constraintsTextRadius = new java.awt.GridBagConstraints();
                  constraintsTextRadius.gridx = 1; constraintsTextRadius.gridy = 0;
                  constraintsTextRadius.fill = java.awt.GridBagConstraints.HORIZONTAL;
                  constraintsTextRadius.weightx = 1.0;
                  constraintsTextRadius.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getTextRadius(), constraintsTextRadius);

                  java.awt.GridBagConstraints constraintsLabelDiameter = new java.awt.GridBagConstraints();
                  constraintsLabelDiameter.gridx = 0; constraintsLabelDiameter.gridy = 1;
                  constraintsLabelDiameter.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getLabelDiameter(), constraintsLabelDiameter);

                  java.awt.GridBagConstraints constraintsTextDiameter = new java.awt.GridBagConstraints();
                  constraintsTextDiameter.gridx = 1; constraintsTextDiameter.gridy = 1;
                  constraintsTextDiameter.fill = java.awt.GridBagConstraints.HORIZONTAL;
                  constraintsTextDiameter.weightx = 1.0;
                  constraintsTextDiameter.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getTextDiameter(), constraintsTextDiameter);

                  java.awt.GridBagConstraints constraintsLabelCircumference = new java.awt.GridBagConstraints();
                  constraintsLabelCircumference.gridx = 0; constraintsLabelCircumference.gridy = 2;
                  constraintsLabelCircumference.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getLabelCircumference(), constraintsLabelCircumference);

                  java.awt.GridBagConstraints constraintsTextCircumference = new java.awt.GridBagConstraints();
                  constraintsTextCircumference.gridx = 1; constraintsTextCircumference.gridy = 2;
                  constraintsTextCircumference.fill = java.awt.GridBagConstraints.HORIZONTAL;
                  constraintsTextCircumference.weightx = 1.0;
                  constraintsTextCircumference.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getTextCircumference(), constraintsTextCircumference);

                  java.awt.GridBagConstraints constraintsLabelArea = new java.awt.GridBagConstraints();
                  constraintsLabelArea.gridx = 0; constraintsLabelArea.gridy = 3;
                  constraintsLabelArea.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getLabelArea(), constraintsLabelArea);

                  java.awt.GridBagConstraints constraintsTextArea = new java.awt.GridBagConstraints();
                  constraintsTextArea.gridx = 1; constraintsTextArea.gridy = 3;
                  constraintsTextArea.fill = java.awt.GridBagConstraints.HORIZONTAL;
                  constraintsTextArea.weightx = 1.0;
                  constraintsTextArea.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getTextArea(), constraintsTextArea);

                  java.awt.GridBagConstraints constraintsButtonCompute = new java.awt.GridBagConstraints();
                  constraintsButtonCompute.gridx = 1; constraintsButtonCompute.gridy = 4;
                  constraintsButtonCompute.insets = new java.awt.Insets(4, 4, 4, 4);
                  getJFrameContentPane().add(getButtonCompute(), constraintsButtonCompute);
       }
      return ivjJFrameContentPane;
}
 private javax.swing.JLabel getLabelArea() {
      if (ivjLabelArea == null) {
                   ivjLabelArea = new javax.swing.JLabel();
                  ivjLabelArea.setName("LabelArea");
                  ivjLabelArea.setText("Area");
        }
      return ivjLabelArea;
}
 private javax.swing.JLabel getLabelCircumference() {
      if (ivjLabelCircumference == null) {
                   ivjLabelCircumference = new javax.swing.JLabel();
                  ivjLabelCircumference.setName("LabelCircumference");
                  ivjLabelCircumference.setText("Circumference ");
       }
      return ivjLabelCircumference;
}
 private javax.swing.JLabel getLabelDiameter() {
      if (ivjLabelDiameter == null) {
                   ivjLabelDiameter = new javax.swing.JLabel();
                  ivjLabelDiameter.setName("LabelDiameter");
                  ivjLabelDiameter.setText("Diameter");
       }
      return ivjLabelDiameter;
}
private javax.swing.JLabel getLabelRadius() {
      if (ivjLabelRadius == null) {
                   ivjLabelRadius = new javax.swing.JLabel();
                  ivjLabelRadius.setName("LabelRadius");
                  ivjLabelRadius.setText("Radius");
       }
      return ivjLabelRadius;
}
private javax.swing.JTextField getTextArea() {
      if (ivjTextArea == null) {
                   ivjTextArea = new javax.swing.JTextField();
                  ivjTextArea.setName("TextArea");
       }
      return ivjTextArea;
}
private javax.swing.JTextField getTextCircumference() {
      if (ivjTextCircumference == null) {
                   ivjTextCircumference = new javax.swing.JTextField();
                  ivjTextCircumference.setName("TextCircumference");
       }
      return ivjTextCircumference;
}
private javax.swing.JTextField getTextDiameter() {
      if (ivjTextDiameter == null) {
                   ivjTextDiameter = new javax.swing.JTextField();
                  ivjTextDiameter.setName("TextDiameter");
       }
      return ivjTextDiameter;
}
private javax.swing.JTextField getTextRadius() {
      if (ivjTextRadius == null) {
                   ivjTextRadius = new javax.swing.JTextField();
                  ivjTextRadius.setName("TextRadius");
       }
      return ivjTextRadius;
}
private void initConnections() {
      getButtonCompute().addMouseListener(this);
}
private void initialize() {
             setName("CircleTest");
            setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
            setSize(426, 240);
            setContentPane(getJFrameContentPane());
            initConnections();
 }  
public static void main(java.lang.String[] args) {
      try {
            CircleTest aCircleTest;
            aCircleTest = new CircleTest();
            aCircleTest.addWindowListener(new java.awt.event.WindowAdapter() {
                  public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                  };
            });
            aCircleTest.show();
            java.awt.Insets insets = aCircleTest.getInsets();
            aCircleTest.setSize(aCircleTest.getWidth() + insets.left + insets.right, aCircleTest.getHeight() + insets.top + insets.bottom);
            aCircleTest.setVisible(true);
      } catch (Throwable exception) {
            System.err.println("Exception occurred in main() of javax.swing.JFrame");
            exception.printStackTrace(System.out);
      }
}
                  public void mouseClicked(java.awt.event.MouseEvent e) {
                  if (e.getSource() == CircleTest.this.getButtonCompute()) {
                        double radius = Double.parseDouble(getTextRadius().getText());
                        getTextArea().setText(Math.PI * radius * radius + "");
                        getTextCircumference().setText(2 * Math.PI * radius + "");
                        getTextDiameter().setText(2 * radius + "");
                        return;
                  }
            }
            public void mouseEntered(java.awt.event.MouseEvent e) {}
            public void mouseExited(java.awt.event.MouseEvent e) {}
            public void mousePressed(java.awt.event.MouseEvent e) {}
            public void mouseReleased(java.awt.event.MouseEvent e) {}
}
0
 
LVL 8

Author Comment

by:AJAY CHADHA
ID: 6233027
Thanks
0
 
LVL 4

Expert Comment

by:kylar
ID: 6233187
I'd swear this is a homework question :(

Kylar
0
 
LVL 1

Expert Comment

by:wgilster
ID: 6233230
Probably Kylar.  BTW You posted a reply to my question a while back on drawing a box around rotated text.  Do you have any ideas on that question?

http://devx.experts-exchange.com/jsp/qManageQuestion.jsp?ta=java&qid=20134735
0
 
LVL 15

Expert Comment

by:ameba
ID: 6868396
>I'd swear this is a homework question

No, it's question from here:
http://www.rentacoder.com/RentACoder/misc/BidRequests/ShowBidRequest.asp?lngBidRequestId=535
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now