java表格就是java swing。
“只有客戶發(fā)展了,才有我們的生存與發(fā)展!”這是創(chuàng)新互聯(lián)建站的服務(wù)宗旨!把網(wǎng)站當(dāng)作互聯(lián)網(wǎng)產(chǎn)品,產(chǎn)品思維更注重全局思維、需求分析和迭代思維,在網(wǎng)站建設(shè)中就是為了建設(shè)一個(gè)不僅審美在線,而且實(shí)用性極高的網(wǎng)站。創(chuàng)新互聯(lián)對網(wǎng)站建設(shè)、網(wǎng)站制作、網(wǎng)站制作、網(wǎng)站開發(fā)、網(wǎng)頁設(shè)計(jì)、網(wǎng)站優(yōu)化、網(wǎng)絡(luò)推廣、探索永無止境。
//創(chuàng)建表頭
String[] columnNames = { "First Name", "Last Name", "Sport",
"# of Years", "Vegetarian" };
//創(chuàng)建顯示數(shù)據(jù)
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還提供了一個(gè)重載的構(gòu)造方法,傳入兩個(gè)Vector
* JTable(Vector rowData, Vector columnNames)
*
*/
final JTable table = new JTable(data, columnNames);
table.setBackground(Color.YELLOW);
import java.util.ArrayList;
import java.util.Scanner;import com.sun.org.apache.xpath.internal.Arg;
public class Student {
//兩個(gè)私有屬性
private int no ;
private String name ;
//默認(rèn)構(gòu)造函數(shù)
public Student(){}
//帶參構(gòu)造函數(shù)
public Student(int no,String name){
this.no=no;
this.name=name;
}
//添加學(xué)生信息
public void addStudentInfo(ArrayList list){
String flag1="yes";
do{
Student student=new Student();
Scanner in =new Scanner(System.in);
System.out.println("請輸入學(xué)生學(xué)號:");
student.setNo(in.nextInt());
System.out.println("請輸入學(xué)生姓名:");
student.setName(in.next());
list.add(student);
System.out.println("是否繼續(xù)添加學(xué)生信息(yes/no)?");
flag1=in.next();
} while(flag1.equals("yes"));
}
//讀取學(xué)生信息
public void showStudentInfo(ArrayListStudent list){
System.out.println(" 學(xué)生no: "+" 學(xué)生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("----------------- 歡迎使用學(xué)生管理系統(tǒng)------------------");
System.out.println("1.輸入學(xué)生信息");
System.out.println("2.顯示學(xué)生信息");
System.out.println("0.退出系統(tǒng)");
System.out.println("請選擇....");
int nn= inn.nextInt();
switch (nn) {
case 1:
student.addStudentInfo(studentList);
break;
case 2:
System.out.println("學(xué)生信息如下:");
student.showStudentInfo(studentList);
break;
case 0:
System.exit(0);
System.out.println("系統(tǒng)退出!");
break;
default:
break;
}
}
} }
String[] content=new String[40];
int i=0;
while(rs.next()){
content[i]=rs.getString(1);//content是你聲明號的數(shù)組
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第一節(jié)/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第二節(jié)/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第三節(jié)/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第四節(jié)/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第五節(jié)/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第六節(jié)/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第七節(jié)/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
,將結(jié)果保存在一維數(shù)組中,直接調(diào)用這些值。
課表數(shù)據(jù)時(shí)存儲于數(shù)據(jù)庫中的嗎?
/**
* 獲取一周的時(shí)間集合(從周一到周日)
* @param weekNum ;-1:上周;0:本周;1:下周
*/
public static ListDate getWeekDates(int weekNum){
ListDate list = new ArrayListDate();
Calendar cal = Calendar.getInstance();
// 獲取指定下幾個(gè)星期
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;
}
這個(gè)是獲取這一周時(shí)間的代碼 ,之后用下面的代碼獲取周一到周日的日期
ListDate ds = DateUtil.getNowWeekDates(weekNum);
ds.get(0)//周一
ds.get(6)//周日
用這兩個(gè)時(shí)間到數(shù)據(jù)庫中進(jìn)行范圍查詢,之后的你應(yīng)該明白了吧