⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 computerselect.java~1~

📁 机房网吧刷卡计费
💻 JAVA~1~
字号:
package cn.com.S1t55.killer.view;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import java.awt.Rectangle;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import java.util.ArrayList;
import cn.com.S1t55.killer.entity.Computer; //导入学员的实体类
import cn.com.S1t55.killer.business.ComBusiness;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class ComputerSelect extends JFrame {
    int weiZhi = 0; //纪录集合类提取元素的下标。
    ArrayList arr = ComBusiness.select();
    JPanel contentPane;
    JTextField txtHao = new JTextField();
    JTextField txtZhuang = new JTextField();
    JTextField txtBei = new JTextField();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JPanel jPanel1 = new JPanel();
    JButton btnZuiHou = new JButton();
    JButton btnHou = new JButton();
    JButton jButton3 = new JButton();
    JButton btnDiYi = new JButton();
    public ComputerSelect() {
        try {
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    /**
     * Component initialization.
     *
     * @throws java.lang.Exception
     */
    private void jbInit() throws Exception {
        contentPane = (JPanel) getContentPane();
        contentPane.setLayout(null);
        setSize(new Dimension(400, 300));
        setTitle("机器信息查询");
        txtHao.setBounds(new Rectangle(119, 47, 187, 29));
        txtZhuang.setBounds(new Rectangle(118, 102, 188, 27));
        txtZhuang.addActionListener(new
                                      ComputerSelect_jTextField2_actionAdapter(this));
        txtBei.setBounds(new Rectangle(117, 154, 189, 28));
        txtBei.addActionListener(new ComputerSelect_txtHao_actionAdapter(this));
        jLabel1.setText("机器号");
        jLabel1.setBounds(new Rectangle(59, 48, 55, 24));
        jLabel2.setText("机器状态");
        jLabel2.setBounds(new Rectangle(57, 106, 59, 23));
        jLabel3.setText("备注");
        jLabel3.setBounds(new Rectangle(54, 155, 63, 25));
        jPanel1.setBorder(BorderFactory.createEtchedBorder());
        jPanel1.setBounds(new Rectangle(57, 223, 286, 38));
        btnZuiHou.setActionCommand(">>");
        btnZuiHou.setText(">>");
        btnZuiHou.addActionListener(new ComputerSelect_btnZuiHou_actionAdapter(this));
        btnHou.setActionCommand(">");
        btnHou.setText(">");
        btnHou.addActionListener(new ComputerSelect_btnHou_actionAdapter(this));
        jButton3.setActionCommand("<");
        jButton3.setText("<");
        jButton3.addActionListener(new ComputerSelect_jButton3_actionAdapter(this));
        btnDiYi.setActionCommand("<<");
        btnDiYi.setText("<<");
        btnDiYi.addActionListener(new ComputerSelect_jButton4_actionAdapter(this));
        contentPane.add(txtHao);
        contentPane.add(txtZhuang);
        contentPane.add(txtBei);
        contentPane.add(jLabel1);
        contentPane.add(jLabel2);
        contentPane.add(jLabel3);
        contentPane.add(jPanel1);
        jPanel1.add(btnDiYi);
        jPanel1.add(jButton3);
        jPanel1.add(btnHou);
        jPanel1.add(btnZuiHou);
    }

    public void jButton4_actionPerformed(ActionEvent e) {
        weiZhi = 0;
               Computer stu = (Computer) arr.get(weiZhi);
               //设计界面文本框中的值
               this.txtHao.setText("" + stu.getId());
               this.txtZhuang.setText(stu.getNotes());
               this.txtBei.setText("" + stu.getOnUse());
    }

    public void jTextField2_actionPerformed(ActionEvent e) {

    }

    public void txtHao_actionPerformed(ActionEvent e) {

    }

    public void jButton3_actionPerformed(ActionEvent e) {
        weiZhi--;
              if (weiZhi < 0) //判断是否是第一条纪录
            weiZhi = 0;
        Computer stu = (Computer) arr.get(weiZhi);
          //设计界面文本框中的值
          this.txtHao.setText("" + stu.getId());
          this.txtZhuang.setText(stu.getNotes());
          this.txtBei.setText("" + stu.getOnUse());

    }

    public void btnHou_actionPerformed(ActionEvent e) {
        weiZhi++;
            if (weiZhi >(arr.size()-1)) //判断是否是最后一条纪录
          weiZhi = arr.size()-1;
      Computer stu = (Computer) arr.get(weiZhi);
     //设计界面文本框中的值
     this.txtHao.setText("" + stu.getId());
     this.txtZhuang.setText(stu.getNotes());
     this.txtBei.setText("" + stu.getOnUse());

    }

    public void btnZuiHou_actionPerformed(ActionEvent e) {
        weiZhi = arr.size() - 1;
           Computer stu = (Computer) arr.get(weiZhi);
        this.txtHao.setText("" + stu.getId());
        this.txtZhuang.setText(stu.getNotes());
        this.txtBei.setText("" + stu.getOnUse());

    }
}


class ComputerSelect_btnZuiHou_actionAdapter implements ActionListener {
    private ComputerSelect adaptee;
    ComputerSelect_btnZuiHou_actionAdapter(ComputerSelect adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnZuiHou_actionPerformed(e);
    }
}


class ComputerSelect_jButton3_actionAdapter implements ActionListener {
    private ComputerSelect adaptee;
    ComputerSelect_jButton3_actionAdapter(ComputerSelect adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton3_actionPerformed(e);
    }
}


class ComputerSelect_btnHou_actionAdapter implements ActionListener {
    private ComputerSelect adaptee;
    ComputerSelect_btnHou_actionAdapter(ComputerSelect adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnHou_actionPerformed(e);
    }
}


class ComputerSelect_txtHao_actionAdapter implements ActionListener {
    private ComputerSelect adaptee;
    ComputerSelect_txtHao_actionAdapter(ComputerSelect adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.txtHao_actionPerformed(e);
    }
}


class ComputerSelect_jTextField2_actionAdapter implements ActionListener {
    private ComputerSelect adaptee;
    ComputerSelect_jTextField2_actionAdapter(ComputerSelect adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jTextField2_actionPerformed(e);
    }
}


class ComputerSelect_jButton4_actionAdapter implements ActionListener {
    private ComputerSelect adaptee;
    ComputerSelect_jButton4_actionAdapter(ComputerSelect adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton4_actionPerformed(e);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -