📄 vipbasedialog.java
字号:
package view.dialog.basedialog;
import java.awt.GridBagLayout;
import java.awt.event.MouseAdapter;
import java.util.Iterator;
import java.util.Vector;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import view.com.GBC;
import view.com.getcomponent.button.GetButton;
import vo.VipVo;
import action.implementclass.mouseaction.VipTableInfoAction;
import dao.VipDao;
/**
* 会员情况基类
* @author linfeng
*
*/
public class VipBaseDialog extends JDialog {
/**
* vip_id 会员编号
* vip_name 会员姓名
* price_pct 打折指数
* phone 电话
* vip_type 会员类型
* button 按钮数组
* names 字符串数组
* btnPanel 按钮面板
* panel 会员面板
* table 会员表格
* tableData 字符串对象
* mouseAction 鼠标事件
*/
public static JTextField vip_id, vip_name, price_pct, phone;
protected static JComboBox vip_type;
protected JButton[] button;
private String[] names = { "确定", "重置", "取消", "刷新" };
private JPanel btnPanel;
private JPanel panel;
public static JTable table;
public static String[] tableData;
private MouseAdapter mouseAction;
private String[] icon={"icon\\button\\确定.GIF","icon\\button\\重置.GIF","icon\\button\\取消.GIF","icon\\button\\刷新.GIF"};
private String[] argActionCommand = { "确定", "重置", "取消", "刷新" };
/**
* 初始化各种组件
*/
public void initialText() {
vip_id = new JTextField(12);
vip_name = new JTextField(12);
price_pct = new JTextField(12);
vip_type = new JComboBox();
vip_type.addItem("钻石VIP");
vip_type.addItem("黄金VIP");
vip_type.addItem("普通VIP");
phone = new JTextField(12);
}
/**
* 获得会员面板
* @return panel 会员面板
*/
public JPanel getPanel() {
panel = new JPanel();
initialText();
panel.setLayout(new GridBagLayout());
panel.add(new JLabel("会员编号"), new GBC(1, 0).setAnchor(GBC.EAST));
panel.add(this.vip_id, new GBC(2, 0).setInset(7).setWeight(3, 0));
panel.add(new JLabel("会员名称"), new GBC(1, 1).setAnchor(GBC.EAST));
panel.add(this.vip_name, new GBC(2, 1).setInset(7).setWeight(3, 0));
panel.add(new JLabel("打折指数"), new GBC(1, 2).setAnchor(GBC.EAST));
panel.add(this.price_pct, new GBC(2, 2).setInset(3).setWeight(3, 0));
panel.add(new JLabel("会员类型"), new GBC(1, 3).setAnchor(GBC.EAST));
panel.add(this.vip_type, new GBC(2, 3).setInset(7).setWeight(3, 0));
panel.add(new JLabel("会员电话"), new GBC(1, 4).setAnchor(GBC.EAST));
panel.add(this.phone, new GBC(2, 4).setInset(7).setWeight(3, 0));
return panel;
}
/**
* 获得按钮面板
* @return btnPanel 按钮面板
*/
public JPanel getBtnPanel() {
btnPanel = new JPanel();
button = new JButton[names.length];
button = new GetButton().getButton(button, names, icon, argActionCommand);
btnPanel.add(button[0]);
btnPanel.add(button[1]);
btnPanel.add(button[2]);
btnPanel.add(button[3]);
btnPanel.setBorder(BorderFactory.createTitledBorder("按钮组"));
return btnPanel;
}
/**
* 获得滚动条面板
* @return sp 滚动条面板
*/
public JScrollPane getJScrollPanel() {
JScrollPane sp = new JScrollPane(getJTable());
return sp;
}
/**
* 获得会员表格
* @return table 会员表格
*/
public JTable getJTable() {
if (table == null) {
Object[][] data = {};
String[] name = { "会员编号", "会员名称", "打折指数", "会员类型", "会员电话" };
DefaultTableModel model = new DefaultTableModel(data, name) {
public boolean isCellEditable(int row, int column) {
return false;
}
};
Vector vector = new VipDao().getVipInfo();
Iterator iter = vector.iterator();
while (iter.hasNext()) {
VipVo value = (VipVo) iter.next();
Object[] objData = { new Integer(value.getVip_id()),
value.getVip_name(), new Double(value.getPrice_pct()),
value.getVip_type(), new Long(value.getPhone()) };
model.addRow(objData);
}
table = new JTable(model);
mouseAction = new VipTableInfoAction(this);
table.addMouseListener(mouseAction);
}
return table;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -