package com.mwq.frame.common;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTable;
public class DeptAndPersonnelDialog extends JDialog {
public static void main(String args[]) {
try {
DeptAndPersonnelDialog dialog = new DeptAndPersonnelDialog();
dialog.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
private final DeptAndPersonnelPanel panel = new DeptAndPersonnelPanel();
private final JTable table = panel.getTable();
private final Vector<Vector<String>> selectedRecordV = new Vector<Vector<String>>();
/**
* Create the dialog
*/
public DeptAndPersonnelDialog() {
super();
setModal(true);
setTitle("按部门查找员工");
setBounds(100, 100, 550, 400);
getContentPane().add(panel, BorderLayout.CENTER);
final JPanel buttonPanel = new JPanel();
final FlowLayout flowLayout = new FlowLayout();
flowLayout.setAlignment(FlowLayout.RIGHT);
buttonPanel.setLayout(flowLayout);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
final JButton selectAllButton = new JButton();
selectAllButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
table.selectAll();
}
});
selectAllButton.setText("全选");
buttonPanel.add(selectAllButton);
final JButton addButton = new JButton();
addButton.addActionListener(new ActionListener() {// 捕获按钮被按下的事件
public void actionPerformed(ActionEvent e) {
int[] rows = table.getSelectedRows();// 获得选中行的索引
int columnCount = table.getColumnCount();// 获得表格的列数
for (int row = 0; row < rows.length; row++) {
Vector<String> recordV = new Vector<String>();// 创建一个向量对象,代表表格的一行
for (int column = 0; column < columnCount; column++) {
recordV.add(table.getValueAt(rows[row], column)
.toString());// 将表格中的值添加到向量中
}
selectedRecordV.add(recordV);// 将代表选中行的向量添加到另一个向量中
}
}
});
addButton.setText("添加");// 设置按钮的名称
buttonPanel.add(addButton);
final JButton exitButton = new JButton();
exitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
setVisible(false);
}
});
exitButton.setText("退出");
buttonPanel.add(exitButton);
//
}
public DeptAndPersonnelPanel getPanel() {
return panel;
}
public Vector getSelectedRecordV() {
return selectedRecordV;
}
}
最近下载更多
caomin LV4
2023年5月19日
poipoiiop LV8
2023年1月8日
赵佳倩 LV1
2022年10月19日
qinshizun LV1
2022年8月22日
微信网友_6084258495877120 LV1
2022年8月11日
baoligeer LV5
2022年6月2日
姜广坤 LV14
2022年5月20日
12koko LV3
2022年4月19日
wanglinddad LV55
2022年4月14日
刘先生-OL LV13
2022年3月23日
最近浏览更多
微信网友_7556429449121792
6月16日
暂无贡献等级
xdd123456
2024年12月26日
暂无贡献等级
zhao鑫
2024年12月19日
暂无贡献等级
KKKing0908
2024年10月7日
暂无贡献等级
微信网友_7180079327236096
2024年9月23日
暂无贡献等级
ljiahao2024
2024年9月5日
暂无贡献等级
255921158 LV5
2024年7月17日
wangming32 LV1
2024年7月15日
ZALZXB20030525
2024年7月1日
暂无贡献等级
微信网友_5986558820093952 LV4
2024年6月29日

