我的 jframe 不显示

2022-01-24 00:00:00 java swing jframe

我是java编程的初学者

I'm beginner woth java programming

我试图让我的 jframe 显示,但它没有

I tried to make my jframe shows but it didn't

jframe.setVisible(true);

没用

推荐答案

我认为你没有正确声明你的 JFrame.这是一个创建简单框架的示例:

I think you didn't declare correctly your JFrame. Here is an example creating a simple frame :

public static void main(String[] args)
{
    // Creating a frame
    JFrame frame = new JFrame("Example");
    // Setting the position and the size of the frame
    frame.setBounds(0,0,800,600);
    // This will terminate the program when closing the frame
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // Then you can display your frame
    frame.setVisible(true);
}

相关文章