Java作业.docx
《Java作业.docx》由会员分享,可在线阅读,更多相关《Java作业.docx(14页珍藏版)》请在冰豆网上搜索。
![Java作业.docx](https://file1.bdocx.com/fileroot1/2023-1/30/08c64524-bcaa-4bb6-8a91-27335a31bf11/08c64524-bcaa-4bb6-8a91-27335a31bf111.gif)
Java作业
贵州师范大学数学与计算机科学学院学生实验报告
课程名称:
JAVA实用教程班级:
12信本实验日期:
2014年12月1日
学号:
120703010048姓名:
杨家堂指导教师:
张艳
importjava.awt.*;
importjavax.swing.*;
importjava.awt.event.*;
importjavax.swing.border.Border;
publicclassjt2014{
publicstaticvoidmain(String[]args){
JFramef=newJFrame();
f.setTitle("学生信息管理系统");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(1004,610);
f.setLocation(200,200);
finalContainercon=f.getContentPane();
finalJPanelpan=newJPanel();
JLabeltitle=newJLabel("学生信息录入系统(杨家堂)",JLabel.CENTER);
title.setHorizontalTextPosition(JLabel.LEFT);
title.setForeground(Color.RED);
title.setFont(newFont("行书",Font.BOLD,48));
JLabell_xm=newJLabel("姓名");
JTextFieldtf_name=newJTextField(20);
JLabell_xb=newJLabel("密码");
JTextFieldsex=newJTextField(20);
ButtonGroupgroup=newButtonGroup();
JRadioButtonmale=newJRadioButton("男",true);
JRadioButtonfemale=newJRadioButton("女");
group.add(male);
group.add(female);
JLabell_ah=newJLabel("党否");
JCheckBox[]dang={newJCheckBox("")};
JPanelDangpan=newJPanel();
Dangpan.add(l_ah);
Dangpan.add(dang[0]);
JLabellb=newJLabel("年龄");
JSpinnerwt=newJSpinner();
wt.setValue(newInteger(20));
JPanelAgepan=newJPanel();
Agepan.add(lb);
Agepan.add(wt);
finalJLabeljl11=newJLabel("");
jl11.setOpaque(true);
jl11.setBackground(newColor(200,55,20));
JButtonjb1=newJButton("选择颜色");
jb1.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
jb1(e);
}
publicvoidjb1(ActionEvente){
Colorcolor=jl11.getBackground();
Colornewcolor=JColorChooser.showDialog(con,"请选择颜色",color);
jl11.setBackground(newcolor);
}
});
JPanelColorpan=newJPanel();
Colorpan.add(jb1);
Colorpan.add(jl11);
JLabell_xk=newJLabel("选课");
String[]coursesNames={"数据结构","操作系统","网络原理","java程序设计",
"分布式系统开发技术","计算机导论","密码学","计算机组成原理","编译原理","图形学"};
JListcourse=newJList(coursesNames);
JScrollPanescrollBar=newJScrollPane(course);
JLabell_jf=newJLabel("加分");
JSlideraddition=newJSlider(JSlider.HORIZONTAL,0,100,50);
addition.setMajorTickSpacing(10);
addition.setMinorTickSpacing(5);
addition.setPaintTicks(true);
addition.setPaintLabels(true);
addition.setSnapToTicks(true);
JPanelJiaFpan=newJPanel();
JiaFpan.add(l_jf);
JiaFpan.add(addition);
JButtonb_sub=newJButton("确认");
JButtonb_save=newJButton("保存");
JTextArearesult=newJTextArea(10,30);
JScrollPanesp=newJScrollPane(result);
Boxb1=Box.createHorizontalBox();
b1.add(l_xm);
b1.add(tf_name);
Boxb2=Box.createHorizontalBox();
b2.add(l_xb);
b2.add(sex);
Boxb4=Box.createHorizontalBox();
b4.add(JiaFpan);
b4.add(addition);
Boxb3=Box.createHorizontalBox();
b3.add(Dangpan);
b3.add(Agepan);
b3.add(Colorpan);
Boxb6=Box.createVerticalBox();
b6.add(Box.createVerticalStrut(15));
b6.add(b1);
b6.add(Box.createVerticalStrut(15));
b6.add(b2);
b6.add(Box.createVerticalStrut(15));
b6.add(b3);
b6.add(Box.createVerticalStrut(15));
b6.add(b4);
b6.add(Box.createVerticalStrut(15));
pan.add(b6);
b6.add(Box.createVerticalStrut(15));
Boxb7=Box.createHorizontalBox();
b7.add(b_sub);
b7.add(b_save);
Boxb5=Box.createVerticalBox();
b5.add(scrollBar);
b5.add(b7);
Boxb8=Box.createHorizontalBox();
b8.add(b6);
b8.add(Box.createHorizontalStrut(40));
b8.add(newJSeparator(JSeparator.VERTICAL));
b8.add(Box.createHorizontalStrut(40));
b8.add(b5);
b8.add(b7);
Boxb9=Box.createVerticalBox();
b9.add(title);
b9.add(b8);
b9.add(sp);
pan.add(b9);
Borderborder=BorderFactory.createTitledBorder("");
pan.setBorder(border);
Borderborder1=BorderFactory.createTitledBorder("记录结果");
sp.setBorder(border1);
Borderborder2=BorderFactory.createTitledBorder("学生信息");
b6.setBorder(border2);
Borderborder3=BorderFactory.createTitledBorder("课程");
b5.setBorder(border3);
Borderborder4=BorderFactory.createTitledBorder("");
title.setBorder(border4);
con.add(pan);
f.setVisible(true);
}
}
importjava.awt.*;
importjavax.swing.*;
publicclassjt2009{
publicstaticvoidmain(String[]args){
JFramef=newJFrame();
f.setTitle("用户登录注册界面");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(624,345);
f.setLocation(100,100);
Containercon=f.getContentPane();
JPanelpan=newJPanel();
JLabeltitle=newJLabel("用户登录注册界面(杨家堂)",JLabel.CENTER);
title.setHorizontalTextPosition(JLabel.LEFT);
title.setForeground(Color.BLACK);
title.setFont(newFont("宋体",Font.BOLD,36));
JLabelYH=newJLabel("用户名:
");
YH.setHorizontalAlignment(SwingConstants.RIGHT);
JTextFieldname=newJTextField(10);
JLabelmima1=newJLabel("密码:
");
mima1.setHorizontalAlignment(SwingConstants.RIGHT);
JPasswordFieldpassword1=newJPasswordField(10);
password1.setEchoChar('*');
JLabelmima2=newJLabel("再次输入密码:
");
mima2.setHorizontalAlignment(SwingConstants.RIGHT);
JPasswordFieldpassword2=newJPasswordField(10);
password2.setEchoChar('*');
JLabelmail=newJLabel("电子邮件:
");
mail.setHorizontalAlignment(SwingConstants.RIGHT);
JTextFieldaddress=newJTextField(10);
JLabelSEX=newJLabel("性别:
");
SEX.setHorizontalAlignment(SwingConstants.RIGHT);
ButtonGroupgroup=newButtonGroup();
JRadioButtonmale=newJRadioButton("男",true);
JRadioButtonfemale=newJRadioButton("女");
group.add(male);
group.add(female);
JPanelcsex=newJPanel();
csex.add(male);
csex.add(female);
JButtonb_sub=newJButton("确认");
JButtonb_cancel=newJButton("取消");
JButtonb_exit=newJButton("退出");
Boxb1=Box.createHorizontalBox();
b1.add(title);
Boxb2=Box.createHorizontalBox();
b2.add(Box.createHorizontalStrut(100));
b2.add(YH);
b2.add(name);
b2.add(Box.createHorizontalStrut(120));
Boxb3=Box.createHorizontalBox();
b3.add(Box.createHorizontalStrut(100));
b3.add(mima1);
b3.add(Box.createHorizontalStrut(13));
b3.add(password1);
b3.add(Box.createHorizontalStrut(120));
Boxb4=Box.createHorizontalBox();
b4.add(Box.createHorizontalStrut(60));
b4.add(mima2);
b4.add(password2);
b4.add(Box.createHorizontalStrut(120));
Boxb5=Box.createHorizontalBox();
b5.add(Box.createHorizontalStrut(100));
b5.add(SEX);
b5.add(csex);
b5.add(Box.createHorizontalStrut(200));
Boxb6=Box.createHorizontalBox();
b6.add(Box.createHorizontalStrut(80));
b6.add(mail);
b6.add(address);
b6.add(Box.createHorizontalStrut(120));
Boxb7=Box.createHorizontalBox();
b7.add(b_sub);
b7.add(Box.createHorizontalStrut(15));
b7.add(b_cancel);
b7.add(Box.createHorizontalStrut(15));
b7.add(b_exit);
Boxb8=Box.createVerticalBox();
b8.add(Box.createVerticalStrut(5));
b8.add(b1);
b8.add(Box.createVerticalStrut(5));
b8.add(b2);
b8.add(Box.createVerticalStrut(5));
b8.add(b3);
b8.add(Box.createVerticalStrut(5));
b8.add(b4);
b8.add(Box.createVerticalStrut(5));
b8.add(b5);
b8.add(Box.createVerticalStrut(5));
b8.add(b6);
b8.add(Box.createVerticalStrut(5));
b8.add(b7);
b8.add(Box.createVerticalStrut(5));
pan.add(b8);
con.add(pan);
f.setVisible(true);
}
}
importjava.awt.*;
importjavax.swing.*;
publicclassjt13extendsJFrame{
publicjt13()
{
super("欢迎使用杨家堂制作的系统");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500,300);
setLocation(200,200);
Containerc=getContentPane();
c.setLayout(newBorderLayout());
Boxg_title=Box.createHorizontalBox();
JLabeltitle=newJLabel("登录界面(杨家堂制作)",JLabel.CENTER);
title.setHorizontalTextPosition(JLabel.LEFT);
title.setForeground(Color.BLUE);
title.setFont(newFont("楷体",Font.BOLD,36));
g_title.add(Box.createHorizontalGlue());
g_title.add(title);
g_title.add(Box.createHorizontalGlue());
c.add(g_title,"North");
Boxg_ma=Box.createHorizontalBox();
JLabell_ma=newJLabel("密码:
");
JPasswordFieldt_ma=newJPasswordField(20);
g_ma.add(Box.createHorizontalStrut(100));
g_ma.add(l_ma);
g_ma.add(t_ma);
g_ma.add(Box.createHorizontalStrut(100));
Boxg_yh=Box.createHorizontalBox();
JLabell_yh=newJLabel("用户:
");
JTextFieldt_yh=newJTextField(20);
g_yh.add(Box.createHorizontalStrut(100));
g_yh.add(l_yh);
g_yh.add(t_yh);
g_yh.add(Box.createHorizontalStrut(100));
Boxa4=Box.createVerticalBox();
a4.add(Box.createVerticalStrut(60));
a4.add(g_yh);
a4.add(Box.createVerticalStrut(40));
a4.add(g_ma);
c.add(a4,"Center");
Boxg_dl=Box.createHorizontalBox();
JButtonb_dl=newJButton("登录");
g_dl.add(Box.createVerticalStrut(60));
g_dl.add(Box.createHorizontalGlue());
g_dl.add(b_dl);
g_dl.add(Box.createHorizontalGlue());
g_dl.add(Box.createVerticalStrut(60));
c.add(g_dl,"South");
setVisible(true);
}
publicstaticvoidmain(Stringargs[]){
jt13f=newjt13();
}
}
importjavax.swing.*;
importjava.awt.*;
publicclassjt14extendsJFrame{
publicjt14(){
super("欢迎使用杨家堂制作的系统");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500,300);
setLocation(200,200);
Containercon=getContentPane();
JPanelq=newJPanel();
JLabeltitle=newJLabel("登录界面(杨家堂)",JLabel.CENTER);
title.setHorizontalTextPosition(JLabel.LEFT);
title.setForeground(Color.BLUE);
title.setFont(newFont("楷体",Font.BOLD,38));
JLabell_yh=newJLabel("用户:
");
l_yh.setHorizontalAlignment(SwingConstants.RIGHT);//向右对其
JT