java课表显示代码 如何用java制作课表
java表格代码怎么写
java表格就是java swing。
“只有客户发展了,才有我们的生存与发展!”这是创新互联建站的服务宗旨!把网站当作互联网产品,产品思维更注重全局思维、需求分析和迭代思维,在网站建设中就是为了建设一个不仅审美在线,而且实用性极高的网站。创新互联对网站建设、网站制作、网站制作、网站开发、网页设计、网站优化、网络推广、探索永无止境。
//创建表头
String[] columnNames = { "First Name", "Last Name", "Sport",
"# of Years", "Vegetarian" };
//创建显示数据
Object[][] data = {
{ "Kathy", "Smith", "Snowboarding", new Integer(5),
new Boolean(false) },
{ "John", "Doe", "Rowing", new Integer(3), new Boolean(true) },
{ "Sue", "Black", "Knitting", new Integer(2),
new Boolean(false) },
{ "Jane", "White", "Speed reading", new Integer(20),
new Boolean(true) },
{ "Joe", "Brown", "Pool", new Integer(10), new Boolean(false) } };
/*
* JTable还提供了一个重载的构造方法,传入两个Vector
* JTable(Vector rowData, Vector columnNames)
*
*/
final JTable table = new JTable(data, columnNames);
table.setBackground(Color.YELLOW);
要求编写一个java程序,输入学生信息,并能保存与显示学生信息。
import java.util.ArrayList;
import java.util.Scanner;import com.sun.org.apache.xpath.internal.Arg;
public class Student {
//两个私有属性
private int no ;
private String name ;
//默认构造函数
public Student(){}
//带参构造函数
public Student(int no,String name){
this.no=no;
this.name=name;
}
//添加学生信息
public void addStudentInfo(ArrayList list){
String flag1="yes";
do{
Student student=new Student();
Scanner in =new Scanner(System.in);
System.out.println("请输入学生学号:");
student.setNo(in.nextInt());
System.out.println("请输入学生姓名:");
student.setName(in.next());
list.add(student);
System.out.println("是否继续添加学生信息(yes/no)?");
flag1=in.next();
} while(flag1.equals("yes"));
}
//读取学生信息
public void showStudentInfo(ArrayListStudent list){
System.out.println(" 学生no: "+" 学生name: ");
for(Student student:list){
System.out.println(" "+student.getNo()+" "+student.getName());
}
}
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public static void main(String arg[]) {
ArrayListStudent studentList= new ArrayListStudent();
Student student= new Student();
Scanner inn= new Scanner(System.in);
while(true){
System.out.println("----------------- 欢迎使用学生管理系统------------------");
System.out.println("1.输入学生信息");
System.out.println("2.显示学生信息");
System.out.println("0.退出系统");
System.out.println("请选择....");
int nn= inn.nextInt();
switch (nn) {
case 1:
student.addStudentInfo(studentList);
break;
case 2:
System.out.println("学生信息如下:");
student.showStudentInfo(studentList);
break;
case 0:
System.exit(0);
System.out.println("系统退出!");
break;
default:
break;
}
}
} }
java 课程表,网页中显示
String[] content=new String[40];
int i=0;
while(rs.next()){
content[i]=rs.getString(1);//content是你声明号的数组
i++;
}
%
body
form name="form" action="showstudent.jsp" method="post"
TABLE border=0 bgcolor="000000" cellspacing="1" width=400
TR bgcolor="FFFFFF"
TD id="td1" /TD
TD星期一/TD
TD星期二/TD
TD星期三/TD
TD星期四/TD
TD星期五/TD
TD星期六/TD
TD星期日/TD
/TR
TR bgcolor="FFFFFF"
TD第一节/TD
TD%=content[0]%/TD
TD%=content[7]%/TD
TD%=content[14]%/TD
TD%=content[21]%/TD
TD%=content[28]%/TD
TDx/TD
TDx/TD
/TR
TR bgcolor="FFFFFF"
TD第二节/TD
TD%=content[1]%/TD
TD%=content[8]%/TD
TD%=content[15]%/TD
TD%=content[22]%/TD
TD%=content[29]%/TD
TDx/TD
TDx/TD
/TR
TR bgcolor="FFFFFF"
TD第三节/TD
TD%=content[2]%/TD
TD%=content[9]%/TD
TD%=content[16]%/TD
TD%=content[23]%/TD
TD%=content[30]%/TD
TDx/TD
TDx/TD
/TR
TR bgcolor="FFFFFF"
TD第四节/TD
TD%=content[3]%/TD
TD%=content[10]%/TD
TD%=content[17]%/TD
TD%=content[24]%/TD
TD%=content[31]%/TD
TDx/TD
TDx/TD
/TR
TR bgcolor="FFFFFF"
TD第五节/TD
TD%=content[4]%/TD
TD%=content[11]%/TD
TD%=content[18]%/TD
TD%=content[25]%/TD
TD%=content[32]%/TD
TDx/TD
TDx/TD
/TR
TR bgcolor="FFFFFF"
TD第六节/TD
TD%=content[5]%/TD
TD%=content[12]%/TD
TD%=content[19]%/TD
TD%=content[26]%/TD
TD%=content[33]%/TD
TDx/TD
TDx/TD
/TR
TR bgcolor="FFFFFF"
TD第七节/TD
TD%=content[6]%/TD
TD%=content[13]%/TD
TD%=content[20]%/TD
TD%=content[27]%/TD
TD%=content[34]%/TD
TDx/TD
TDx/TD
/TR
/TABLE
/form
/body
/html
,将结果保存在一维数组中,直接调用这些值。
用Java怎样实现课表代码?有周次
课表数据时存储于数据库中的吗?
/**
* 获取一周的时间集合(从周一到周日)
* @param weekNum ;-1:上周;0:本周;1:下周
*/
public static ListDate getWeekDates(int weekNum){
ListDate list = new ArrayListDate();
Calendar cal = Calendar.getInstance();
// 获取指定下几个星期
cal.add(Calendar.DAY_OF_WEEK, weekNum * 7);
cal.setFirstDayOfWeek(Calendar.MONDAY);
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
list.add(cal.getTime());
for(int i = 0;i 6;i++){
cal.add(Calendar.DAY_OF_WEEK, 1);
list.add(cal.getTime());
}
return list;
}
这个是获取这一周时间的代码 ,之后用下面的代码获取周一到周日的日期
ListDate ds = DateUtil.getNowWeekDates(weekNum);
ds.get(0)//周一
ds.get(6)//周日
用这两个时间到数据库中进行范围查询,之后的你应该明白了吧
分享题目:java课表显示代码 如何用java制作课表
网址分享:http://ybzwz.com/article/dopdhpd.html