![在这里插入图片描述](https://img-blog.csdnimg.cn/20191224205214356.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl8zOTU5Mzk0MA==,size_16,color_FFFFFF,t_70)
jtnLast.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int intTotal= selectTotalCount();
intPage=Integer.valueOf(intTotal/8);
int inta=8*intPage;
String sql="select*from orderNew limit "+inta+",8";
list=selectOrder(sql);
String[][] aa=selectList();
setTable(aa,bb);
}
});
jtnFirst.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String sql="select*from orderNew limit 0,8";
list=selectOrder(sql);
String[][] aa=selectList();
setTable(aa,bb);
intPage=0;
}
});
jtnForward.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(intPage>=1){
intPage-=1;
int inta;
inta=8*intPage;
String sql="select*from orderNew limit "+inta+",8";
list=selectOrder(sql);
String[][] aa=selectList();
setTable(aa,bb);
}
}
});
jtnBackward.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int intTotal=Integer.valueOf(selectTotalCount()/8);
if(intPage<intTotal){
intPage+=1;
int inta;
inta=8*intPage;
String sql="select*from orderNew limit "+inta+",8";
list=selectOrder(sql);
String[][] aa=selectList();
setTable(aa,bb);
}
}
});
private int selectTotalCount(){
try {
Connection con=DB.getConnection();
String sql="select count(*)from orderNew";
PreparedStatement pst=con.prepareStatement(sql);
ResultSet rs=pst.executeQuery();
while(rs.next())
{
int intTotal=rs.getInt(1);
return intTotal;
}
} catch (SQLException e) {
e.printStackTrace();
}
return 0;
}