package Layout;
import java.awt.*;
import javax.swing.*;
public class MyBorderLayout extends JFrame{
private JButton b1 = new JButton("东");
private JButton b2 = new JButton("南");
private JButton b3 = new JButton("西");
private JButton b4 = new JButton("北");
private JButton b5 = new JButton("中");
public MyBorderLayout(){ setTitle("用户界面");
setSize(500, 500);
setLocation(100, 100);
add(b1,BorderLayout.EAST);
add(b2,BorderLayout.SOUTH);
add(b3,BorderLayout.WEST);
add(b4,BorderLayout.NORTH);
add(b5,BorderLayout.CENTER); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
} public static void main(String[] args) {
MyBorderLayout l = new MyBorderLayout(); } }
 package Layout;
import java.awt.*;
import java.util.HashMap;
import java.util.Map; import javax.swing.*;
public class MyFlowLayout extends JFrame{
private Map<String,JButton> map = new HashMap();
private JButton b = new JButton();
public MyFlowLayout(){
map.put("B1",new JButton("B1"));
map.put("B2",new JButton("B2"));
map.put("B3",new JButton("B3"));
map.put("B4",new JButton("B4"));
map.put("B5",new JButton("B5"));
this.setLayout(new FlowLayout());
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.setLayout(new FlowLayout(FlowLayout.RIGHT));
this.add(map.get("B1"));
this.add(map.get("B2"));
this.add(map.get("B3"));
this.add(map.get("B4"));
this.add(map.get("B5"));
this.setTitle("用户界面");
this.setSize(500, 400);
this.setLocation(400, 500);
this.setVisible(true);
} public static void main(String[] args) { MyFlowLayout l = new MyFlowLayout();
} }
 package Layout;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
import javax.swing.*;
public class MyGridLayout extends JFrame {
private Map<String,JButton> map = new HashMap();
public MyGridLayout (){ map.put("B1",new JButton("B1"));
map.put("B2",new JButton("B2"));
map.put("B3",new JButton("B3"));
map.put("B4",new JButton("B4"));
map.put("B5",new JButton("B5"));
map.put("B6",new JButton("B6"));
map.put("B7",new JButton("B7"));
map.put("B8",new JButton("B8"));
map.put("B9",new JButton("B9"));
this.add(map.get("B1"));
this.add(map.get("B2"));
this.add(map.get("B3"));
this.add(map.get("B4"));
this.add(map.get("B5"));
this.add(map.get("B6"));
this.add(map.get("B7"));
this.add(map.get("B8"));
this.add(map.get("B9")); this.setTitle("用户界面");
this.setSize(500, 600);
this.setLocation(500, 500);
this.setVisible(true);
this.setLayout(new GridLayout(3,3,15,15)); }
public static void main(String[] args) {
MyGridLayout l = new MyGridLayout(); } }

最新文章

  1. windows 常用命令整合--脚本工具
  2. 搭建Python+Django开发环境
  3. [问题2015S02] 复旦高等代数 II(14级)每周一题(第三教学周)
  4. Microsoft 2013 新技术学习笔记 二
  5. UI基础:UIActionSheet和UIAlterView
  6. UML类图新手入门级介绍
  7. VS2013中设置大小写的快捷键
  8. ☀【jQuery 优化】jQuery基础教程(第3版)
  9. 阻止IOS自动识别页面上的电话号码、email地址
  10. Qt之HTTPS登录(集成QNetworkAccessManager提前修改QSslConfiguration,然后post)
  11. Cngigure和BUS实现远端配置
  12. DHCP协议分析(Wireshark)
  13. [Java Web学习]JDBC事务处理
  14. NFC中国-中国第一NFC论坛,NFC中文论坛+NFC技术社区+NFC_电子发烧友网【申明:来源于网络】
  15. Bootstrap 插件收集
  16. Linux - 系统资源
  17. CSS3 Flex布局整理(一)
  18. Windows10(UWP)下的MEF
  19. Redis-3.2.0集群配置(redis cluster)
  20. VUE 实现tab切换页面效果

热门文章

  1. T1155 金明的预算方案 codevs
  2. 泛域名Wildcard Domain
  3. Codeforces Gym 100431D Bubble Sort 水题乱搞
  4. Loj #2036. 「SHOI2015」自动刷题机
  5. Maven修改默认本地资源库文件夹
  6. Net调用非托管代码(P/Invoke与C++InterOP) [转]
  7. K-L变换
  8. C# Window编程随记——ClickOnce程序部署
  9. 基于ACCESS和ASP的SQL多个表查询与计算统计代码(一)
  10. android 5.2