Java awt program to find the cube of a number

In this program, You will learn how to find the cube of a number using awt in java.

``````8 = 2 * 2 * 2

27 = 3 * 3 * 3``````

Example: How to find the cube of a number using awt in java.

``````import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Button;
import java.awt.Frame;
import java.awt.Label;
import java.awt.TextField;
import java.awt.event.WindowEvent;

class Test implements ActionListener {

Button b1;
TextField t1;
Label lb1, lb3;
Frame f;

Test() {
f = new Frame("Awt find cube");

lb1 = new Label("Enter a Number :");
lb1.setBounds(5, 50, 150, 30);

t1 = new TextField();
t1.setBounds(200, 50, 150, 30);

lb3 = new Label("Result :");
lb3.setBounds(90, 140, 150, 30);

b1 = new Button("Find ");
b1.setBounds(90, 200, 100, 30);

@Override
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});

f.setLayout(null);
f.setSize(600, 500);
f.setVisible(true);

}

@Override
public void actionPerformed(ActionEvent e) {

int n = Integer.parseInt(t1.getText());
int cube = 0;
if (e.getSource().equals(b1)) {

cube = n * n * n;

lb3.setText(String.valueOf("Cube is  :    " + cube));
}

}

public static void main(String args[]) {
Test t = new Test();
}
}
``````