以下是一个简单的Java gui程序,它创建了一个窗口并显示了一个标签:

import javax.swing.JFrame; import javax.swing.JLabel;

public class SimpleGui { public static void main(String[] args) { // 创建一个窗口 JFrame frame = new JFrame("Simple GUI"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  // 创建一个标签
  JLabel label = new JLabel("Hello, World!");

  // 将标签添加到窗口中
  frame.getContentPane().add(label);

  // 调整窗口大小并显示
  frame.pack();
  frame.setVisible(true);

} }

写一个简单的Java gui程序

原文地址: http://www.cveoy.top/t/topic/bgfn 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录