Java试验课题.docx

上传人:b****3 文档编号:4470215 上传时间:2022-12-01 格式:DOCX 页数:18 大小:455.61KB
下载 相关 举报
Java试验课题.docx_第1页
第1页 / 共18页
Java试验课题.docx_第2页
第2页 / 共18页
Java试验课题.docx_第3页
第3页 / 共18页
Java试验课题.docx_第4页
第4页 / 共18页
Java试验课题.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

Java试验课题.docx

《Java试验课题.docx》由会员分享,可在线阅读,更多相关《Java试验课题.docx(18页珍藏版)》请在冰豆网上搜索。

Java试验课题.docx

Java试验课题

importjavax.swing.*;

importjava.awt.*;

importjava.awt.event.*;

importjava.io.*;

publicclassDiaoChaextendsJFrameimplementsActionListener{

JLabelheadLab=newJLabel("对学习网络课程调查表");

Object[]each={

newEachPanel("","","","",0),

newEachPanel("1.你学习网络课程,主要是应为","想提高自身能力","以后工作的需要","对这个专业非常感兴趣",0),

newEachPanel("2.你每个星期大约有多少时间上网","3小时以下","3-6小时","6小时以上",1),

newEachPanel("3.你每个星期上网用于学习的时间?

","3小时以下","3-6小时","6小时以上",1),

newEachPanel("4.下列各种虚席资料中,你最愿意使用的是:

","多媒体教学光盘","教科书等文字教材","网上教学课程",1),

newEachPanel("5.你认为我们现有的课程中教师讲解视频部分该作何改进?

","很好,不用改进","只需保留声音,不要视频","增加视频中课堂的氛围",0),

newEachPanel("6.你是否认为课程中教师讲解是必不可少的?

","必不可少","可以去掉","有时需要",1),

newEachPanel("7.在播放视频时,随着教师的讲解过程,你认为有必要同步呈现的内容有","教师PPT讲稿","相关的图片资料","相关的Flash动画",0),

newEachPanel("8.你认为我们现有的课程中Flash动画","动画太少","对学习帮助不大","对学习有一定的帮助",1),

newEachPanel("9.你认为我们现在的课程讲解文字部分该作何改进?

","很好,不用改进","简化内容,只保留提纲","",0),

newEachPanel("10.你认为现有课程的界面是否需要改进?

","很好,不用改进","界面应更美观","各课程的界面风格应统一",0),

newOtherPanel("11.你认为在课程汇总使用各种媒体","越多越好","越少越好","不用最好","随便",""),

newOtherPanel("12.你认为现有课程左下方的栏目菜单是否需要改进?

","很好,使用方便,不用改进","简化内容即可","菜单应更美观","各个菜单的风格应该统一",""),

newOtherPanel("13.你认为对学习最有效的交流沟通方式是:

","网上同学之间的交流","面对面地与同学交流","网上与专业教师交流","",""),

newOtherPanel("14.你希望在教学中应用课题式教学、案例教学等模式吗?

","是的","不是的","","",""),

newOtherPanel("15.你是否希望在学习进程中能有更多机会经行网上自测,以检查自己的学习情况?

","是的","不是的","","",""),

};

Containercp=getContentPane();

JPaneljp1=newJPanel();

JPaneljp=newJPanel();

JScrollPanejsp1=newJScrollPane(jp);

JPaneljp2=newJPanel();

JTextAreajta=newJTextArea(50,50);

JScrollPanejsp2=newJScrollPane(jta);

Buttonokbtn=newButton("提交");

Buttoncanbtn=newButton("取消");

publicDiaoCha(){

super("问卷调查系统");

jp.setPreferredSize(newDimension(680,940));

jp.setLayout(null);

jp.add(headLab);

for(inti=1;i<16;i++){

jp.add((JPanel)each[i]);

((JPanel)each[i]).setLocation(0,50*(i-1)+30);

}

jta.setWrapStyleWord(true);

jta.setLineWrap(true);

jta.setEditable(true);

jsp2.setBounds(10,800,500,100);

okbtn.setForeground(Color.BLUE);

canbtn.setForeground(Color.BLUE);

okbtn.setBounds(530,810,50,30);

canbtn.setBounds(530,860,50,30);

okbtn.addActionListener(this);

canbtn.addActionListener(this);

jp.add(jsp2);

jp.add(okbtn);

jp.add(canbtn);

add(jsp1);

headLab.setBounds(250,5,250,20);

headLab.setFont(newFont("楷体",Font.BOLD,20));

setVisible(true);

setResizable(false);

setBounds(340,100,730,600);

}

publicvoidactionPerformed(ActionEvente){

if(e.getSource()==okbtn){

Stringstr="";

booleancanReturn=true;

try{

FileWriterfw=newFileWriter(newFile("text1.txt"));

BufferedWriterbfw=newBufferedWriter(fw);

for(inti=1;i<30;i++){

bfw.write('');

}

bfw.write(headLab.getText(),0,headLab.getText().length());

bfw.newLine();

bfw.flush();

for(inti=1;i<=15;i++){

if(each[i]instanceofEachPanel){

((EachPanel)each[i]).getAnswer();

if(((EachPanel)each[i]).flag){

JOptionPane.showMessageDialog(this,"您第"+i+"题未选择,无法提交","错误",JOptionPane.ERROR_MESSAGE);

canReturn=false;

}

}

}

if(canReturn){

for(inti=1;i<=15;i++){

if(each[i]instanceofEachPanel){

str=((EachPanel)each[i]).getAnswer();

}else{

str=((OtherPanel)each[i]).getAnswer();

}

bfw.write(str,0,str.length());

bfw.newLine();

bfw.flush();

}

bfw.newLine();

bfw.write("建议:

",0,"建议:

".length());

bfw.newLine();

intlen=jta.getText().length();

for(intstart=0;start<=len;start=start+10){

bfw.write(jta.getText(),start,20);

bfw.newLine();

bfw.flush();

}

bfw.newLine();

bfw.flush();

bfw.close();

}

}catch(Exceptionee){}

if(canReturn){

JOptionPane.showMessageDialog(this,"提交成功,谢谢您的参与!

(调查结果保持在本文件夹的Text1.txt中)","提示",JOptionPane.PLAIN_MESSAGE);

dispose();

}

}if(e.getSource()==canbtn){

JOptionPane.showMessageDialog(this,"您取消了此次调查,系统将关闭,谢谢!

","提示",JOptionPane.PLAIN_MESSAGE);

dispose();

}

}

//publicstaticvoidmain(Stringargs[]){

//newDiaoCha();

//}

}

 

packagemysql;

importjava.awt.*;

importjava.awt.event.*;

importjava.sql.*;

importjavax.swing.*;

classLoginextendsJFrame

{

privatestaticfinallongserialVersionUID=1L;

privatestaticJFrameframe=newJFrame("学生饭卡管理系统登录界面");

privateJButtonsubmit=newJButton("登陆");

privateJButtonreset=newJButton("重置");

privateJButtonassign=newJButton("注册");

JLabelnameLab=newJLabel("用户名:

");

privateJLabelpasswdLab=newJLabel("密码:

");

privateJLabellab=newJLabel();

publicJTextFieldnameText=newJTextField(20);

publicJPasswordFieldpasswdText=newJPasswordField(20);

publicLogin(){}

publicvoidlogin(){

nameLab.setBounds(60,20,100,20);

passwdLab.setBounds(60,50,100,20);

lab.setBounds(100,90,200,20);

nameText.setBounds(120,20,100,20);

passwdText.setBounds(120,50,100,20);

submit.setBounds(120,120,100,30);

reset.setBounds(250,50,60,20);

assign.setBounds(250,20,60,20);

passwdText.setEchoChar('*');

frame.add(nameLab);

frame.add(passwdLab);

frame.add(lab);

frame.add(nameText);//用户名

frame.add(passwdText);//用户密码

frame.add(submit);

frame.add(reset);

frame.add(assign);

frame.setSize(400,220);

frame.setLocation(400,250);

ImagePanelimg=newImagePanel();

img.setBounds(0,0,400,200);

frame.add(img);

frame.setVisible(true);

submit.addActionListener(newActionListener(){

publicvoidactionPerformed(ActionEvente){

@SuppressWarnings("deprecation")

Stringpasswd=passwdText.getText();

Stringname=nameText.getText();

try{

ResultSetsqlRst=null;

Class.forName("com.mysql.jdbc.Driver");

Connectionconn=DriverManager.getConnection("jdbc:

mysql:

//localhost:

3306/test1","root","123456");

Statementst=conn.createStatement();

Stringsql="select*fromuserwhereuserNo='"+name+"'andpasswd='"+passwd+"';";

sqlRst=st.executeQuery(sql);

if(sqlRst.next()){

newFankajiemain();

frame.dispose();

}

else{

lab.setForeground(Color.red);

lab.setText("登陆失败!

密码或账号错误!

");

}

}catch(ClassNotFoundExceptione1){

e1.printStackTrace();

}catch(SQLExceptione1){

//TODOAuto-generatedcatchblock

e1.printStackTrace();

}

}

});

assign.addActionListener(newActionListener(){//注册按钮,点击进入到第三层界面输入学号

publicvoidactionPerformed(ActionEvente){

frame.dispose();

newZhuce();

}

}

);

reset.addActionListener(newActionListener(){//重置按钮

publicvoidactionPerformed(ActionEvente){

nameText.setText("");//用户名重置

passwdText.setText("");//密码重置

}

}

);

}

publicstaticvoidmain(Stringargs[]){

Loginlog=newLogin();

log.login();

}

classImagePanelextendsJLabel{//构建一个图片容器

privatestaticfinallongserialVersionUID=1L;

protectedvoidpaintComponent(Graphicsg)

super.paintComponent(g);

ImageIconimg=newImageIcon("D:

\\Login.jpg");

g.drawImage(img.getImage(),0,0,this);

}

}

}

packagemysql;

importjava.awt.*;

importjavax.swing.*;

importjava.awt.event.ActionEvent;

importjava.awt.event.ActionListener;

importjava.sql.Connection;

importjava.sql.DriverManager;

importjava.sql.SQLException;

importjava.sql.Statement;

classZhuce

{

privateJFramejrf=newJFrame("注册窗口");

privateJLabeljla1=newJLabel("用户名:

");

privateJLabeljla2=newJLabel("密码:

");

privateJLabeljla3=newJLabel("确认密码:

");

privateJLabeljla4=newJLabel("姓名:

");

privateJLabeljla5=newJLabel("性别:

");

privateJLabeljla6=newJLabel("年龄:

");

privateJLabeljla7=newJLabel("生日:

");

privateJLabeljla8=newJLabel("身份证:

");

privateJLabeljla9=newJLabel("班级:

");

privateJLabeljla10=newJLabel("学院:

");

privateJLabeljla13=newJLabel("金额:

");

privateJLabeljla14=newJLabel("余额:

");

privateJLabeljla11=newJLabel("");

privateJLabeljla12=newJLabel("xxxx-xx-xx");//birth的格式

privateJTextFieldjtx1=newJTextField("");

privateJTextFieldjtx2=newJTextField("");

privateJTextFieldjtx3=newJTextField("");

privateJTextFieldjtx4=newJTextField("");

privateJTextFieldjtx5=newJTextField("");

privateJTextFieldjtx6=newJTextField("");

privateJTextFieldjtx7=newJTextField("");

privateJTextFieldjtx8=newJTextField("");

privateJTextFieldjtx9=newJTextField("");

privateJTextFieldjtx10=newJTextField("");

privateJTextFieldjtx13=newJTextField("");

privateJTextFieldjtx14=newJTextField("");

privateJButtonjbt=newJButton("提交");

privateJButtonjbt1=newJButton("返回");

Zhuce(){

Containercp=jrf.getContentPane();

//jrf.setBounds(500,200,300,300);

jla1.setBounds(40,20,100,20);

jla2.setBounds(40,60,100,20);

jla3.setBounds(40,100,100,20);

jla4.setBounds(40,140,100,20);

jla5.setBounds(40,180,100,20);

jla6.setBounds(40,220,100,20);

jla7.setBounds(40,260,100,20);

jla8.setBounds(40,300,100,20);

jla9.setBounds(40,340,100,20);

jla10.setBounds(40,380,100,20);

jla11.setBounds(120,500,150,20);

jla12.setBounds(270,260,100,20);

jla13.setBounds(40,420,100,20);

jla14.setBounds(40,460,100,20);

jtx1.setBounds(110,20,150,20);

jtx2.setBounds(110,60,150,20);

jtx3.setBounds(110,100,150,20);

jtx4.setBounds(110,140,150,20);

jtx5.setBounds(110,180,150,20);

jtx6.setBounds(110,220,150,20);

jtx7.setBounds(110,260,150,20);

jtx8.setBounds(110,300,150,20);

jtx9.setBounds(110,340,150,20);

jtx10.setBounds(110,380,150,20);

jtx13.setBounds(110,420,150,20);

jtx14.setBounds(110,460,150,20);

jbt.setBounds(90,550,80,30);

jbt1.setBounds(190,550,80,30);

cp.add(jla1);

cp.add(jla2);

cp.add(jla3);

cp

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1