南昌大学JAVA课程设计班级管理系统Word文件下载.docx
- 文档编号:16689800
- 上传时间:2022-11-25
- 格式:DOCX
- 页数:41
- 大小:509.89KB
南昌大学JAVA课程设计班级管理系统Word文件下载.docx
《南昌大学JAVA课程设计班级管理系统Word文件下载.docx》由会员分享,可在线阅读,更多相关《南昌大学JAVA课程设计班级管理系统Word文件下载.docx(41页珍藏版)》请在冰豆网上搜索。
为了便于录入专业信息,本学籍管理系统使用了一个名字为“专业.txt”的文件,文件的每一行为一个专业的名称。
例子如下:
(二)ManagerWindow类
a)效果图:
b)UML图
c)代码
packageclassManager;
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
importjava.io.*;
@SuppressWarnings("
serial"
)
publicclassManagerWindowextendsJFrameimplementsActionListener{
InputClassbaseinput;
ModifySituationbasemodify;
Deletebaseremove;
Inquestbasesearchprint;
JMenuBarbar;
JMenufileMenu;
JMenuIteminput,modify,searchprint,remove,welcome;
Filefile=null;
FlowLayoutflow=null;
JLabellabel=null;
JPanelpCenter;
publicManagerWindow(){
super("
班级管理系统"
);
file=newFile("
K:
\\BaseInformation.txt"
//改盘符路径
input=newJMenuItem("
录入班级基本信息"
modify=newJMenuItem("
修改班级基本信息"
searchprint=newJMenuItem("
查询班级基本信息"
remove=newJMenuItem("
删除班级基本信息"
welcome=newJMenuItem("
欢迎界面"
bar=newJMenuBar();
fileMenu=newJMenu("
菜单选项"
fileMenu.add(input);
fileMenu.add(modify);
fileMenu.add(searchprint);
fileMenu.add(remove);
fileMenu.add(welcome);
bar.add(fileMenu);
setJMenuBar(bar);
label=newJLabel("
JLabel.CENTER);
label.setIcon(newImageIcon("
welcome1.jpg"
));
label.setFont(newFont("
隶书"
Font.BOLD,40));
label.setHorizontalTextPosition(SwingConstants.CENTER);
label.setForeground(Color.red);
input.addActionListener(this);
modify.addActionListener(this);
searchprint.addActionListener(this);
remove.addActionListener(this);
welcome.addActionListener(this);
flow=newFlowLayout();
pCenter=newJPanel();
pCenter.setLayout(flow);
if(!
file.exists()){
try{
FileOutputStreamout=newFileOutputStream(file);
PrintStreamp=newPrintStream(out);
p.println("
BaseInformation"
p.close();
out.close();
}catch(IOExceptione){
}
}
pCenter.add(label);
add(pCenter,BorderLayout.CENTER);
validate();
setVisible(true);
setBounds(100,50,460,280);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
addWindowListener(newWindowAdapter(){
publicvoidwindowClosing(WindowEvente){
intn=JOptionPane.showConfirmDialog(null,"
确认退出么?
"
"
确认对话框"
JOptionPane.YES_NO_OPTION);
if(n==JOptionPane.YES_NO_OPTION)
System.exit(0);
});
}
publicvoidactionPerformed(ActionEvente){
if(e.getSource()==input){
baseinput=newInputClass(file);
baseinput.setLocation(getBounds().x+getBounds().width,
getBounds().y);
baseinput.setVisible(true);
}elseif(e.getSource()==modify){
basemodify=newModifySituation(file);
basemodify.setLocation(getBounds().x+getBounds().width,
if(e.getSource()==searchprint){
basesearchprint=newInquest(file);
basesearchprint.setLocation(getBounds().x+getBounds().width,
basesearchprint.setVisible(true);
}elseif(e.getSource()==remove){
baseremove=newDelete(file);
baseremove.setLocation(getBounds().x+getBounds().width,
elseif(e.getSource()==welcome){
newManagerWindow();
publicstaticvoidmain(Stringargs[]){
newManagerWindow();
}
(三)Class类
a)UML图
Class类所创建的对象是InputStudent类成员之一,负责封装班主任的基本信息
b)代码
publicclassClassimplementsSerializable{
Stringclassnumber,headteacher,college,discipling,population,imagePicPath;
publicClass(Stringclassnumber,Stringheadteacher,Stringcollege,
Stringdiscipling,Stringpopulation,StringimagePicPath){
super();
this.classnumber=classnumber;
this.headteacher=headteacher;
this.college=college;
this.discipling=discipling;
this.population=population;
this.imagePicPath=imagePicPath;
publicClass(){
//TODOAuto-generatedconstructorstub
publicStringgetHeadteacher(){
returnheadteacher;
publicvoidsetHeadteacher(Stringheadteacher){
publicvoidsetNumber(Stringnumber){
this.classnumber=number;
publicStringgetNumber(){
returnclassnumber;
publicvoidsetName(Stringname){
this.headteacher=name;
publicStringgetName(){
publicvoidsetCollege(Stringcollege){
this.college=college;
publicStringgetCollege(){
returncollege;
publicvoidsetDiscipling(Stringdiscipling){
this.discipling=discipling;
publicStringgetDiscipling(){
returndiscipling;
publicvoidsetPopulation(Stringpopulation){
this.population=population;
publicStringgetPopulation(){
returnpopulation;
publicvoidsetImagePic(StringimagePicPath){
publicStringgetImagePic(){
returnimagePicPath;
(四)TeacherPicture类
a)效果图
b)UML图
该类创建的对象负责绘制学生的照片,效果如图所示。
c)代码
publicclassTeacherPictureextendsJPanel{
FileimageFile;
Toolkittool;
publicTeacherPicture(){
tool=getToolkit();
publicvoidsetImage(FileimageFile){
this.imageFile=imageFile;
repaint();
publicvoidpaintComponent(Graphicsg){
super.paintComponent(g);
intw=getBounds().width;
inth=getBounds().height;
if(imageFile!
=null){
Imageimage=tool.getImage(imageFile.getAbsolutePath());
g.drawImage(image,0,0,w,h,this);
else
g.drawString("
没有选择图片"
10,30);
(五)InputClass类
该类所穿件的对象是ManagerWindow类的重要成员之一,负责提供录入班级基本信息的界面。
importjava.util.HashMap;
importjavax.swing.filechooser.*;
publicclassInputClassextendsJFrameimplementsActionListener{
Classtec=null;
JPanelpanel;
TeacherPicturepic;
HashMap<
String,Class>
BaseInformation=newHashMap<
();
JTextFieldclassnumber,headteacher,population;
JButtonselectpic;
JComboBoxcollege,discipling;
Stringcollege1[]={"
信工学院"
"
人文学院"
建筑学院"
};
JButtoninput,reset;
RandomAccessFilein=null;
RandomAccessFileout=null;
FilesystemFile,imagePic;
Stringpath=null;
Containerc;
Stringnumber="
;
Stringname=null;
//存放班主任名
publicInputClass(Filefile){
录入班级基本信息对话框"
systemFile=file;
c=getContentPane();
panel=newJPanel(newBorderLayout());
tec=newClass();
//
pic=newTeacherPicture();
classnumber=newJTextField(5);
headteacher=newJTextField(5);
discipling=newJComboBox();
try{
FileReaderinOne=newFileReader("
专业.txt"
BufferedReaderinTwo=newBufferedReader(inOne);
Strings=null;
while((s=inTwo.readLine())!
=null)
discipling.addItem(s);
inOne.close();
inTwo.close();
catch(IOExceptionexp){
discipling.addItem("
网络工程"
计算机科学与技术"
数字媒体技术"
卓越工程师"
college=newJComboBox(college1);
population=newJTextField(5);
selectpic=newJButton("
选择"
input=newJButton("
录入"
reset=newJButton("
重置"
selectpic.addActionListener(this);
reset.addActionListener(this);
Boxbox1=Box.createHorizontalBox();
box1.add(newJLabel("
班号"
JLabel.CENTER));
box1.add(classnumber);
Boxbox2=Box.createHorizontalBox();
box2.add(newJLabel("
班主任"
box2.add(headteacher);
Boxbox3=Box.createHorizontalBox();
box3.add(newJLabel("
学院"
box3.add(college);
Boxbox4=Box.createHorizontalBox();
box4.add(newJLabel("
专业"
box4.add(discipling);
Boxbox5=Box.createHorizontalBox();
box5.add(newJLabel("
人数"
box5.add(population);
BoxboxH=Box.createVerticalBox();
boxH.add(box1);
boxH.add(box2);
boxH.add(box3);
boxH.add(box4);
boxH.add(box5);
boxH.add(Box.createVerticalGlue());
JPanelpicPanel=newJPanel();
picPanel.setBackground(Color.green);
picPanel.add(newJLabel("
选择照片"
),JLabel.CENTER);
picPanel.add(selectpic);
JPanelputButton=newJPanel();
putButton.add(input);
putButton.add(reset);
JPanelmessPanel=newJPanel();
messPanel.add(boxH);
messPanel.setBackground(Color.green);
putButton.setBackground(Color.yellow);
setLayout(newBorderLayout());
JSplitPanesplitV=newJSplitPane(JSplitPane.VERTICAL_SPLIT,picPanel,pic);
JSplitPanesplitH=newJSplitPane(JSplitPane.HORIZONTAL_SPLIT,messPanel,splitV);
panel.add(splitH,BorderLayout.CENTER);
panel.add(putButton,BorderLayout.SOUTH);
c.add(panel);
setSize(360,300);
addWindowListener(newWindowAdapter(){
publicvoidwindowClosing(WindowEvente){
setVisible(false);
publicvoidactionPerformed(ActionEvente){
name=headteacher.getText();
number=classnumber.getText();
if(e.getSource()==input){
System.out.println(number);
if(number.length()>
0)
{
Classtemp;
Stringinf=null;
String[]s2=newString[6];
try{
RandomAccessFilein=newRandomAccessFile(systemFile,
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 南昌大学 JAVA 课程设计 班级 管理 系统