版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、/車輛管理系統(tǒng)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<S
6、tring,Car>基本信息表=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(
7、File file) systemFile=file; pic=new CarPicture(); 車牌號=new JTextField(5); 姓名=new JTextField(5); 檔次=new JComboBox(); try FileReader inOne = new FileReader("專業(yè).txt"); BufferedReader inTwo = new BufferedReader(inOne); String s = null; int i=0; while(s=inTwo.readLine()!=null) 檔次.addItem(s); inO
8、ne.close(); inTwo.close(); catch(IOException exp) 檔次.addItem("高級"); 檔次.addItem("中高級"); 檔次.addItem("中級"); 檔次.addItem("中低級"); 檔次.addItem("普通"); 購車公司=new JTextField(5); 購車時間=new JTextField(5); 選擇照片=new JButton("選擇"); group=new ButtonGroup(); 男
9、=new JRadioButton("男",true); 女=new JRadioButton("女",true); group.add(男); group.add(女); 錄入=new JButton("錄入"); 重置=new JButton("重置"); 錄入.addActionListener(this); 選擇照片.addActionListener(this); 重置.addActionListener(this); Box box1=Box.createHorizontalBox(); box1.ad
10、d(new JLabel("車牌號:",JLabel.CENTER); 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.create
11、HorizontalBox(); box4.add(new JLabel("車輛檔次:",JLabel.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
12、 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.green); picPanel.add(new JLabel("選擇照片:",JLabel.CENTER); picPanel.add(
13、選擇照片); 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(); JSplitPane splitV=new JSplitPane(JSplitPane.VERTICAL_SPLIT,picPanel,p
14、ic); 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()=錄入) String number="" number=車牌號.getText(); if(number.length()>
15、0) try inOne =new FileInputStream(systemFile); inTwo =new ObjectInputStream(inOne); 基本信息表=(HashMap<String,Car>)inTwo.readObject(); inOne.close(); inTwo.close(); catch(Exception ee) if(基本信息表.containsKey(number) String warning="該生基本信息已存在,請到修改頁面修改!" JOptionPane.showMessageDialog(this,wa
16、rning, "警告",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)檔次.getSele
17、ctedItem(); String 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(i
18、magePic); try 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
19、,warning,"警告",JOptionPane.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.show
20、OpenDialog(null); File choiceFile=chooser.getSelectedFile(); if(choiceFile!=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)
21、; 姓名.setText(null); 購車公司.setText(null); 購車時間.setText(null); 選擇照片.setText("選擇"); imagePic=null; pic.setImage(imagePic); pic.repaint(); /3.6inquset類class Inquest extends JDialog implements ActionListener CarPicture pic; PrintJob print; Graphics g=null; HashMap<String,Car>基本信息表; JTextFi
22、eld 車牌號,姓名,檔次,購車公司,購車時間; JRadioButton 男,女; JButton 查詢,打印文本及照片,打印文本,打印照片; ButtonGroup group=null; FileInputStream inOne=null; ObjectInputStream inTwo=null; File systemFile=null; JPanel messPanel; Car stu; public Inquest(File file) setTitle("查詢對話框"); setModal(false); systemFile=file; pic =ne
23、w CarPicture(); 車牌號=new JTextField(6); 查詢=new JButton("查詢"); 車牌號.addActionListener(this); 查詢.addActionListener(this); 打印文本及照片=new JButton("打印文本及照片"); 打印文本=new JButton("打印文本"); 打印照片=new JButton("打印照片"); 打印文本及照片.addActionListener(this); 打印文本.addActionListener(th
24、is); 打印照片.addActionListener(this); 打印文本及照片.setEnabled(false); 打印文本.setEnabled(false); 打印照片.setEnabled(false); 姓名=new JTextField(5); 姓名.setEditable(false); 檔次=new JTextField(5); 檔次.setEditable(false); 購車公司=new JTextField(5); 購車公司.setEditable(false); 購車時間=new JTextField(5); 購車時間.setEditable(false); 男=
25、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(查詢); Box box2=Box.createHorizontalBox(); box2.add(new
26、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.createHorizontal
27、Box(); 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); box
28、H.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,BorderLayout.SOUTH); validate(); set
29、Visible(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(number.length()>0) t
30、ry inOne=new FileInputStream(systemFile); inTwo=new ObjectInputStream(inOne); 基本信息表=(HashMap<String,Car>)inTwo.readObject(); inOne.close(); inTwo.close(); catch(Exception ee) if(基本信息表.containsKey(number) stu=基本信息表.get(number); 姓名.setText(stu.getName(); 檔次.setText(stu.getDiscipling(); 購車公司.setT
31、ext(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
32、(false); 打印照片.setEnabled(false); String warning="該車牌號不存在!" JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE); clearMess(); else 打印文本及照片.setEnabled(false); 打印文本.setEnabled(false); 打印照片.setEnabled(false); String warning="必須要輸入車牌號!" JOptionPane.s
33、howMessageDialog(this,warning,"警告", JOptionPane.WARNING_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.transla
34、te(w,0); pic.printAll(g); 姓名.setText(stu.getName(); g.dispose(); print.end(); 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()
35、; catch(Exception exp) else if(e.getSource()=打印照片) try print=getToolkit().getPrintJob(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(
36、) 車牌號.setText(null); 姓名.setText(null); 購車公司.setText(null); 購車時間.setText(null); 檔次.setText(null); pic.setImage(null); pic.repaint(); /3.8Delete類class Delete extends JPanel implements ActionListener HashMap<String,Car>基本信息表=null; JTextField 車牌號,姓名,檔次,購車公司,購車時間; JRadioButton 男,女; JButton 刪除; Butt
37、onGroup group=null; FileInputStream inOne=null; ObjectInputStream inTwo=null; FileOutputStream outOne=null; ObjectOutputStream outTwo=null; File systemFile=null; public Delete(File file) systemFile=file; 車牌號=new JTextField(10); 刪除=new JButton("刪除"); 車牌號.addActionListener(this); 刪除.addActio
38、nListener(this); 姓名=new JTextField(10); 姓名.setEditable(false); 檔次=new JTextField(10); 檔次.setEditable(false); 購車公司=new JTextField(10); 購車公司.setEditable(false); 購車時間=new JTextField(10); 購車時間.setEditable(false); 男=new JRadioButton("男",false); 女=new JRadioButton("女",false); group=new
39、 ButtonGroup(); group.add(男); group.add(女); Box box1=Box.createHorizontalBox(); box1.add(new JLabel("輸入要刪除的車牌號:",JLabel.CENTER); box1.add(車牌號); box1.add(刪除); Box box2=Box.createHorizontalBox(); box2.add(new JLabel("車主姓名:",JLabel.CENTER); box2.add(姓名); Box box3=Box.createHorizonta
40、lBox(); 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 bo
41、x6=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()=車牌號) Strin
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年岳麓版選擇性必修三歷史上冊階段測試試卷
- 景區(qū)周邊房屋租賃協(xié)議(2篇)
- 機關事業(yè)單位合同范本(2篇)
- 服裝制造公司合并合同(2篇)
- 2025年宿遷職業(yè)技術學院高職單招數(shù)學歷年(2016-2024)頻考點試題含答案解析
- 2025年安徽綠海商務職業(yè)學院高職單招職業(yè)技能測試近5年??及鎱⒖碱}庫含答案解析
- 2025年天津海運職業(yè)學院高職單招數(shù)學歷年(2016-2024)頻考點試題含答案解析
- 2025年吉林工業(yè)職業(yè)技術學院高職單招語文2018-2024歷年參考題庫頻考點含答案解析
- 2025年北京網(wǎng)絡職業(yè)學院高職單招語文2018-2024歷年參考題庫頻考點含答案解析
- 2025至2031年中國紡織工具配件行業(yè)投資前景及策略咨詢研究報告
- 2025年包裝印刷項目可行性研究報告
- 企業(yè)融資報告特斯拉成功案例分享
- 給客戶的福利合同(2篇)
- 銷售調(diào)味品工作總結5篇
- 2024年江蘇省勞動合同條例
- 供電企業(yè)輿情的預防及處置
- 【高中語文】《氓》課件++統(tǒng)編版+高中語文選擇性必修下冊
- T-WAPIA 052.3-2023 無線局域網(wǎng)設備技術規(guī)范 第3部分:接入點和控制器
- 運動技能學習與控制完整
- Unit4MyfamilyStorytime(課件)人教新起點英語三年級下冊
- 財務管理專業(yè)《生產(chǎn)實習》教學大綱
評論
0/150
提交評論