第十一周课程总结

第十一周课程总结

这周我们主要学习了土星界面处理,有容器,组件,还有布局管理等等,这些组成在一起形成一个图形界面

###ATM工具包:
组件 Component
容器 Container
布局管理器 LatoutManager

组件:Component

Button 按钮
Label 标签
Checkbox
Choice
List
Scrollbar
TextComonent

Swing工具包:
组件 Component
容器 Container
布局管理器 LatoutManager

组件:JComponent
JButton 按钮
JLabel 标签
JCheckbox
JChoice
JList
JScrollbar
JTextComonent

基本容器 JFrame
JFrame frame = new JFrame();
f.setSize(300,400)
f.setVisible(true);
建立显示窗体
JLabel lab = new JLabel("显示标签");
f.add(lab);
在窗体中显示标签
JButton but = new JButton("按钮");
f.add(but);
在窗体中显示按钮

布局管理器
FlowLayout 流式布局管理器
f.setLayout(new FlowLayout(FlowLayout.CENTER,3,3);

BorderLayout 将窗体表面化为东南西北中
f.setLayout(new BorderLAyout(3,3));
f.add(new JButton("东(east)"),BorderLayout.EAST);
f.add(new JButton("西(west)"),BorderLayout.WEST);
f.add(new JButton("北(north)"),BorderLayout.NORTH);
f.add(new JButton("南(south)"),BorderLayout.SOUTH);
f.add(new JButton("中(center)"),BorderLayout.CENTER);

GridLayout 表格布局管理器
f.setLyout(new GridLayout(Height,width,3,3);
需要注意的事无论按钮多还是按钮少横轴是不会变的,都是竖轴在改变

CardLayout 将一组组件重叠地进行布局,每次只展示一个画面
通过card。next(cont); 进行下一个界面切换

绝对定位
提供一个坐标进行精准布局
f.setLayout(null); 使用绝对定位
posted @ 2019-11-07 20:28  渔家傲。  阅读(102)  评论(1编辑  收藏  举报