public class WASD extends JFrame{
Ellipse2D.Double ball;
int ballx = 100;
int bally = 100;
static JTextField typingArea;
public static void main(String[] args){
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
private static void createAndShowGUI(){
WASD frame = new WASD("frame");
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.addComponentsToPane();
frame.pack();
frame.setVisible(true);
}
private void addComponentsToPane(){
typingArea = new JTextField(20);
//typingArea.addKeyListener(this);
}
public WASD(String name){
super(name);
}
}
当我运行程序时,我得到的只是一个空窗口。JTextField 不显示。谢谢!
(显然我的帖子代码太多了,所以我添加这个让它让我提交。忽略这句话和上一个。)