1、 this .number=number;public String getNumber() return number;public void setName( String name)( this .name=name;)public String getName()( return name;public void setDiscipling( String discipling)( this .discipling=discipling;public String getDiscipling()( return discipling;public void setGrade( Stri
2、ng grade)( this .grade=grade;public String getGrade()( return grade;public void setBorth( String borth)( this .borth=borth;public String getBorth()( return borth;public void setSex( String sex)( this .sex=sex;public String getSex()( return sex;public void setImagePic( File image)( imagePic=image;pub
3、lic File getImagePic()( return imagePic;/3.5InputCar 类class InputCar extends JPanel implements ActionListener( Car 车主=null ;CarPicture pic;HashMap 基本信息表=null ;JTextField 车牌号,姓名,购车公司,购车时间;JButton 选择照片;JComboBox 档次;JRadioButton 男,女;ButtonGroup group= null ;JButton 录入,重置;FileInputStream inOne= null ;Ob
4、jectInputStream inTwo= null ;FileInputStream outOne= null ;ObjectOutputStream outTwo= null ;File systemFile,imagePic;public InputCar( File file) systemFile=file;pic= newCarPicture();车牌号=new JTextField(5);姓名=new JTextField(5);档次=new JComboBox();try FileReader inOne = new FileReader (专业.txt);BufferedR
5、eader inTwo = new BufferedReader (inOne);String s = null ;int i=0;while (s=inTwo.readLine()!档次.addItem(s);inOne.close();inTwo.close();catch (IOException exp)档次.addItem(高级中高级”);中级中低级普通购车公司=new JTextField(5);购车时间=new JTextField(5);选择照片=new JButton(选择group= new ButtonGroup();男=new JRadioButton(男,true )
6、;女=new JRadioButton(女group.add( 男);group.add( 女);录入=new JButton(录入重置=new JButton(重置录入.addActionListener( this );选择照片.addActionListener( this );重置.addActionListener( this );Box box1=Box.createHorizontalBox();box1.add( new JLabel(“车牌号:,JLabel.CENTER);box1.add( 车牌号);Box box2=Box.createHorizontalBox();b
7、ox2.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(车辆档次:box4.add( 档次);Box box5=Box.createHorizontalBox();box5.add( new JLabel(购车公司:box5
8、.add( 购车公司);Box box6=Box.createHorizontalBox();box6.add( new JLabel(购车时间: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= newJPanel();picPanel.setBackground( C
9、olor .green);picPanel.add( new JLabel(选择照片: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 ();JSplitPane
10、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()= 录入)(String n
11、umber=;number= 车牌号.getText();if (number.length()0)try inOne = new FileInputStream (systemFile);inTwo = new ObjectInputStream (inOne);基本信息表=(HashMap)inTwo.readObject();catch (Exception ee)if (基本信息表.containsKey(number)String warning=该生基本信息已存在,请到修改页面修改! ”;JOptionPane.showMessageDialog( this ,warning, 警
12、告”,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();String grade=购车公司.getText();
13、String borth=购车时间.getText();String sex= null ;if (男.isSelected()sex= 男.getText();elsesex= 女.getText();车主=newCar();车主.setNumber(number);车主.setName(name);车主.setDiscipling(discipling);车主.setGrade(grade);车主.setBorth(borth);车主.setSex(sex);车主.setImagePic(imagePic);try FileOutputStream outOne= newFileOutpu
14、tStream (systemFile);outTwo= new ObjectOutputStream (outOne);基本信息表.put(number, 车主);outTwo.writeObject( 基本信息表);outTwo.close(); outOne.close(); clearMess(); ) catch ( Exception ee) ) ) ) else String warning=必须要输入学号! JOptionPane.showMessageDialog( this ,warning,”警告 ) ) else if (e.getSource()=选择照片) JFil
15、eChooser chooser= new JFileChooser(); FileNameExtensionFilter filter= newFileNameExtensionFilter( JPG&GIFImages, jpg , gif chooser.setFileFilter(filter); int state=chooser.showOpenDialog( null ); File choiceFile=chooser.getSelectedFile(); if (choiceFile!= null &state=JFileChooser.APPROVE_OPTION) 选择照
16、片.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( imagePic= null ;pic.setImage(imagePi
17、c);/3.6inquset 类class Inquest extends JDialog implements ActionListener ( CarPicture pic;PrintJob print;Graphics g= null ; 基本信息表;JTextField 车牌号,姓名,档次,购车公司,购车时间;JRadioButton 男,女;JButton 查询,打印文本及照片,打印文本,打印照片;File systemFile= null ;JPanel messPanel;Car stu;public Inquest( File file)(setTitle( ”查询对话框”);
18、setModal( false );systemFile=file;pic = newCarPicture();车牌号=new JTextField(6);查询=newJButton(查询车牌号.addActionListener( this );查询.addActionListener( this );打印文本及照片=new JButton(打印文本及照片”);打印文本=newJButton(打印文本);打印照片=newJButton(打印照片打印文本及照片.addActionListener( this );打印文本.addActionListener( this );打印照片.addAc
19、tionListener( 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
20、(车牌号);box1.add( 查询);box2.add( new JLabel(车主姓名:box2.add(姓名);性另U: JLabel.CENTER);box3.add(男);box3.add(女);档次:box4.add(档次);messPanel= new JPanel();JSplitPane splitH= new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,messPanel,pic);JPanel pSouth= new JPanel();pSouth.add( 打印文本及照片);pSouth.add(打印文本);pSouth.add( 打印
21、照片);add(pSouth, BorderLayout .SOUTH);setVisible( false );setSize(360,230);addWindowListener( new WindowAdapter ()public void windowClosing( WindowEvent e);public void actionPerformed( ActionEvent e)if (e.getSource()=查询 |e.getSource()= 车牌号)inOne= new FileInputStream (systemFile);inTwo= new ObjectInpu
22、tStream (inOne);catch (Exception ee)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
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1