当前位置: 首页 > news >正文

深圳设计公司上市成功有几家/陕西整站关键词自然排名优化

深圳设计公司上市成功有几家,陕西整站关键词自然排名优化,做文字的网站,创新的成都 网站建设AWT 包括了很多类和接口,用于java Application的GUI编程GUI的各种元素有java类类实现使用AWT所涉及的类一般在java.awt包及其子包中Container和Component是AWT中的两个核心类Component & Container java的图形用户界面的嘴基本组成部分是Component&#xff0c…

AWT

  • 包括了很多类和接口,用于java Application的GUI编程
  • GUI的各种元素有java类类实现
  • 使用AWT所涉及的类一般在java.awt包及其子包中
  • Container和Component是AWT中的两个核心类

Component & Container

  • java的图形用户界面的嘴基本组成部分是Component,Component类及其子类的对象用来描述以图形化的方式显示在屏幕上并能与用户进行交互的GUI元素,例如:一个按钮,一个标签等;
  • 一般的Component对象不能独立的显示出来,必须将放在某一个Container对象中才可以显示出来;
  • Container是Component的子类,Container子类对象可以容纳别的Component对象;
  • Container对象可以使用add() 方法向其中添加其他Component对象;
  • Container是Component的子类,因此Container对象也可以被当作Component对象添加到其他Container对象中;
  • 有两种常用的Container:
  • Window:其对象表示自由停泊的顶级窗口;
  • Panel:其对象可以作为容纳其他Component对象,但是不能独立的存在,必须被添加到其他Container中。

 

Frame

  • Frame是window的子类,有Frame或子类创建的对象为一个窗体;
  • Frame的常用构造方法:Frame()   Frame(String s)创建标题栏字符串s的窗口。

实例代码:

import java.awt.*;
public class TestFrame{public static void main(String[] args){Frame f = new Frame("My First Test");f.setSize(600,400);f.setLocation(300,300);f.setBackground(Color.cyan);f.setVisible(true);}
}

Panel

  • Panel对象可以看成容纳Component的空间;
  • Panel对象可以拥有自己的布局管理器;
  • Panel类拥有从父类继承来的setBounds(int x,int y,int width,int height)…
  • Panel的构造方法:Panel()使用默认的FlowLayout类布局管理器初始化;
  • Panel(LayoutManager layout)使用指定的布局管理器初始化。

实例代码:

import java.awt.*;public class TestPanel{public static void main(String[] args){Frame f = new Frame("Java Frame with Panel");Panel p = new Panel(null);f.setLayout(null);f.setBounds(300,300,500,500);f.setBackground(new Color(0,0,102));p.setBounds(50,50,400,400);p.setBackground(new Color(205,205,222));f.add(p);f.setVisible(true);}
}

布局管理器

  • java语言中提供了布局管理器类的对象可以管理Component在Container中的布局,不必直接设置Component位置和大小;
  • 每个Container都有一个布局管理器对象,当容器需要对某个组件进行定位或判断其大小尺寸的时候,就会调用其对应的布局管理器,调用Container的setLayout方法改变其布局管理器对象;
  • AWT提供了5中布局管理器类:FlowLayout;BorderLayout;GridLayout;CardLayout;GridBagLayout。

 

FLowLayout布局管理器

  • FlowLayout是Panel类的默认布局管理器:他是对组件进行逐行进行定位,行内从左到右一排满后换行,不改变组件的大小,按主键原有尺寸显示组件,可设置不同组件的间距,行距以及对齐方式;
  • FlowLayout布局管理器默认的对齐方式是居中;
  • FlowLayout构造方法:new FlowLayout(FlowLayout.RIGHT,20,40)右对齐,组件之间水平间距20像素,垂直间距40像素;
  • New FlowLayout(FlowLayout.left);左对齐,水平和垂直间距为缺省值(5);
  • New FlowLayout();使用缺省的居中对齐方式,水平和垂直间距为缺省值(5);

实例代码:

import java.awt.*;public class TestFlowLayout{public static void main(String[] args){Frame f = new Frame("FlowLayout");Button button1 = new Button("OK");Button button2 = new Button("Open");Button button3 = new Button("Close");f.setLayout(new FlowLayout());f.add(button1);f.add(button2);f.add(button3);f.setSize(100,100);f.setVisible(true);}
}

BorderLayout布局管理器

  • BorderLayout是Frame类的默认布局管理器;
  • BorderLayout将整个容器的布局划分成:东(EAST),西(WEST),南(SOUTH),北(NORTH),中(CENTER)五个区域,组件只能添加到指定的区域;
  • 如不指定组件的加入部位,则默认加入到CENTER区;
  • 每个区域只能加入一个组件,如加入多个则先前加入的组件会被覆盖。

