我正在尝试让按钮刷新窗口,但收到以下错误消息:
Test.java:21: error: cannot find symbol
this.draw();
^
symbol: method draw()
1 error
这是代码:
import javax.swing.*;
import java.awt.event.*;
public class Test {
JFrame frame;
public void createMainWindow() {
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800,600);
JButton refresh = new JButton("Refresh");
refresh.setBounds(620, 20, 100, 30);
refresh.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
this.draw();
}
}
);
frame.setLayout(null);
frame.add(refresh);
frame.setVisible(true);
frame.setTitle("Title");
}
public void draw() {
// Code
frame.setVisible(true);
}
}
我显然误解了这一点。
温温酱
慕的地8271018
相关分类