⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addstudinfopanel.java

📁 您的文件包然后写出其具体功能(至少要20个字)。尽量不要让站长把时间都花费在为您
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 5;
		gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(jLabel11, gridBagConstraints);

		jLabel12.setFont(new java.awt.Font("宋体", 0, 14));
		jLabel12.setText("\u79cd\u65cf");
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 2;
		gridBagConstraints.gridy = 5;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(jLabel12, gridBagConstraints);

		jLabel13.setFont(new java.awt.Font("宋体", 0, 14));
		jLabel13.setText("\u8eab\u4efd\u8bc1");
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 7;
		gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(jLabel13, gridBagConstraints);

		jLabel14.setFont(new java.awt.Font("宋体", 0, 14));
		jLabel14.setText("\u5165\u5b66\u65f6\u95f4");
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 8;
		gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(jLabel14, gridBagConstraints);

		begintime.setColumns(20);
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 1;
		gridBagConstraints.gridy = 8;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(begintime, gridBagConstraints);

		name.setColumns(20);
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 1;
		gridBagConstraints.gridy = 2;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(name, gridBagConstraints);

		ok.setText("\u786e\u5b9a");
		ok.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				okActionPerformed(evt);
			}
		});
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 10;
		gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(ok, gridBagConstraints);

		age.setColumns(20);
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 3;
		gridBagConstraints.gridy = 4;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(age, gridBagConstraints);

		studentid.setColumns(20);
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 1;
		gridBagConstraints.gridy = 3;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(studentid, gridBagConstraints);

		year.setColumns(20);
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 1;
		gridBagConstraints.gridy = 6;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(year, gridBagConstraints);

		java.util.List<ClassInfo> list=null;
		ClassDao classdao=new ClassDao();
		list=classdao.getAllClass();
		Iterator<ClassInfo> iter=list.iterator();
		while(iter.hasNext())//这里的Iterator因为已经设定了<ClassInfo>,所以iter.next()不用强制转化为ClassInfo;
			classid.addItem(iter.next().getClassID());
		classid.setPreferredSize(new java.awt.Dimension(130, 23));
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 1;
		gridBagConstraints.gridy = 5;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(classid, gridBagConstraints);

		sex.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "男",
		"女" }));
		
		sex.setPreferredSize(new java.awt.Dimension(130, 23));
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 1;
		gridBagConstraints.gridy = 4;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(sex, gridBagConstraints);

		jLabel15.setBorder(javax.swing.BorderFactory
				.createLineBorder(new java.awt.Color(0, 0, 0)));
		jLabel15.setPreferredSize(new java.awt.Dimension(125, 140));
		jLabel15.setText("photo");
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 4;
		gridBagConstraints.gridy = 2;
		gridBagConstraints.gridwidth = 3;
		gridBagConstraints.gridheight = 3;
		gridBagConstraints.weightx = 5.0;
		add(jLabel15, gridBagConstraints);

		photo.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				photoActionPerformed(evt);
			}
		});
		
		photo.setText("\u63d2\u5165\u76f8\u7247");
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 4;
		gridBagConstraints.gridy = 5;
		gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(photo, gridBagConstraints);

		family.setColumns(20);
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 3;
		gridBagConstraints.gridy = 5;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(family, gridBagConstraints);

		day.setColumns(20);
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 5;
		gridBagConstraints.gridy = 6;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(day, gridBagConstraints);

		identification.setColumns(20);
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 1;
		gridBagConstraints.gridy = 7;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(identification, gridBagConstraints);

		month.setColumns(20);
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 3;
		gridBagConstraints.gridy = 6;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(month, gridBagConstraints);

		jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(
				null, "\u8bf4\u660e",
				javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
				javax.swing.border.TitledBorder.DEFAULT_POSITION,
				new java.awt.Font("宋体", 0, 12), new java.awt.Color(0, 0, 0)));
		jScrollPane1.setPreferredSize(new java.awt.Dimension(600, 120));

		jTextArea1.setColumns(20);
		jTextArea1.setRows(5);
		jScrollPane1.setViewportView(jTextArea1);

		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 9;
		gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
		gridBagConstraints.weightx = 5.0;
		gridBagConstraints.weighty = 0.1;
		add(jScrollPane1, gridBagConstraints);
	}

	private void photoActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
		JFileChooser chooser = new JFileChooser();
	    FileNameExtensionFilter filter = new FileNameExtensionFilter(
	        "JPG & GIF Images", "jpg", "gif");
	    chooser.setFileFilter(filter);
	    int returnVal = chooser.showOpenDialog(null);
	    if(returnVal == JFileChooser.APPROVE_OPTION){
	         lujin=chooser.getSelectedFile().getPath();
	         ImageIcon image=new ImageIcon(lujin.trim());
				image.setImage(image.getImage().getScaledInstance(150, 200,Image.SCALE_DEFAULT));
				jLabel15.setIcon(image);
				jLabel15.setText("");
	         //jLabel15.setIcon(new ImageIcon(lujin.trim()));
	    }
	}
	
	private void okActionPerformed(java.awt.event.ActionEvent evt) {
		if(studentid.getText().equals("")||age.getText().equals("")
				||sex.getSelectedItem().equals("")||identification.getText().equals("")
				||classid.getSelectedItem().equals("")||name.getText().equals("")
				||family.getText().equals("")||begintime.getText().equals("")){
			JOptionPane.showMessageDialog(null, "请填好资料");
			return ;
		}
		StudentInfoDao studentinfodao=new StudentInfoDao();
		StudentSroceDao studentsrocedao=new StudentSroceDao();
		StudentInfo studentinfo=new StudentInfo();
		StudentSroce studentsroce=new StudentSroce();
		CourseClassDao courseclassdao=new CourseClassDao();
		List<Course> courselist=courseclassdao.getCourseForClass((String)classid.getSelectedItem());
		Iterator<Course> iter=courselist.iterator();
		while(iter.hasNext()){
			studentsroce.setClassID(classid.getSelectedItem().toString().trim());
			studentsroce.setCourseName(iter.next().getCourseName());
			studentsroce.setStudentID(studentid.getText().trim());
			//studentsroce.setSroce(0.0);
			studentsrocedao.addSroce(studentsroce);
		}
		studentinfo.SetStudentID(studentid.getText().trim());
		studentinfo.SetStudentName(name.getText().trim());
		studentinfo.SetAge(age.getText().trim());
		studentinfo.SetSex(sex.getSelectedItem().toString().trim());
		studentinfo.SetClassID(classid.getSelectedItem().toString().trim());
		studentinfo.SetFamily(family.getText().trim());
		studentinfo.SetBirthday(year.getText().trim()
				+"-"+month.getText().trim()+"-"+day.getText().trim());
		studentinfo.SetIdentification(identification.getText().trim());
		studentinfo.setBeginTime(begintime.getText().trim());
		studentinfo.SetRemarks(jTextArea1.getText().trim());
		if(lujin!=null){
			try{
				studentinfo.SetOLEPhoto(new FileInputStream(lujin.trim()));
			}catch(IOException e){
				e.printStackTrace();
				JOptionPane.showMessageDialog(null, "对不起,获取图片失败,由于选择路径不对,请重新选择!");
			}
		}
		studentinfodao.addStudentInfo(studentinfo);
	}
	
	private String lujin;
	private javax.swing.JTextField age;
	private javax.swing.JTextField begintime;
	private javax.swing.JComboBox classid;
	private javax.swing.JTextField day;
	private javax.swing.JTextField family;
	private javax.swing.JTextField identification;
	private javax.swing.JButton jButton1;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel11;
	private javax.swing.JLabel jLabel12;
	private javax.swing.JLabel jLabel13;
	private javax.swing.JLabel jLabel14;
	private javax.swing.JLabel jLabel15;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JLabel jLabel3;
	private javax.swing.JLabel jLabel4;
	private javax.swing.JLabel jLabel5;
	private javax.swing.JLabel jLabel6;
	private javax.swing.JLabel jLabel7;
	private javax.swing.JLabel jLabel8;
	private javax.swing.JLabel jLabel9;
	private javax.swing.JScrollPane jScrollPane1;
	private javax.swing.JTextArea jTextArea1;
	private javax.swing.JTextField month;
	private javax.swing.JTextField name;
	private javax.swing.JButton ok;
	private javax.swing.JButton photo;
	private javax.swing.JComboBox sex;
	private javax.swing.JTextField studentid;
	private javax.swing.JTextField year;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -