• 手机版

    扫码体验手机版

  • 微信公众号

    扫码关注公众号

国内首家协议开发

软芯音视解码保护平台

在线
客服

发布
需求

在线
聊天

天盟
APP

天盟APP下载

关注
微信

微信扫一扫访问
顶部

java 读取xls表格然后实现上一页和下一页 (写了出来但是不能用,不知道为

package shizi;


import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;


import javax.swing.*;


import javazoom.jl.player.advanced.jlap;
import jxl.Sheet;
import jxl.Workbook;


public class Xue_1 extends JFrame implements ActionListener{
        JButton x1=new JButton("上一个");
        JButton x2=new JButton("下一个");
        JButton r1=new JButton("返回主菜单");
        JButton r2=new JButton("切换音乐");
        JButton r3=new JButton("切换背景");
        JButton r4=new JButton("静音模式");
        JLabel bj2=new JLabel(new ImageIcon("image/215452.jpg"));
        Xinxi[] xinxis;
       
        JLabel h1=new JLabel("字");
        JLabel h2=new JLabel("组词");
        JLabel h3=new JLabel("造句");
        JLabel h4=new JLabel("拼音");
        JLabel h5=new JLabel("喇叭");
       
        Font font1=new Font("楷体",Font.BOLD,90);
        Font font2=new Font("微软雅黑",Font.BOLD,30);




        int n;
       
        public Xue_1(){
               
                Container c=this.getContentPane();
                c.setLayout(null);
                xinxis=this.getXinxis();
               
                h1.setBounds(270,50, 100,100);
                h4.setBounds(100,200, 300,70);
                h2.setBounds(100,260, 300,70);
                h3.setBounds(100,320, 300,70);
                h5.setBounds(410,150, 50,50);
               
                h1.setFont(font1);
                h2.setFont(font2);
                h3.setFont(font2);
                h4.setFont(font2);
               
               
                bj2.setBounds(0,0,500,600);
                x1.setBounds(100, 520, 100, 40);
                x2.setBounds(300, 520, 100, 40);
                r1.setBounds(0, 0, 100, 30);
                r2.setBounds(0, 30, 100, 30);
                r3.setBounds(0, 60, 100, 30);
                r4.setBounds(0, 90, 100, 30);
                x1.addActionListener(this);
                x2.addActionListener(this);
                r1.addActionListener(this);
                r2.addActionListener(this);
                r3.addActionListener(this);
                r4.addActionListener(this);
               
               
                c.add(h1);
                c.add(h2);
                c.add(h3);
                c.add(h4);
                c.add(h5);
                c.add(r1);
                c.add(r2);
                c.add(r3);
                c.add(r4);
                c.add(x1);
                c.add(x2);
                c.add(bj2);
               
                this.showXinxi(xinxis[0]);
                this.setTitle("识字板块");
                this.setSize(500, 600);
                this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                this.setVisible(true);
        }
       
        public static void main(String[] args) {
                Xue_1 xue=new Xue_1();
               
        }


        @Override
        public void actionPerformed(ActionEvent e) {
                this.getXinxis();
                // TODO Auto-generated method stub
                if(e.getSource()==x1){
                        n--;               
                        if(n40){
                                n--;
                                JOptionPane.showMessageDialog(null, "亲!已经学完了,快去做练习游戏吧!");
                        }
       
                }else if(e.getSource()==r1){
                        Jiemian_1 jm=new Jiemian_1();
                       
                }else if(e.getSource()==r2){
                       
                }else if(e.getSource()==r3){
                       
                }else if(e.getSource()==r4){
                       
                }
        }
       
        public Xinxi[] getXinxis(){
                Xinxi[] xinxis=null;
                try{        File file=new File("file/1.xls");
                Workbook workbook=Workbook.getWorkbook(file);
                Sheet sheet=workbook.getSheet(0);
                int rows=sheet.getRows();
                int columns=sheet.getColumns();
                xinxis=new Xinxi[rows];
                        Xinxi xx=new Xinxi();               
                        System.out.println("n="+n);
                        xx.setZi(sheet.getCell(0,0+n).getContents());
                        xx.setCi(sheet.getCell(1,0+n).getContents());
                        xx.setJu(sheet.getCell(2,0+n).getContents());
                        xx.setPinyin(sheet.getCell(3,0+n).getContents());
                        xx.setYuyin(sheet.getCell(4,0+n).getContents());
                        xinxis[n]=xx;
                workbook.close();       
                }catch(Exception ex){
                        ex.printStackTrace();
        }
                return xinxis;
}


        public void showXinxi(Xinxi xinxi){
                h1.setText(xinxi.getZi());
                h2.setText(xinxi.getCi());
                h3.setText(xinxi.getJu());
                h4.setText(xinxi.getPinyin());
                h5.setText(xinxi.getYuyin());
        }


}

免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。

版权声明:作者保留权利,不代表天盟立场。

使用道具 举报

全部参与1

你的jar包和类的代码没给全,自己单步调试下吧

使用道具 举报

发新帖

发布任务需求已有1031167位用户正在使用天盟网服务

发布分类: *
任务预算: *
需求内容: *
手机号码: *
任务商家报价为
  • 预算价 :
  • 成交价 :
  • 完工期 :
  • 质保期 :

* 最终任务项目以服务商报价、双方协商为准!