java GUI AWT包
2024-10-21 09:36:20
第一个GUI程序,在netbeans里因为没有自动导包,害的我差点崩溃,因为没有导入AWT包,所以
public class Jfram {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
EventQueue.invokeLater(()->{
SimpleFrame frame=new SimpleFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);}
);
}}
class SimpleFrame extends JFrame{
public SimpleFrame(){
setSize(300,200);
}
}
高亮的就是报错语句,上网查了,是为了线程安全,我现在也不太懂这个语法,先记上,
public class Jfram {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
SimpleFrame frame=new SimpleFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);}
}
class SimpleFrame extends JFrame{
public SimpleFrame(){
setSize(300,200);
}
}
事实证明,没有这段语法,程序也是能跑的,应该是为什么线程安全,巴拉巴拉的
书上设置像素大小,非要拿变量存着,setSize方法也是要在函数里调用,可能是因为要函数式编程吧,
问题还是在interlij idea里发现的,因为interlij里自动导包,学习了
最新文章
- div实现自适应高度的textarea,实现angular双向绑定
- what's cloud computing? IaaS
- 每天一个linux命令(14):head 命令
- struts2中的constant配置详解
- .net_ckeditor+ckfinder的图片上传配置
- C语言输出单个汉字字符
- C# ASPX.NET 文件(图片)下载
- C#学习笔记之线程 - 同步上下文
- Python:运算符
- html动态编辑框
- oracle 取头十条数据
- XCL-Charts圈图
- 使用c#给outlook添加任务、发送邮件
- YII 1.0 隐藏单入口index.php 设置路由与伪静态
- C++ Primer Plus阅读笔记
- Redux中间件组合方法
- vue-filter
- 如何用Win7远程链接ubuntu14.04桌面
- text_edit 未定义解决
- 数据库查询字段为null 时,返回0
热门文章
- C3861: “CoInitialize”“CoUninitialize”: 找不到标识符
- Power shell 读取电量,改变屏幕亮度
- Android中动态添加tab
- linux run/media/wang/centos_磁盘爆满
- flutter CustomScrollView多个滑动组件嵌套
- nextLine和hasNextLine的区别
- ubuntu下ntp时间同步
- 记录web面经
- C# List间的交集并集差集
- python33