pageturner.java
来自「简易的OA办公软件系统 包含部门管理 短消息管理 公告管理 考勤管理 员工管理」· Java 代码 · 共 87 行
JAVA
87 行
package com.buat.util;
public class PageTurner {
public int total=0; //记录总条数
public int countPerPage=0; //记录每一页的条数
public int pageNO=0; //记录当前页数
public int beginIndex=0; //记录开始的索引值
public int endIndex=0; //记录结束的索引值
public int pageCount=0; //记录总页数
public PageTurner(int total,int countPerPage){
this.total=total;
this.countPerPage=countPerPage;
this.pageCount=(total-1)/this.countPerPage+1;
}
public int getBeginIndex(){ //获取开始记录的索引值
this.beginIndex=pageNO*this.countPerPage;
return this.beginIndex;
}
public int getEndIndex(){ //获取结束记录的索引值
if(this.pageNO==this.pageCount-1){
this.endIndex=this.total-1;
}else{
this.endIndex=(this.pageNO+1)*this.countPerPage-1;
}
return this.endIndex;
}
public void getFirstPage(){ //显示第一页
this.pageNO=0;
}
public int getNextPage(){ //下一页
this.pageNO=this.pageNO+1;
if(this.pageNO>this.pageCount-1){
this.pageNO=this.pageCount-1;
}
return this.pageNO;
}
public int getPreviousPage(){ //上一页
this.pageNO=this.pageNO-1;
if(this.pageNO<0){
this.pageNO=0;
}
return this.pageNO;
}
public int getLastPage(){ //显示最后一页
this.pageNO=this.pageCount-1;
return this.pageNO;
}
public int getTotal() {
return total;
}
public int getCountPerPage() {
return countPerPage;
}
public void setCountPerPage(int countPerPage) {
this.countPerPage = countPerPage;
}
public int getPageNO() {
return pageNO;
}
public void setPageNO(int pageNO) {
this.pageNO=pageNO;
}
public void setBeginIndex(int beginIndex) {
this.beginIndex = beginIndex;
}
public void setEndIndex(int endIndex) {
this.endIndex = endIndex;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?