我想连接方法,returnedConversion以便ActionListener在用户选择转换为和来自哪个临时比例之后将结果返回给.我知道代码有点脱节,至少可以说,所以请忽略所有注释掉的区域(除非你能指出我应该注意的区域).
如何将该方法returnedConversion中的代码连接到代码才能ActionListener正常运行?我是否正确地将JTextField盒子中的输入转换为双倍然后适当地将其转换回a String以将其传递回第二个JTextField盒子?
package temperatureConverter;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class TempConverter extends JFrame {
private JComboBox firstComboBox;
private JComboBox secondComboBox;
private JTextField initialTemp;
private JTextField convertedTemp;
private JButton convertButton;
// private enum TempType { FAHRENHEIT, CELSIUS, KELVIN};
private static final String[] tempType = { "Fahrenheit", "Celsius",
"Kelvin" };
public static final String theInitialTempType = null;
public …Run Code Online (Sandbox Code Playgroud)