我这里有非常简单的 Java swing 代码,我没有看到框架中显示的按钮。有人可以帮助解决问题吗?
import javax.swing.*;
import java.awt.event.*;
public class HangmanGUI extends JFrame{
JComboBox favoriteShows;
JButton[] alphaButtons;
String infoOnComponent = "";
JButton button1;
public static void main(String[] args){
new HangmanGUI();
}
//constructor for Hangman
/**
* Instantiates a new hangman gui.
*/
public HangmanGUI() {
this.setSize(600,400);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("Play Hangman");
JPanel thePanel = new JPanel();
button1 = new JButton("Get Answer");
thePanel.add(button1);
this.setVisible(true);
}
}