📄 cardframe.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 java.util.ArrayList;
import cn.com.S1t55.killer.entity.Card; //导入学员的实体类
import cn.com.S1t55.killer.business.CardBusiness;
import javax.swing.JTextField;
import java.awt.Rectangle;
import javax.swing.JLabel;
import javax.swing.DebugGraphics;
import javax.swing.BorderFactory;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.border.TitledBorder;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class CardFrame extends JFrame {
int weiZhi = 0; //纪录集合类提取元素的下标。
ArrayList arr = CardBusiness.select();
JPanel contentPane;
JTextField txtID = new JTextField();
JTextField txtName = new JTextField();
JTextField txtPassword = new JTextField();
JTextField txtboolan = new JTextField();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JPanel jPanel1 = new JPanel();
TitledBorder titledBorder1 = new TitledBorder("");
JButton btnZuiHou = new JButton();
JButton btnHou = new JButton();
JButton btnQian = new JButton();
JButton btnDiYi = new JButton();
public CardFrame() {
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("查询卡信息");
txtID.setBounds(new Rectangle(133, 29, 174, 33));
txtName.setBounds(new Rectangle(132, 82, 178, 30));
txtPassword.setBounds(new Rectangle(130, 129, 177, 29));
txtboolan.setBounds(new Rectangle(130, 179, 177, 30));
jLabel1.setFont(new java.awt.Font("宋体", Font.BOLD | Font.ITALIC, 14));
jLabel1.setText("卡号");
jLabel1.setBounds(new Rectangle(82, 28, 47, 36));
jLabel2.setFont(new java.awt.Font("宋体", Font.BOLD | Font.ITALIC, 14));
jLabel2.setText("用户名");
jLabel2.setBounds(new Rectangle(76, 82, 52, 29));
jLabel3.setFont(new java.awt.Font("宋体", Font.BOLD | Font.ITALIC, 14));
jLabel3.setText("密码");
jLabel3.setBounds(new Rectangle(83, 129, 42, 28));
jLabel4.setFont(new java.awt.Font("宋体", Font.BOLD | Font.ITALIC, 14));
jLabel4.setText("余额");
jLabel4.setBounds(new Rectangle(79, 180, 48, 27));
jPanel1.setBorder(BorderFactory.createEtchedBorder());
jPanel1.setBounds(new Rectangle(50, 231, 319, 48));
btnZuiHou.setActionCommand(">>");
btnZuiHou.setText(">>");
btnZuiHou.addActionListener(new CardFrame_btnZuiHou_actionAdapter(this));
btnHou.setActionCommand(">");
btnHou.setText(">");
btnHou.addActionListener(new CardFrame_btnHou_actionAdapter(this));
btnQian.setActionCommand("<");
btnQian.setText("<");
btnQian.addActionListener(new CardFrame_btnQian_actionAdapter(this));
btnDiYi.setActionCommand("<<");
btnDiYi.setText("<<");
btnDiYi.addActionListener(new CardFrame_btnDiYi_actionAdapter(this));
contentPane.add(txtID);
contentPane.add(txtName);
contentPane.add(txtPassword);
contentPane.add(txtboolan);
contentPane.add(jLabel1);
contentPane.add(jLabel2);
contentPane.add(jLabel3);
contentPane.add(jLabel4);
contentPane.add(jPanel1);
jPanel1.add(btnDiYi);
jPanel1.add(btnQian);
jPanel1.add(btnHou);
jPanel1.add(btnZuiHou);
}
public void btnDiYi_actionPerformed(ActionEvent e) {
weiZhi = 0;
Card stu = (Card) arr.get(weiZhi);
//设计界面文本框中的值
this.txtID.setText("" + stu.getId());
this.txtName.setText(stu.getMemberId());
this.txtPassword.setText("" + stu.getPassword());
this.txtboolan.setText("" + stu.getBalance());
}
public void btnQian_actionPerformed(ActionEvent e) {
//从集合类中提取对象
weiZhi--;
if (weiZhi < 0) //判断是否是第一条纪录
weiZhi = 0;
Card stu = (Card) arr.get(weiZhi);
//设计界面文本框中的值
this.txtID.setText("" + stu.getId());
this.txtName.setText(stu.getMemberId());
this.txtPassword.setText("" + stu.getPassword());
this.txtboolan.setText("" + stu.getBalance());
}
public void btnHou_actionPerformed(ActionEvent e) {
weiZhi++;
if (weiZhi >(arr.size()-1)) //判断是否是最后一条纪录
weiZhi = arr.size()-1;
Card stu = (Card) arr.get(weiZhi);
//设计界面文本框中的值
this.txtID.setText("" + stu.getId());
this.txtName.setText(stu.getMemberId());
this.txtPassword.setText("" + stu.getPassword());
this.txtboolan.setText("" + stu.getBalance());
}
public void btnZuiHou_actionPerformed(ActionEvent e) {
weiZhi = arr.size() - 1;
Card stu = (Card) arr.get(weiZhi);
//设计界面文本框中的值
this.txtID.setText("" + stu.getId());
this.txtName.setText(stu.getMemberId());
this.txtPassword.setText("" + stu.getPassword());
this.txtboolan.setText("" + stu.getBalance());
}
}
class CardFrame_btnZuiHou_actionAdapter implements ActionListener {
private CardFrame adaptee;
CardFrame_btnZuiHou_actionAdapter(CardFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnZuiHou_actionPerformed(e);
}
}
class CardFrame_btnHou_actionAdapter implements ActionListener {
private CardFrame adaptee;
CardFrame_btnHou_actionAdapter(CardFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnHou_actionPerformed(e);
}
}
class CardFrame_btnDiYi_actionAdapter implements ActionListener {
private CardFrame adaptee;
CardFrame_btnDiYi_actionAdapter(CardFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnDiYi_actionPerformed(e);
}
}
class CardFrame_btnQian_actionAdapter implements ActionListener {
private CardFrame adaptee;
CardFrame_btnQian_actionAdapter(CardFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnQian_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -