hi
I am trying to build a triangle calculator that can tell you if you can form a valid triangle, I have reach the calculation part as yet just the part of the gui and that is the part with the error. something is wrong and i cant seem to figure it . probably a logical error somewhere.
I build the gui but it is blank. what it supposed to print is sideA with a txtfield and that goes for b and c. but for some reason it is blank.
can some take a look at my codes and tell me what and where I have gone wrong.
(new Triangle_Calculator()).setVisible(true); this piece of codes here, when I add it in, this is what bring up the gui but it is blank and when i remove it, it doesnt print out. nothing is being printed out. not even the gui comes up
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package quadratric;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Triangle_Calculator extends JFrame implements ActionListener {
JButton clear = new JButton("clear");
JButton exit = new JButton("exit");
public Triangle_Calculator(){
JFrame frame = new JFrame("Calculator");
frame.setBounds(300, 200, 220, 250);
frame.setTitle("Triangle Carlculator");
JPanel jp = new JPanel(new GridLayout(2, 2));
frame.getContentPane().add(clear);
clear.setBounds(300, 250, 200, 100);
frame.getContentPane().add(exit);
exit.setBounds(300, 250, 200, 100);
//row 1
JLabel area = new JLabel("area of Triangle");
area.setFont(area.getFont().deriveFont(16.0f));
area.setHorizontalAlignment(JLabel.CENTER);
JTextField sideAfield = new JTextField();
sideAfield.setColumns(5);
//row 2
JLabel sideB = new JLabel("sideB");
frame.add(sideB);
JTextField sideBfield = new JTextField();
sideBfield.setColumns(5);
//row 3
JLabel sideC = new JLabel("sideC");
frame.add(sideC);
JTextField sideCfield = new JTextField();
sideCfield.setColumns(5);
//row 5
JButton calbtn = new JButton("Calculate Area");
frame.add(calbtn);
JTextField ans = new JTextField("ans");
calbtn.addActionListener(this);
frame.pack();;
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main (String[]args){
(new Triangle_Calculator()).setVisible(true);
}
@Override
public void actionPerformed(ActionEvent ae) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}