我添加了一个带有eclipse的jbutton,但看不到它。我如何解决它?Java JButton它没有真正运行
public class GUITest // test class
{
// block the warnings
public static void main(String[] args) //main
{
System.out.println("start of main");
/* stackoverflow want to add more details */
JFrame frame = new JFrame();
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,300);
JPanel panel = new JPanel();
frame.add(panel);
JButton button = new JButton("Click here");
panel.add(button);
button.addActionListener(new Action());
System.out.println("end of main");
/*计算器要添加更多的细节* /}
public static class Action implements ActionListener //actionlistener
{
public void actionPerformed (ActionEvent e)
{ /* stackoverflow want to add more details */
JFrame frame2 = new JFrame("Clicked");
frame2.setVisible(true);
frame2.setSize(200,200);
JLabel label = new JLabel("You clicked me!");
JPanel panel = new JPanel();
frame2.add(panel);
panel.add(label); // some more details
}
}
}
邮编看到这里Initial Threads .... –
随时拨打'setVisible' last.after将所有组件。但这似乎VGA issue.close Eclipse和尝试运行'图形处理器nvidea' HTTP ://forums.lenovo.com/t5/image/serverpage/image-id/4817i32CB2A6D7D20EC06/image-size/original?v = mpbl-1&px = -1 –
您可以将您的代码作为文本在这里发布... –