📄 searchreckoninginfoframe.java
字号:
package myprojects.reckoning;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import javax.swing.event.*;
import java.util.*;
import javax.swing.table.*;
import java.io.*;
//-----------------导入自定义的包---------------------------
import myprojects.reckoning.*;
/**
* @(#)SearchReckoningInfoFrame.java
*
*查询交易情况
*
* @author
* @version 1.00 05/12/25
*/
public class SearchReckoningInfoFrame extends JFrame {
JPanel contentPane;
JPanel reckoningInfoPanel = new JPanel();
JLabel hintReckoningInfoLabel = new JLabel();
JPanel buttonPanel = new JPanel();
JButton affrimButton = new JButton();
JButton exitButton = new JButton();
//用表格来表示列表
DefaultTableModel reckoningInfoModel = new DefaultTableModel();
JTable reckoningInfoTable = new JTable(reckoningInfoModel);
SearchReckoningInfo searchReckoningInfo = new SearchReckoningInfo();
//Construct the frame
public SearchReckoningInfoFrame() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(null);
this.setSize(new Dimension(400, 350));
this.setLocation(290,250);
this.setTitle("查询交易情况");
this.setResizable(false); //使之不能改变大小
contentPane.setForeground(Color.black);
reckoningInfoPanel.setBackground(Color.lightGray);
reckoningInfoPanel.setBounds(new Rectangle(24, 14, 345, 202));
BorderLayout border = new BorderLayout();
reckoningInfoPanel.setLayout(border);
hintReckoningInfoLabel.setText(" "+
" 交易信息");
buttonPanel.setBackground(Color.lightGray);
buttonPanel.setBounds(new Rectangle(24, 226, 347, 54));
buttonPanel.setLayout(null);
affrimButton.setBounds(new Rectangle(151-65, 16, 73, 25));
affrimButton.setText("确定");
exitButton.setBounds(new Rectangle(245-40, 16, 73, 25));
exitButton.setText("退出");
contentPane.add(reckoningInfoPanel, null);
reckoningInfoPanel.add(hintReckoningInfoLabel,BorderLayout.NORTH);
contentPane.add(buttonPanel, null);
buttonPanel.add(affrimButton, null);
buttonPanel.add(exitButton, null);
/////////////////////////////////////////////
reckoningInfoModel.addColumn("交易号");
reckoningInfoModel.addColumn("登记号");
reckoningInfoModel.addColumn("收入");
reckoningInfoModel.addColumn("日期");
reckoningInfoModel.addColumn("操作员");
reckoningInfoTable.setPreferredScrollableViewportSize(new Dimension(130, 100));
reckoningInfoTable.setBackground(new Color(255, 255, 210));
reckoningInfoTable.setRowHeight(20);
reckoningInfoTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane reserveInfoscrollpane = new JScrollPane(reckoningInfoTable);
reckoningInfoPanel.add(reserveInfoscrollpane,BorderLayout.CENTER);
/////////////////////////////////////////////
//从 SearchReckoningInfo 类型对象获取帐户信息
Vector reckoningList = new Vector();
Reckoning reckoning = new Reckoning();
reckoningList = searchReckoningInfo.getReckoningInfo();
for(int i=0;i<reckoningList.size();i++)
{
reckoning=(Reckoning)reckoningList.get(i);
reckoningInfoModel.addRow(new Object[]{
reckoning.reckoningId+"",
reckoning.checkInGuestId.trim(),
reckoning.income+"",
reckoning.tradeDate.trim(),
reckoning.accountId.trim()
});
}
////////////////////////////////////
this.setVisible(true);
affrimButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
closeFrame();
}
});
exitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
closeFrame();
}
});
}/////////////////// jbInit end
//close this frame when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
closeFrame();
}
}
void closeFrame() {
this.dispose();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -