feat(class44): 简单GUI界面

- 新增一个简单的登录窗口示例- 包含 JFrame、JPanel 和 JButton 的基本使用
-窗口大小设置为 300x200像素
- 添加了一个名为"登陆"的按钮
This commit is contained in:
2025-08-13 20:31:42 +08:00
parent c741b067d6
commit 32825e5512

View File

@@ -0,0 +1,22 @@
package class44;
import javax.swing.*;
public class JFarmeDemo1 {
public static void main(String[] args) {
// 创建一个输入框,有一个登陆按钮
JFrame win = new JFrame("登陆窗口");
win.setSize(300,200); //窗口大小
win.setLocationRelativeTo(null);//窗口居中
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //窗口关闭方式
JPanel panel = new JPanel();
win.add(panel);
JButton btn = new JButton("登陆");
btn.setBounds(100,100,100,50); //按钮位置和尺寸
panel.add(btn);
win.setVisible(true);
}
}