hi danpost
I am currently trying to build a quadratic calculator from scratch instead of the usual drag and drop, but for some reason when I ran it the gui interface down pop up like it should, dont know what i have done wrong or if the logic I use is correct. I am totally lost and i dont know what to do again. can u help me out here.
here is the codes that I use:
package tester;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Tester extends JFrame implements ActionListener {
JTextField factorA = new JTextField("Factor A");
JTextField factorB = new JTextField("Factor B");
JTextField factorC = new JTextField("Factor C");
JTextField solutions = new JTextField("solutions");
JButton compute= new JButton("compute");
JButton exits = new JButton("exits");
JButton clear = new JButton("Clear");
Tools tls = new Tools();
public Tester(){
this.setTitle("Quadratic Calculator");
this.setSize(300, 300);
this.setLayout(null);
this.getContentPane().add(factorA);
factorA.setBounds(85, 100, 100, 30);
this.getContentPane().add(factorB);
factorB.setBounds(190, 100,100, 20);
this.getContentPane().add(factorC);
factorC.setBounds(295, 100, 100, 20);
this.getContentPane().add(compute);
compute.setBounds(200, 100, 100, 25);
this.getContentPane().add(solutions);
solutions.setBounds(295, 100, 100, 25);
this.getContentPane().add(clear);
clear.setBounds(295, 100, 100,25);
exits.addActionListener(this);
compute.addActionListener(this);
clear.addActionListener(this);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equalsIgnoreCase("exits"))
System.exit(0);
if(e.getActionCommand().equalsIgnoreCase("clear"))
tls.clear(factorA, factorB, factorC);
if(e.getActionCommand().equalsIgnoreCase("compute"))
compute.setText(tls.addvalues(factorA, factorB, factorC));
and here is the output what i get
run:
BUILD SUCCESSFUL (total time: 0 seconds)

