I/O
IO流:1:字节流(inputStream:输入流)(outputStream:输出流)。2:字符流(reader:输入流)(winter:输出流)。
首先判断是输入还是输出(站在计算机的立场);其次判断传递字符还是字节,从而选择用什么管道。字节管道是 最根本的,字符管道专门用来传递文本数据的。
操作顺序;1,建立管道。2,操作管道。3,关闭 管道。
序列化:将内存中的对象一二进制流的形式输出。
反序列化:将输入的二进制流转化为内存中的对象。(第二种产生对象的方式)
序列化中将对象转化为二进制流的叫做操作流,后面必须跟上节点流即目的地。
一篇GUI,可以照着做的public class MyFrame extends JFrame{
private Container contentP;//内容面板
private JLabel msgLab;//文字标签
private JLabel imgLab;//图片标签
private JTextField usernameTxt;//文本框
private JPasswordField pwdTxt;//密码框
private JButton okBtn;//按钮
private JButton getMoentyBtn;//取钱按钮
private JComboBox<String> teacherCmb;//下拉列表
private JTextArea selfArea;//文本域
private JRadioButton maleRad;//单选框
private JRadioButton femaleRad;
private JCheckBox hobbitBox;//复选框
public MyFrame(){
Toolkit tk = Toolkit.getDefaultToolkit();//获取工具对象
int screenWidth = (int)tk.getScreenSize().getWidth();
int screenHeight = (int)tk.getScreenSize().getHeight();
this.setSize(500, 400);//设置窗体大小--像素
this.setLocation((screenWidth-500)/2, (screenHeight-400)/2);//设置窗体的位置
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置窗体关闭即退出程序
this.setTitle("我的第一个GUI窗体");//标题栏设置标题
this.setIconImage(tk.createImage("image/icon.png"));//设置标题栏图标
this.setResizable(false);//设置窗体改变大小的能力
this.addContent();
this.setVisible(true);//设置该窗体可见
}
private void addContent(){
this.contentP = this.getContentPane();//获取内容面板
this.contentP.setBackground(Color.WHITE);//设置窗体背景色
this.contentP.setLayout(null);//设置布局管理器为null---代表放入该容器的组件的大小位置全靠自定义
//文本标签
this.msgLab = new JLabel("用户名:");//产生对象
this.msgLab.setText("用户名:");
// this.msgLab.setBorder(BorderFactory.createLineBorder(Color.BLACK));//给标签设置边框--调试用
this.msgLab.setFont(new Font("微软雅黑",Font.BOLD,16));//设置字体
this.msgLab.setForeground(new Color(82,254,211));//设置字体颜色
this.msgLab.setBounds(100, 20, 80, 30);//设置大小位置
this.contentP.add(this.msgLab);//放入容器
//图片标签
this.imgLab = new JLabel(new ImageIcon("image/fish.jpg"));
this.imgLab.setBounds(200, 20, 243, 167);
this.contentP.add(this.imgLab);
//文本框
this.usernameTxt = new JTextField();
this.usernameTxt.setBounds(20, 70, 100, 30);
this.usernameTxt.setFont(new Font("微软雅黑",Font.BOLD,16));//设置字体
this.usernameTxt.setForeground(new Color(82,254,211));//设置字体颜色
// this.usernameTxt.setEditable(false);//设置文本框不可编辑
this.contentP.add(this.usernameTxt);
//密码框
this.pwdTxt = new JPasswordField();
this.pwdTxt.setEchoChar('*');
this.pwdTxt.setFont(new Font("微软雅黑",Font.BOLD,16));//设置字体
this.pwdTxt.setForeground(new Color(82,254,211));//设置字体颜色
this.pwdTxt.setBounds(20, 120, 100, 30);
this.contentP.add(this.pwdTxt);
//按钮
this.okBtn = new JButton("确定");
this.okBtn.setText("确定");
this.okBtn.setFont(new Font("微软雅黑",Font.BOLD,16));//设置字体
this.okBtn.setForeground(new Color(82,254,211));//设置字体颜色
this.okBtn.setBounds(20, 160, 100, 30);
this.contentP.add(this.okBtn);
this.getMoentyBtn = new JButton(new ImageIcon("image/buttonGet.jpg"));
this.getMoentyBtn.setBounds(20, 200, 140, 50);
this.contentP.add(this.getMoentyBtn);
//下拉列表
this.teacherCmb = new JComboBox<String>();
this.teacherCmb.addItem("周春艳");
this.teacherCmb.addItem("刘弯弯");
this.teacherCmb.addItem("万洁");
this.teacherCmb.addItem("张欣");
this.teacherCmb.addItem("何茹薇");
this.teacherCmb.setEditable(true);//设置为可编辑为true
this.teacherCmb.setBounds(20, 260, 100, 20);
this.contentP.add(this.teacherCmb);
//文本域
this.selfArea = new JTextArea();
JScrollPane scrollP = new JScrollPane(this.selfArea);
scrollP.setBounds(200, 200, 280, 160);
this.contentP.add(scrollP);
//单选框
this.maleRad = new JRadioButton("男");
this.femaleRad = new JRadioButton("女");
this.maleRad.setBounds(20, 290, 50, 25);
this.femaleRad.setBounds(80, 290, 50, 25);
this.maleRad.setBackground(Color.WHITE);
this.femaleRad.setBackground(Color.WHITE);
this.maleRad.setSelected(true);//设置默认选中
this.contentP.add(this.maleRad);
this.contentP.add(this.femaleRad);
ButtonGroup bGroup = new ButtonGroup();//按钮分组
bGroup.add(this.maleRad);
bGroup.add(this.femaleRad);
//复选框
this.hobbitBox = new JCheckBox("兴趣爱好");
this.hobbitBox.setBounds(20, 325, 100, 25);
this.contentP.add(this.hobbitBox);
}
}
I/O的更多相关文章
- <%@ include file="">和<jsp:include file="">区别
<%@include file="a.jsp"%>是在编译时加入,所谓静态,就是在编译的时候将jsp的代码加入进来再编译,之后运行. <jsp:include p ...
- <jsp:include>和<%@include file=""%>区别【131031】
<jsp:include page=""> 父页面和包含进来的页面单独编译,单独翻译成servlet后,在前台拼成一个HTML页面. <%@include fil ...
- this.getClass().getResource("") url path file 区别
首先注意 "/word/appointDismiss.docx" 前面一定要加 /,有一次我就是忘记加/ 查了半天错, 不能写成 "word/appointDismiss ...
- python3.0_day9_scoket基础之篇
一.socket简单介绍 socket通常也称作"套接字",用于描述IP地址和端口,是一个通信链的句柄,应用程序通常通过"套接字"向网络发出请求或者应答网络请求 ...
- python学习之路网络编程篇(第一篇)socket初识
什么是socket 网络上的两个程序通过一个双向的通信连接实现数据的交换,这个连接的一端称为socket.socket通常也称为“套接字”,是一个通信链的句柄,可以用来实现不同虚拟机或不同计算机之间的 ...
- php笔记篇(二)
mysql中key .primary key .unique key 与index区别(http://www.manongjc.com/article/1487.html) php is_file() ...
- php 编程笔记分享 - 非常实用
php opendir()列出目录下所有文件的两个实例 php opendir()函数讲解及遍历目录实例 php move_uploaded_file()上传文件实例及遇到问题的解决方法 php使用m ...
- jsp基本语法总结
一,用jsp脚本元素调用java代码 1,jsp表达式的应用 jsp表达式将值直接插入到输出中: <%= Java Expression %> 代表一个值 隐式对象,在使用jsp表达式的 ...
- 27.centos7基础学习与积累-013-文件和目录的权限
从头开始积累centos7系统运用 大牛博客: https://blog.51cto.com/yangrong/p5 https://blog.oldboyedu.com/ 文件的权限 rw-r--r ...
- 2020/1/31 PHP代码审计之文件包含漏洞
0x00 文件包含简介 文件包含漏洞的产生原因是在通过引入文件时,引用的文件名,用户可控,由于传入的文件名没有经过合理的校检,或者校验被绕过,从而操作了预想之外的文件,就可能导致意外的文件泄露甚至恶意 ...
随机推荐
- Github上关于iOS的各种开源项目集合(强烈建议大家收藏,查看,总有一款你需要)
下拉刷新 EGOTableViewPullRefresh - 最早的下拉刷新控件. SVPullToRefresh - 下拉刷新控件. MJRefresh - 仅需一行代码就可以为UITableVie ...
- JAVA-小青蛙跳石头游戏
游戏摘自微信传的手机网页版小游戏,我拿来做成了JAVA的界面版,但是没有去做素材,,直接拿方块代替小青蛙.游戏原址就不分享了,只能在手机上打开. 下面是源码: /* * Main.java * */ ...
- DSO的记录模式Record Mode字段测试
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- s
echo. 输出空行 echo; 输出空行 请求用户输入 set /p LOG_PATH=请输入log绝对路径: http://159.20.127:9009/gamesdk/doroot.jsp ...
- 【树莓派】树莓派使用4G模块上网
想了解一下树莓派通过4G网络模块通信如何实现,看到这篇文章(http://www.lxway.com/95811506.htm),准备接下来有机会实践一下,先留存学习: 一.4G Luci配置 1. ...
- PDF二次开发_iStylePDF表单域的填充
wo讲到PDF表单,我们首先需要认识Adobe定义的PDF表单有哪些.以下是我从网上搜索到的简单介绍: PDF 表单简介 PDF 是可移植文档格式(Portable Document Format)的 ...
- 平衡二叉树AVL
1.定义 平衡二叉树(Balanced Binary Tree)是二叉查找树的一个改进,也是第一个引入平衡概念的二叉树.1962年,G.M. Adelson-Velsky 和 E.M. Landis发 ...
- winpcap抓包原理
winpcap抓包原理 WinPcap 是由伯克利分组捕获库派生而来的分组捕获库,它是在Windows 操作平台上来实现对底层包的截取过滤.WinPcap 是 BPF 模型和 Libpcap 函数库在 ...
- HBase 数据读写流程
HBase 数据读写流程 2016-10-18 杜亦舒 读数据 HBase的表是按行拆分为一个个 region 块儿,这些块儿被放置在各个 regionserver 中 假设现在想在用户表中获取 ro ...
- OpenCV学习笔记(一)——OpenCV安装
1.无脑安装以下安装文件 cn_visual_studio_2010_ultimate_x86_dvd_532347.iso 2.测试Hello OpenCV 文件→新建→项目 win32应用程序→下 ...