实例代码:

import java.awt.*;public class TestBorderLayout{public static void main(String[] args){Frame f = new Frame("Border Layout");Button bn = new Button("BN");Button bs = new Button("BS");Button bw = new Button("BW");Button be = new Button("BE");Button bc = new Button("BC");f.add(bn,BorderLayout.NORTH);f.add(bs,BorderLayout.SOUTH);f.add(bw,BorderLayout.WEST);f.add(be,BorderLayout.EAST);f.add(bc,BorderLayout.CENTER);f.setSize(200,200);f.setVisible(true);}
}

GridLayout布局管理器

  • GridLayout型布局管理器将空间划分成规则的巨型网格,每个单元格区域到校相等,组件被添加到每个单元小格中,先从左到右添加满一行后换行,再从上到下;
  • 在GridLayout构造方法中指定分隔的行数和列数:

实例代码:

import java.awt.*;public class TestGridLayout{public static void main(String[] args){Frame f = new Frame("计算器");Button b1 = new Button("1");Button b2 = new Button("2");Button b3 = new Button("3");Button b11 = new Button("+");Button b12 = new Button("-");Button b4 = new Button("4");Button b5 = new Button("5");Button b6 = new Button("6");Button b13 = new Button("*");Button b14 = new Button("/");Button b7 = new Button("7");Button b8 = new Button("8");Button b9 = new Button("9");Button b15 = new Button("=");		Button b0 = new Button("0");f.setLayout(new GridLayout(3,5));f.add(b1);f.add(b2);f.add(b3);f.add(b11);f.add(b12);f.add(b4);f.add(b5);f.add(b6);f.add(b13);f.add(b14);f.add(b7);f.add(b8);f.add(b9);f.add(b0);f.add(b15);f.pack();f.setVisible(true);}
}

输出结果:

布局管理器总结:

Frame是一个顶级窗口,Frame的确实布局管理器为BorderLayout;

Panel无法独立显示,必须添加到某个容器中,Panel的缺省布局管理器为FlowLayout;

当把Panel作为一个组件添加到某个容器中后,该Panel仍然可以有自己的布局管理器;

使用布局管理器时,布局管理器负责各个组件的大小和位置,因此用户无法在这种情况下设置组件的大小和位置属性,如果试图使用java语言提供的setLocation(),setSize(),setBounds()等方法,则会别局部管理器覆盖;

如果用户确实需要亲自设置组件大小或位置,则应取消该容器的布局管理器,方法为setLayout(null);

http://www.jmfq.cn/news/4969315.html

相关文章:

  • 无锡自助做网站/中国搜索引擎市场份额
  • 石景山青岛网站建设/世界十大搜索引擎及地址
  • 网站开发有哪些模块/seo需要掌握什么技能
  • 菠菜网站建设条件/百度高级搜索首页
  • 外贸网站 服务器/品牌整合营销推广
  • 出国越南做网站8000保底/网络媒体有哪些
  • 网站建设整合营销/抖音seo运营模式
  • 个人网站有什么用/seo技巧分享
  • 金融网站怎么做/google国际版入口
  • 产品介绍网站源码/东莞做网站的公司吗
  • 环评怎么在网站做公示/网络安全培训最强的机构
  • 做网站有那几种末班/如何在百度推广自己的产品
  • 怎样在百度上做网站/新产品推广方式有哪些
  • 做任务的正规网站/中企动力做网站推广靠谱吗
  • 珠海网站制作服务/微信软文案例
  • 武汉那些网站做家教的/网站建设建站在线建站
  • nba最新排名情况/seo优化神器
  • 域名和主机搭建好了怎么做网站/网络推广策划方案模板
  • 上海正规做网站公司/苏州关键词搜索排名
  • 台山网站建设公司/百度网站优化公司
  • 群晖nas可以做web网站/高粱seo博客
  • 建设钓鱼网站源码/最近的新闻大事
  • 网站建设与维护相关知识/seo zac
  • 卖游戏币网站制作/2345网址导航下载桌面
  • 金牌网站设计网站建设/广告公司广告牌制作
  • 网站开发后 怎么换前端/外链工具软件
  • 北京网站开发公司/同城推广
  • 江西专业南昌网站建设/首页关键词排名
  • 黑龙江做网站的公司有哪些/空间刷赞网站推广
  • 网站登录页面怎么做的/网站优化一年多少钱