Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello. I am working on a GUI that calculates millions of gallons per day to gallons per minute. I have my GUI class, a utility

Hello. I am working on a GUI that calculates millions of gallons per day to gallons per minute. I have my GUI class, a utility class for the calculation, and a main class to run the program. I am not sure how to put use the utility class in my GUI class. As it is right now, I keep getting an error that says:

Error:forms: C:\Users\Zackychaos\IdeaProjects\GUI's and event handlers\src\waterflow\MGDtogpm.form: Cannot bind: field does not exist: waterflow.MGDtogpm.MGDtoGPM

My code is below. Any help is appreciated:

package waterflow; import javax.swing.*; import java.awt.event.*; public class WaterCalGUI extends JFrame { private JTextField mgdinput; private JTextField gpmoutput; private JButton conversionbutton; private double gpm; private double mgd; public WaterCalGUI(){ conversionbutton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double mgd = Double.parseDouble(mgdinput.getText()); double gpm = mgd * 694.44; gpmoutput.setText(Double.toString(gpm)); } }); } } 

package waterflow; public class WaterCalculator { private double gpm; private double mgd; public static void convertMGDtoGPM(double gpm, double mgd) { gpm = mgd * 694.44; System.out.println(gpm); } } 

package waterflow; public class Main { public static void main(String[] args) { WaterCalGUI display = new WaterCalGUI(); } } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions