每当我键入此代码时,java 总是在类声明语句下加下划线,错误消息是“此处需要接口”。我怎样才能解决这个问题?
package tempconverter;
import javax.swing.*;
import java.awt.event.*;
import java.awt.FlowLayout;
import static java.lang.System.out;
public class TempConverter extends JFrame implements ActionListener, ActionEvent{
static JFrame f = new JFrame();
static JTextField enter = new JTextField(3);
static JButton confirm = new JButton("Convert");
public static void main(String[] args) {
f.setLayout(new FlowLayout());
f.setSize(100, 50);
f.pack();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(enter);
f.add(confirm);
f.setVisible(true);
}
@Override
public void actionPerformed (ActionEvent e) {
double toConvert = Float.parseFloat(enter.getText());
double inF, inK;
inF = toConvert / 5 * 9 + 32;
inK = …Run Code Online (Sandbox Code Playgroud) java ×1