I have the JButtons already made and placed and i made a command for it but when i click still nothing happens.
heres my command method
public void actionPreformed(ActionEvent evt) { String cmd = evt.getActionCommand(); if (cmd != null) { if (cmd.equalsIgnoreCase("algButton")) { getInput.userInput(); } } }
here's my entire GUI class
package Algebra; import javax.swing.*; import java.awt.*; import java.awt.event.*; import Algebra.getInput; public class GUI{ //Create Frame private JFrame f = new JFrame("Joshs' Algebra Calculator"); //Create Panels private JPanel funcPnl = new JPanel(); private JTextField txtNotes = new JTextField(); //Buttons private JButton algButton = new JButton("Equations"); private JButton areaButton = new JButton("Area"); //Create Menu private JMenuBar mb = new JMenuBar(); private JMenu muFile = new JMenu("File"); private JMenuItem muItemQuite = new JMenuItem("Quit"); private JMenu muHelp = new JMenu("Help"); private JMenuItem muItemAbout = new JMenuItem("About"); public GUI(){ //set menu f.setJMenuBar(mb); //build menu muFile.add(muItemQuite); muHelp.add(muItemAbout); mb.add(muFile); mb.add(muHelp); //Add Buttons funcPnl.add(algButton); funcPnl.add(areaButton); //Set Up Frame f.setIconImage(Toolkit.getDefaultToolkit() .getImage("icon_confused.gif")); f.setSize(400,400); f.getContentPane().setLayout(new BorderLayout()); f.getContentPane().add(funcPnl, BorderLayout.WEST); f.getContentPane().add(txtNotes, BorderLayout.SOUTH); // Allows the Swing App to be closed f.addWindowListener(new ListenCloseWdw()); //Add Menu listener muItemQuite.addActionListener(new ListenMenuQuit()); //Buttons algButton.setActionCommand("algButton"); } public void actionPreformed(ActionEvent evt) { String cmd = evt.getActionCommand(); if (cmd != null) { if (cmd.equalsIgnoreCase("algButton")) { getInput.userInput(); } } } public class ListenMenuQuit implements ActionListener{ public void actionPerformed(ActionEvent e){ System.exit(0); } } public class ListenCloseWdw extends WindowAdapter{ public void windowClosing(WindowEvent e){ System.exit(0); } } public void launchFrame(){ // Display Frame f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); } public static void main(String args[]){ GUI gui = new GUI(); gui.launchFrame(); //gui.Action(ActionEvent); //getInput.userInput(); } }
I know its not complete but i just don't know were to go from here.