Ai
1 Star 0 Fork 0

20175235泽仁拉措/Besti.Java

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
InputArea.java 1.75 KB
一键复制 编辑 原始数据 按行查看 历史
20175235泽仁拉措 提交于 2019-04-08 00:58 +08:00 . txt
import java.io.*;
import javax.swing.*;
import java.awt.Color;
import java.awt.event.*;
public class InputArea extends JPanel implements ActionListener {
File f=null;
RandomAccessFile out;
Box baseBox,boxV1,boxV2;
JTextField name,email,phone;
JButton button;
InputArea(File f) {
setBackground(Color.cyan);
this.f=f;
name=new JTextField(12);
email=new JTextField(12);
phone=new JTextField(12);
button=new JButton("录入");
button.addActionListener(this);
boxV1=Box.createVerticalBox();
boxV1.add(new JLabel("输入姓名"));
boxV1.add(Box.createVerticalStrut(8));
boxV1.add(new JLabel("输入email"));
boxV1.add(Box.createVerticalStrut(8));
boxV1.add(new JLabel("输入电话"));
boxV1.add(Box.createVerticalStrut(8));
boxV1.add(new JLabel("单击录入"));
boxV2=Box.createVerticalBox();
boxV2.add(name);
boxV2.add(Box.createVerticalStrut(8));
boxV2.add(email);
boxV2.add(Box.createVerticalStrut(8));
boxV2.add(phone);
boxV2.add(Box.createVerticalStrut(8));
boxV2.add(button);
baseBox=Box.createHorizontalBox();
baseBox.add(boxV1);
baseBox.add(Box.createHorizontalStrut(10));
baseBox.add(boxV2);
add(baseBox);
}
public void actionPerformed(ActionEvent e) {
try{
RandomAccessFile out=new RandomAccessFile(f,"rw");
if(f.exists())
{ long length=f.length();
out.seek(length);
}
out.writeUTF("姓名:"+name.getText());
out.writeUTF("eamil:"+email.getText());
out.writeUTF("电话:"+phone.getText());
out.close();
}
catch(IOException ee){}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/drpkgj/Besti.Java.git
git@gitee.com:drpkgj/Besti.Java.git
drpkgj
Besti.Java
Besti.Java
master

搜索帮助