版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、/车辆管理系统package javaapplication27;import javax.swing.*;import java.io.*;import java.awt.*;import java.awt.event.*;import java.util.*;import javax.swing.filechooser.*;import java.io.FileInputStream;/3.4CarPicture 类class CarPicture extends JPanel File imageFile; Toolkit tool; public CarPicture() tool=g
2、etToolkit(); public void setImage(File imageFile) this.imageFile=imageFile; repaint(); Override public void paintComponent(Graphics g) super.paintComponent(g); int w=getBounds().width; int h=getBounds().height; if(imageFile!=null) Image image=tool.getImage(imageFile.getAbsolutePath(); g.drawImage(im
3、age, 0,0,w,h, this); /3.3Car类class Car implements Serializable String number,name,discipling,grade,borth,sex; File imagePic; public void setNumber(String number) this.number=number; public String getNumber() return number; public void setName(String name) =name; public String getName() retu
4、rn name; public void setDiscipling(String discipling) this.discipling=discipling; public String getDiscipling() return discipling; public void setGrade(String grade) this.grade=grade; public String getGrade() return grade; public void setBorth(String borth) this.borth=borth; public String getBorth()
5、 return borth; public void setSex(String sex) this.sex=sex; public String getSex() return sex; public void setImagePic(File image) imagePic=image; public File getImagePic() return imagePic; /3.5InputCar类class InputCar extends JPanel implements ActionListener Car 车主=null; CarPicture pic; HashMap基本信息表
6、=null; JTextField 车牌号,姓名,购车公司,购车时间; JButton 选择照片; JComboBox 档次; JRadioButton 男,女; ButtonGroup group=null; JButton 录入,重置; FileInputStream inOne=null; ObjectInputStream inTwo=null; FileInputStream outOne=null; ObjectOutputStream outTwo=null; File systemFile,imagePic; public InputCar(File file) systemF
7、ile=file; pic=new CarPicture(); 车牌号=new JTextField(5); 姓名=new JTextField(5); 档次=new JComboBox(); try FileReader inOne = new FileReader(专业.txt); BufferedReader inTwo = new BufferedReader(inOne); String s = null; int i=0; while(s=inTwo.readLine()!=null) 档次.addItem(s); inOne.close(); inTwo.close(); cat
8、ch(IOException exp) 档次.addItem(高级); 档次.addItem(中高级); 档次.addItem(中级); 档次.addItem(中低级); 档次.addItem(普通); 购车公司=new JTextField(5); 购车时间=new JTextField(5); 选择照片=new JButton(选择); group=new ButtonGroup(); 男=new JRadioButton(男,true); 女=new JRadioButton(女,true); group.add(男); group.add(女); 录入=new JButton(录入);
9、 重置=new JButton(重置); 录入.addActionListener(this); 选择照片.addActionListener(this); 重置.addActionListener(this); Box box1=Box.createHorizontalBox(); box1.add(new JLabel(车牌号:,JLabel.CENTER); box1.add(车牌号); Box box2=Box.createHorizontalBox(); box2.add(new JLabel(车主姓名:,JLabel.CENTER); box2.add(姓名); Box box3=
10、Box.createHorizontalBox(); box3.add(new JLabel(车主性别:,JLabel.CENTER); box3.add(男); box3.add(女); Box box4=Box.createHorizontalBox(); box4.add(new JLabel(车辆档次:,JLabel.CENTER); box4.add(档次); Box box5=Box.createHorizontalBox(); box5.add(new JLabel(购车公司:,JLabel.CENTER); box5.add(购车公司); Box box6=Box.create
11、HorizontalBox(); box6.add(new JLabel(购车时间:,JLabel.CENTER); box6.add(购车时间); Box boxH=Box.createVerticalBox(); boxH.add(box1); boxH.add(box2); boxH.add(box3); boxH.add(box4); boxH.add(box5); boxH.add(box6); boxH.add(Box.createVerticalGlue(); JPanel picPanel=new JPanel(); picPanel.setBackground(Color.g
12、reen); picPanel.add(new JLabel(选择照片:,JLabel.CENTER); picPanel.add(选择照片); JPanel putButton=new JPanel(); putButton.add(录入); putButton.add(重置); JPanel messPanel=new JPanel(); messPanel.add(boxH); messPanel.setBackground(Color.cyan); putButton.setBackground(Color.red); setLayout(new BorderLayout(); JSp
13、litPane splitV=new JSplitPane(JSplitPane.VERTICAL_SPLIT,picPanel,pic); JSplitPane splitH=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,messPanel,splitV); add(splitH,BorderLayout.CENTER); add(putButton,BorderLayout.SOUTH); validate(); public void actionPerformed(ActionEvent e) if(e.getSource()=录入) Strin
14、g number=; number=车牌号.getText(); if(number.length()0) try inOne =new FileInputStream(systemFile); inTwo =new ObjectInputStream(inOne); 基本信息表=(HashMap)inTwo.readObject(); inOne.close(); inTwo.close(); catch(Exception ee) if(基本信息表.containsKey(number) String warning=该生基本信息已存在,请到修改页面修改!; JOptionPane.sho
15、wMessageDialog(this,warning, 警告,JOptionPane.WARNING_MESSAGE); else String m=基本信息将被录入!; int ok=JOptionPane.showConfirmDialog(this,m, 确认,JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE); if(ok=JOptionPane.YES_OPTION) String name=姓名.getText(); String discipling=(String)档次.getSelectedItem(); S
16、tring grade=购车公司.getText(); String borth=购车时间.getText(); String sex=null; if(男.isSelected() sex=男.getText(); else sex=女.getText(); 车主=new Car(); 车主.setNumber(number); 车主.setName(name); 车主.setDiscipling(discipling); 车主.setGrade(grade); 车主.setBorth(borth); 车主.setSex(sex); 车主.setImagePic(imagePic); try
17、 FileOutputStream outOne=new FileOutputStream(systemFile); outTwo=new ObjectOutputStream(outOne); 基本信息表.put(number,车主); outTwo.writeObject(基本信息表); outTwo.close(); outOne.close(); clearMess(); catch(Exception ee) else String warning=必须要输入学号!; JOptionPane.showMessageDialog(this,warning,警告,JOptionPane.
18、WARNING_MESSAGE); else if(e.getSource()=选择照片) JFileChooser chooser=new JFileChooser(); FileNameExtensionFilter filter=new FileNameExtensionFilter(JPG&GIF Images,jpg,gif); chooser.setFileFilter(filter); int state=chooser.showOpenDialog(null); File choiceFile=chooser.getSelectedFile(); if(choiceFile!=
19、null&state=JFileChooser.APPROVE_OPTION) 选择照片.setText(choiceFile.getName(); imagePic=choiceFile; pic.setImage(imagePic); pic.repaint(); else if(e.getSource()=重置) clearMess(); public void clearMess() 车牌号.setText(null); 姓名.setText(null); 购车公司.setText(null); 购车时间.setText(null); 选择照片.setText(选择); imagePi
20、c=null; pic.setImage(imagePic); pic.repaint(); /3.6inquset类class Inquest extends JDialog implements ActionListener CarPicture pic; PrintJob print; Graphics g=null; HashMap基本信息表; JTextField 车牌号,姓名,档次,购车公司,购车时间; JRadioButton 男,女; JButton 查询,打印文本及照片,打印文本,打印照片; ButtonGroup group=null; FileInputStream in
21、One=null; ObjectInputStream inTwo=null; File systemFile=null; JPanel messPanel; Car stu; public Inquest(File file) setTitle(查询对话框); setModal(false); systemFile=file; pic =new CarPicture(); 车牌号=new JTextField(6); 查询=new JButton(查询); 车牌号.addActionListener(this); 查询.addActionListener(this); 打印文本及照片=new
22、 JButton(打印文本及照片); 打印文本=new JButton(打印文本); 打印照片=new JButton(打印照片); 打印文本及照片.addActionListener(this); 打印文本.addActionListener(this); 打印照片.addActionListener(this); 打印文本及照片.setEnabled(false); 打印文本.setEnabled(false); 打印照片.setEnabled(false); 姓名=new JTextField(5); 姓名.setEditable(false); 档次=new JTextField(5)
23、; 档次.setEditable(false); 购车公司=new JTextField(5); 购车公司.setEditable(false); 购车时间=new JTextField(5); 购车时间.setEditable(false); 男=new JRadioButton(男,false); 女=new JRadioButton(女,false); group=new ButtonGroup(); group.add(男); group.add(女); Box box1=Box.createHorizontalBox(); box1.add(new JLabel(车牌号:,JLabe
24、l.CENTER); box1.add(车牌号); box1.add(查询); Box box2=Box.createHorizontalBox(); box2.add(new JLabel(车主姓名:,JLabel.CENTER); box2.add(姓名); Box box3=Box.createHorizontalBox(); box3.add(new JLabel(性别:,JLabel.CENTER); box3.add(男); box3.add(女); Box box4=Box.createHorizontalBox(); box4.add(new JLabel(档次:,JLabel
25、.CENTER); box4.add(档次); Box box5=Box.createHorizontalBox(); box5.add(new JLabel(购车公司:,JLabel.CENTER); box5.add(购车公司); Box box6=Box.createHorizontalBox(); box6.add(new JLabel(购车时间:,JLabel.CENTER); box6.add(购车时间); Box boxH=Box.createVerticalBox(); boxH.add(box1); boxH.add(box2); boxH.add(box3); boxH.a
26、dd(box4); boxH.add(box5); boxH.add(box6); messPanel=new JPanel(); messPanel.add(boxH); JSplitPane splitH=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,messPanel,pic); add(splitH,BorderLayout.CENTER); JPanel pSouth=new JPanel(); pSouth.add(打印文本及照片); pSouth.add(打印文本); pSouth.add(打印照片); add(pSouth,BorderL
27、ayout.SOUTH); validate(); setVisible(false); setSize(360,230); addWindowListener(new WindowAdapter() Override public void windowClosing(WindowEvent e) setVisible(false);); public void actionPerformed(ActionEvent e) if(e.getSource()=查询|e.getSource()=车牌号) String number=; number=车牌号.getText(); if(numbe
28、r.length()0) try inOne=new FileInputStream(systemFile); inTwo=new ObjectInputStream(inOne); 基本信息表=(HashMap)inTwo.readObject(); inOne.close(); inTwo.close(); catch(Exception ee) if(基本信息表.containsKey(number) stu=基本信息表.get(number); 姓名.setText(stu.getName(); 档次.setText(stu.getDiscipling(); 购车公司.setText(
29、stu.getGrade(); 购车时间.setText(stu.getBorth(); if(stu.getSex().equals(男) 男.setSelected(true); else 女.setSelected(true); pic.setImage(stu.getImagePic(); pic.repaint(); 打印文本及照片.setEnabled(true); 打印文本.setEnabled(true); 打印照片.setEnabled(true); else 打印文本及照片.setEnabled(false); 打印文本.setEnabled(false); 打印照片.se
30、tEnabled(false); String warning=该车牌号不存在!; JOptionPane.showMessageDialog(this,warning,警告,JOptionPane.WARNING_MESSAGE); clearMess(); else 打印文本及照片.setEnabled(false); 打印文本.setEnabled(false); 打印照片.setEnabled(false); String warning=必须要输入车牌号!; JOptionPane.showMessageDialog(this,warning,警告, JOptionPane.WARN
31、ING_MESSAGE); else if(e.getSource()=打印文本及照片) try print=getToolkit().getPrintJob(new JFrame(),打印,new Properties(); g=print.getGraphics(); g.translate(120,200); int w=messPanel.getBounds().width; messPanel.printAll(g); g.translate(w,0); pic.printAll(g); 姓名.setText(stu.getName(); g.dispose(); print.end
32、(); catch(Exception exp) else if(e.getSource()=打印文本) try print=getToolkit().getPrintJob(new JFrame(),打印,new Properties(); g=print.getGraphics(); g.translate(120,200); messPanel.printAll(g); g.dispose(); print.end(); catch(Exception exp) else if(e.getSource()=打印照片) try print=getToolkit().getPrintJob(
33、new JFrame(),打印,new Properties(); g=print.getGraphics(); int w=messPanel.getBounds().width; g.translate(120+w,200); pic.printAll(g); g.dispose(); print.end(); catch(Exception exp) public void clearMess() 车牌号.setText(null); 姓名.setText(null); 购车公司.setText(null); 购车时间.setText(null); 档次.setText(null); p
34、ic.setImage(null); pic.repaint(); /3.8Delete类class Delete extends JPanel implements ActionListener HashMap基本信息表=null; JTextField 车牌号,姓名,档次,购车公司,购车时间; JRadioButton 男,女; JButton 删除; ButtonGroup group=null; FileInputStream inOne=null; ObjectInputStream inTwo=null; FileOutputStream outOne=null; ObjectOu
35、tputStream outTwo=null; File systemFile=null; public Delete(File file) systemFile=file; 车牌号=new JTextField(10); 删除=new JButton(删除); 车牌号.addActionListener(this); 删除.addActionListener(this); 姓名=new JTextField(10); 姓名.setEditable(false); 档次=new JTextField(10); 档次.setEditable(false); 购车公司=new JTextField
36、(10); 购车公司.setEditable(false); 购车时间=new JTextField(10); 购车时间.setEditable(false); 男=new JRadioButton(男,false); 女=new JRadioButton(女,false); group=new ButtonGroup(); group.add(男); group.add(女); Box box1=Box.createHorizontalBox(); box1.add(new JLabel(输入要删除的车牌号:,JLabel.CENTER); box1.add(车牌号); box1.add(删
37、除); Box box2=Box.createHorizontalBox(); box2.add(new JLabel(车主姓名:,JLabel.CENTER); box2.add(姓名); Box box3=Box.createHorizontalBox(); box3.add(new JLabel(性别:,JLabel.CENTER); box3.add(男); box3.add(女); Box box4=Box.createHorizontalBox(); box4.add(new JLabel(档次:,JLabel.CENTER); box4.add(档次); Box box5=Box
38、.createHorizontalBox(); box5.add(new JLabel(购车公司:,JLabel.CENTER); box5.add(购车公司); Box box6=Box.createHorizontalBox(); box6.add(new JLabel(购车时间:,JLabel.CENTER); box6.add(购车时间); Box boxH=Box.createVerticalBox(); boxH.add(box1); boxH.add(box2); boxH.add(box3); boxH.add(box4); boxH.add(box5); boxH.add(box6); boxH.add(Box.createVerticalGlue(); JPanel pCenter=new JPanel(); pCenter.add(boxH); setLayout(new BorderLayout(); add(pCenter,BorderLayout.CENTER); validate(); public void actionPerformed(ActionEvent e) if(e.getSource()=删除|e.getSource()=车牌号) S
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年细部收口处理技术方案-城市支路工程
- AHA ACLS 高级心血管生命支持操作指南 2025 中文版 心律失常处理细则
- 多囊卵巢综合征自我管理的注意事项
- 卵巢妊娠破裂护理查房
- 妇科宫腔镜术前术后健康健康教育内容
- 职高中职数学基础模块上册题库
- 紫色炫彩渐变风格演示汇报模板
- 造影宫腔粘连术后护理个案
- 中药学综合知识与技能 历年试题
- 人工流产术后宫腔粘连的临床诊疗方案与长期管理策略
- 江苏常州市常州花园中学等校2026-2027学年八年级上学期数学期中试卷(含答案)
- 2026新版安全领导力管理人员素质与职责培训课件
- 2026年院前急救护士岗位业务考试题库(含答案)
- 2025年度肾内科护理部工作总结及2026年工作规划
- 2026年教师遴选备考试题及答案
- 2026北京市初、中级卫生专业技术资格考试(卫生科研)历年参考题库含答案详解
- 高盛-全球半导体:芯片系列第四篇:中国半导体自给自足建设推进-Global Semis CHIPS IV:China Semis self-sufficiency builds-20260824
- 重度子痫前期合并HELLP综合征个案护理
- (2025)国家电网考试历年真题库(附参考答案)
- 学堂在线 医学英语词汇进阶 期末考试答案
- 北京人口变动趋势预测
评论
0/150
提交评论