?? querycustomerwin.java
字號:
package org.itstar.netbar.swing;
import javax.swing.SwingUtilities;
import javax.swing.JFrame;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import org.itstar.netbar.bean.CustomerBean;
import org.itstar.netbar.domain.ICustomerDomain;
import org.itstar.netbar.domain.impl.CustomerDomainImpl;
import java.awt.Rectangle;
public class QueryCustomerWin {
private JFrame jFrame = null; // @jve:decl-index=0:visual-constraint="10,10"
private JScrollPane jScrollPane = null;
private JTable jTable = null;
/**
* This method initializes jScrollPane
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJTable());
}
return jScrollPane;
}
private TableModel getTableModel()
{
CustomerBean cBean=new CustomerBean();
ICustomerDomain cDomain=new CustomerDomainImpl();
List list=new ArrayList();
list=cDomain.queryAll();
Iterator it=list.iterator();
Object[] columnName={"會員卡號","卡號密碼","卡上金額(元)","會員姓名","身份證號","注冊日期","卡號狀態","上次登錄"};
Object[][] cells=new Object[list.size()][8];
int i=0;
while(it.hasNext())
{
cBean=(CustomerBean)it.next();
cells[i][0]=cBean.getCusCardNum();
cells[i][1]=cBean.getCusCardPassword();
cells[i][2]=cBean.getCusBalance();
cells[i][3]=cBean.getCusName();
cells[i][4]=cBean.getCusPersonID();
cells[i][5]=cBean.getCusRegDate();
cells[i][6]=cBean.getCusCardState();
cells[i][7]=cBean.getCusLastLoginTime();
i++;
}
TableModel tableModel=new DefaultTableModel(cells,columnName);
return tableModel;
}
/**
* This method initializes jTable
*
* @return javax.swing.JTable
*/
private JTable getJTable() {
if (jTable == null) {
jTable = new JTable(getTableModel());
}
return jTable;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自動生成方法存根
SwingUtilities.invokeLater(new Runnable() {
public void run() {
QueryCustomerWin application = new QueryCustomerWin();
application.getJFrame().setVisible(true);
}
});
}
/**
* This method initializes jFrame
*
* @return javax.swing.JFrame
*/
public JFrame getJFrame() {
if (jFrame == null) {
jFrame = new JFrame();
jFrame.setAlwaysOnTop(true);
jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
jFrame.setBounds(new Rectangle(100, 120, 843, 538));
jFrame.setPreferredSize(new Dimension(500, 450));
jFrame.setContentPane(getJScrollPane());
jFrame.setTitle("會員信息");
}
return jFrame;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -