package com.xyzx.swing;
import javax.swing.JFrame;
/**
* @description 我的记事本主程序
*/
public class NotePad {
public static void main(String[] args) {
initFrame();
}
/**
* @description 初始化Frame(窗体)
*/
public static void initFrame(){
JFrame notePadFrame = new JFrame("我的记事本");
notePadFrame.setSize(300, 400);
notePadFrame.setVisible(true);
}
}
实现的效果:

二、修改:
package com.xyzx.swing;
import javax.swing.JFrame;
/**
* @description 我的记事本主程序
*/
public class NotePad {
/**
* 构造函数
*/
public NotePad(){
JFrame notePadFrame = new JFrame("我的记事本");
// 设置边框
notePadFrame.setBounds(200, 200, 300, 500);
notePadFrame.setVisible(true);
}
public static void main(String[] args) {
new NotePad();
}
}
效果:

本文介绍了一个使用Java Swing框架创建的简易记事本应用程序。通过构造函数初始化JFrame窗体,设置了窗口的位置、大小并使其可见。文章对比了两种不同的实现方式,展示了如何调整窗口的边界。
1067

被折叠的 条评论
为什么被折叠?



