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(n<0){
n++;
JOptionPane.showMessageDialog(null, "亲!已经到第一页了!");
}
}else if(e.getSource()==x2){
n++;
if(n>40){
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());
}
}
botao555
相关分类