Hi all,

I am having trouble with class communication to reset some textfields through event handling. Any help would be appreciated. Here is a portion of my code.

The class that contains the textfields that I wish to use a reset button for:

import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;

public class FinancingInformation {
	JTextField basePriceText;
	JTextField downPaymentText;
	JTextField salesTaxText;
	private JLabel basePriceLabel, downPaymentLabel, salesTaxLabel;
	private TitledBorder financingInformationBorder;
	private JPanel financingInformationPanel;
	public FinancingInformation(){
		financingInformationPanel = new JPanel();
		basePriceLabel = new JLabel("Base Price: $");
		downPaymentLabel = new JLabel("Down Payment: $");
		salesTaxLabel = new JLabel("Sales Tax: $");
		basePriceText = new JTextField("0.0");
		downPaymentText = new JTextField("0.0");
		salesTaxText = new JTextField("7.0");
		financingInformationPanel.setLayout(new GridLayout(3,2));
		financingInformationPanel.add(basePriceLabel); financingInformationPanel.add(basePriceText);
		financingInformationPanel.add(downPaymentLabel); financingInformationPanel.add(downPaymentText);
		financingInformationPanel.add(salesTaxLabel); financingInformationPanel.add(salesTaxText);
		financingInformationBorder = new TitledBorder("Financing Information");
	public JPanel getFI()
		return financingInformationPanel;
	public JTextField getBasePriceText() {
		return basePriceText;

	public void setBasePriceText(JTextField basePriceText) {
		this.basePriceText = basePriceText;

	public JTextField getDownPaymentText() {
		return downPaymentText;

	public void setDownPaymentText(JTextField downPaymentText) {
		this.downPaymentText = downPaymentText;

	public JTextField getSalesTaxText() {
		return salesTaxText;

	public void setSalesTaxText(JTextField salesTaxText) {
		this.salesTaxText = salesTaxText;

The button class:

import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.awt.event.*;

public class ActionButtons {
	private JButton calc, reset, exit;
	private JPanel buttonPanel;
	private TitledBorder buttonBorder;
	private FinancingInformation fi;
	public ActionButtons(){
		buttonPanel = new JPanel();
		fi = new FinancingInformation();
		calc = new JButton("Calculate");
		reset = new JButton("Reset");
		exit = new JButton("Exit");
		calc.addActionListener(new CalcListener());
		reset.addActionListener(new ResetListener());
		exit.addActionListener(new ExitListener());
		buttonPanel.setLayout(new GridLayout(1,3));
		buttonPanel.add(calc); buttonPanel.add(reset); buttonPanel.add(exit);
		buttonBorder = new TitledBorder("Action Buttons");
	private class CalcListener implements ActionListener
		public void actionPerformed(ActionEvent cb)
	private class ResetListener implements ActionListener
		public void actionPerformed(ActionEvent rb)
	private class ExitListener implements ActionListener
		public void actionPerformed(ActionEvent eb)
	public JPanel getAB()
		return buttonPanel;

As of now when I run the program, when I click the reset button, nothing happens. There are not even any error messages. Thanks in advance for any help!

5 Years
Discussion Span
Last Post by mKorbel
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.