java车辆管理系统Word下载.docx
《java车辆管理系统Word下载.docx》由会员分享,可在线阅读,更多相关《java车辆管理系统Word下载.docx(30页珍藏版)》请在冰豆网上搜索。
![java车辆管理系统Word下载.docx](https://file1.bdocx.com/fileroot1/2022-11/25/68450807-1c13-4150-88fd-8659366b0782/68450807-1c13-4150-88fd-8659366b07821.gif)
{this.number=number;
publicStringgetNumber()
{returnnumber;
publicvoidsetName(Stringname)
(this.name=name;
)
publicStringgetName()
(returnname;
publicvoidsetDiscipling(Stringdiscipling)
(this.discipling=discipling;
publicStringgetDiscipling()
(returndiscipling;
publicvoidsetGrade(Stringgrade)
(this.grade=grade;
publicStringgetGrade()
(returngrade;
publicvoidsetBorth(Stringborth)
(this.borth=borth;
publicStringgetBorth()
(returnborth;
publicvoidsetSex(Stringsex)
(this.sex=sex;
publicStringgetSex()
(returnsex;
publicvoidsetImagePic(Fileimage)
(imagePic=image;
publicFilegetImagePic()
(returnimagePic;
//3.5InputCar类
classInputCarextendsJPanelimplementsActionListener
(Car车主=null;
CarPicturepic;
HashMap<
String,Car>
基本信息表=null;
JTextField车牌号,姓名,购车公司,购车时间;
JButton选择照片;
JComboBox档次;
JRadioButton男,女;
ButtonGroupgroup=null;
JButton录入,重置;
FileInputStreaminOne=null;
ObjectInputStreaminTwo=null;
FileInputStreamoutOne=null;
ObjectOutputStreamoutTwo=null;
FilesystemFile,imagePic;
publicInputCar(Filefile)
{systemFile=file;
pic=newCarPicture();
车牌号=newJTextField(5);
姓名=newJTextField(5);
档次=newJComboBox();
try{FileReaderinOne=newFileReader("
专业.txt"
);
BufferedReaderinTwo=newBufferedReader(inOne);
Strings=null;
inti=0;
while((s=inTwo.readLine())!
档次.addItem(s);
inOne.close();
inTwo.close();
catch(IOExceptionexp){
档次.addItem("
高级"
中高级”);
中级"
中低级"
普通"
购车公司=newJTextField(5);
购车时间=newJTextField(5);
选择照片=newJButton("
选择"
group=newButtonGroup();
男=newJRadioButton("
男"
true);
女=newJRadioButton("
女"
group.add(男);
group.add(女);
录入=newJButton("
录入"
重置=newJButton("
重置"
录入.addActionListener(this);
选择照片.addActionListener(this);
重置.addActionListener(this);
Boxbox1=Box.createHorizontalBox();
box1.add(newJLabel(“车牌号:
"
,JLabel.CENTER));
box1.add(车牌号);
Boxbox2=Box.createHorizontalBox();
box2.add(newJLabel(”车主姓名:
”,JLabel.CENTER));
box2.add(姓名);
Boxbox3=Box.createHorizontalBox();
box3.add(newJLabel("
车主性别:
JLabel.CENTER));
box3.add(男);
box3.add(女);
Boxbox4=Box.createHorizontalBox();
box4.add(newJLabel("
车辆档次:
box4.add(档次);
Boxbox5=Box.createHorizontalBox();
box5.add(newJLabel("
购车公司:
box5.add(购车公司);
Boxbox6=Box.createHorizontalBox();
box6.add(newJLabel("
购车时间:
box6.add(购车时间);
BoxboxH=Box.createVerticalBox();
boxH.add(box1);
boxH.add(box2);
boxH.add(box3);
boxH.add(box4);
boxH.add(box5);
boxH.add(box6);
boxH.add(Box.createVerticalGlue());
JPanelpicPanel=newJPanel();
picPanel.setBackground(Color.green);
picPanel.add(newJLabel("
选择照片:
picPanel.add(选择照片);
JPanelputButton=newJPanel();
putButton.add(录入);
putButton.add(重置);
JPanelmessPanel=newJPanel();
messPanel.add(boxH);
messPanel.setBackground(Color.cyan);
putButton.setBackground(Color.red);
setLayout(newBorderLayout());
JSplitPanesplitV=newJSplitPane(JSplitPane.VERTICAL_SPLIT,picPanel,pic);
JSplitPanesplitH=newJSplitPane(JSplitPane.HORIZONTAL_SPLIT,messPanel,splitV);
add(splitH,BorderLayout.CENTER);
add(putButton,BorderLayout.SOUTH);
validate();
publicvoidactionPerformed(ActionEvente)(if(e.getSource()==录入)(
Stringnumber="
;
number=车牌号.getText();
if(number.length()>
0){
try{
inOne=newFileInputStream(systemFile);
inTwo=newObjectInputStream(inOne);
基本信息表=(HashMap<
String,Car>
)inTwo.readObject();
catch(Exceptionee){)
if(基本信息表.containsKey(number)){
Stringwarning="
该生基本信息已存在,请到修改页面修改!
”;
JOptionPane.showMessageDialog(this,warning,"
警告
”,JOptionPane.WARNING_MESSAGE);
else{
Stringm="
基本信息将被录入!
”;
intok=JOptionPane.showConfirmDialog(this,m,”确认”,JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE);
if(ok==JOptionPane.YES_OPTION){
Stringname=姓名.getText();
Stringdiscipling=(String)档次.getSelectedItem();
Stringgrade=购车公司.getText();
Stringborth=购车时间.getText();
Stringsex=null;
if(男.isSelected())
sex=男.getText();
else
sex=女.getText();
车主=newCar();
车主.setNumber(number);
车主.setName(name);
车主.setDiscipling(discipling);
车主.setGrade(grade);
车主.setBorth(borth);
车主.setSex(sex);
车主.setImagePic(imagePic);
try{FileOutputStreamoutOne=newFileOutputStream(systemFile);
outTwo=newObjectOutputStream(outOne);
基本信息表.put(number,车主);
outTwo.writeObject(基本信息表);
outTwo.close();
outOne.close();
clearMess();
)catch(Exceptionee){))))else{Stringwarning="
必须要输入学号!
JOptionPane.showMessageDialog(this,warning,”警告
))elseif(e.getSource()==选择照片){JFileChooserchooser=newJFileChooser();
FileNameExtensionFilterfilter=newFileNameExtensionFilter("
JPG&
GIF
Images"
"
jpg"
"
gif"
chooser.setFileFilter(filter);
intstate=chooser.showOpenDialog(null);
FilechoiceFile=chooser.getSelectedFile();
if(choiceFile!
=null&
&
state==JFileChooser.APPROVE_OPTION){选择照片.setText(choiceFile.getName());
imagePic=choiceFile;
pic.setImage(imagePic);
pic.repaint();
))elseif(e.getSource()==重置){clearMess();
))publicvoidclearMess(){车牌号.setText(null);
姓名.setText(null);
购车公司.setText(null);
购车时间.setText(null);
选择照片.setText("
imagePic=null;
pic.setImage(imagePic);
//3.6inquset类
classInquestextendsJDialogimplementsActionListener(CarPicturepic;
PrintJobprint;
Graphicsg=null;
基本信息表;
JTextField车牌号,姓名,档次,购车公司,购车时间;
JRadioButton男,女;
JButton查询,打印文本及照片,打印文本,打印照片;
FilesystemFile=null;
JPanelmessPanel;
Carstu;
publicInquest(Filefile)(
setTitle(”查询对话框”);
setModal(false);
systemFile=file;
pic=newCarPicture();
车牌号=newJTextField(6);
查询=newJButton("
查询"
车牌号.addActionListener(this);
查询.addActionListener(this);
打印文本及照片=newJButton("
打印文本及照片”);
打印文本=newJButton("
打印文本"
);
打印照片=newJButton("
打印照片"
打印文本及照片.addActionListener(this);
打印文本.addActionListener(this);
打印照片.addActionListener(this);
打印文本及照片.setEnabled(false);
打印文本.setEnabled(false);
打印照片.setEnabled(false);
姓名=newJTextField(5);
姓名.setEditable(false);
档次=newJTextField(5);
档次.setEditable(false);
购车公司=newJTextField(5);
购车公司.setEditable(false);
购车时间=newJTextField(5);
购车时间.setEditable(false);
false);
box1.add(车牌号);
box1.add(查询);
box2.add(newJLabel("
车主姓名:
box2.add(姓名);
性另U:
JLabel.CENTER));
box3.add(男);
box3.add(女);
档次:
box4.add(档次);
messPanel=newJPanel();
JSplitPanesplitH=newJSplitPane(JSplitPane.HORIZONTAL_SPLIT,messPanel,pic);
JPanelpSouth=newJPanel();
pSouth.add(打印文本及照片);
pSouth.add(打印文本);
pSouth.add(打印照片);
add(pSouth,BorderLayout.SOUTH);
setVisible(false);
setSize(360,230);
addWindowListener(newWindowAdapter(){
publicvoidwindowClosing(WindowEvente){
}});
publicvoidactionPerformed(ActionEvente){
if(e.getSource()==查询||e.getSource()==车牌号){
inOne=newFileInputStream(systemFile);
inTwo=newObjectInputStream(inOne);
catch(Exceptionee){}
stu=基本信息表.get(number);
姓名.setText(stu.getName());
档次.setText(stu.getDiscipling());
购车公司.setText(stu.getGrade());
购车时间.setText(stu.getBorth());
if(stu.getSex().equals("
男”))
男.setSelected(true);
女.setSelected(true);
pic.setImage(stu.getImagePic());
pic.repaint();
打印文本及照片.setEnabled(true);
打印文本.setEnabled(true);
打印照片.setEnabled(true);
该车牌号不存在!
JOptionPane.showMessageDialog(this,warning,"
clearMess();
必须要输入车牌号!
警告"
JOptionPane.WARNING_MES