Hi,
I have created the buttons along in the GUI, but I need help adding the ActionListener interface to make the buttons respond. Any assistance would be greatly appreciated...
import javax.swing.*; import javax.swing.JFrame;//page 298 Core Java import javax.swing.JTextField;//page 379 Core Java import javax.swing.JButton;//page 331 Core Java import java.awt.Container;//page 331 Core Java import java.awt.FlowLayout;//page 371 Core Java class theButtons { public static void main(String args[]) { //declare/initialize variables JFrame frame; Container contentPane; JTextField textfield; JButton button; FlowLayout layout; String thePrincipal; String interestRate; String theTerm; String pleaseCalculate; String toRefresh; JFrame theFrame = new JFrame("McBride Financial Services"); final int FRAME_WIDTH = 550; final int FRAME_HEIGHT = 300; theFrame.setSize(FRAME_WIDTH, FRAME_HEIGHT); textfield = new JTextField("Type your text here."); contentPane = theFrame.getContentPane(); thePrincipal = "Principal Amount"; button = new JButton(thePrincipal); contentPane.add(textfield); contentPane.add(button); layout = new FlowLayout(); contentPane.setLayout(layout); interestRate = "Interest Rate"; button = new JButton(interestRate); contentPane.add(textfield); contentPane.add(button); layout = new FlowLayout(); contentPane.setLayout(layout); theTerm = "Loan Term"; button = new JButton(theTerm); contentPane.add(textfield); contentPane.add(button); layout = new FlowLayout(); contentPane.setLayout(layout); pleaseCalculate = "Calculate"; button = new JButton(pleaseCalculate); contentPane.add(textfield); contentPane.add(button); layout = new FlowLayout(); contentPane.setLayout(layout); toRefresh = "Refresh"; button = new JButton(toRefresh); contentPane.add(textfield); contentPane.add(button); layout = new FlowLayout(); contentPane.setLayout(layout); theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); theFrame.pack(); theFrame.setVisible(true); } }