📄 usereditdialog.java
字号:
package com.ciash.bms.gui.impl;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Collection;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import com.ciash.bms.entity.User;
import com.ciash.bms.gui.uiInter.RegisterDialogUI;
import com.ciash.common.gui.tool.ToolKit;
import com.ciash.bms.gui.uiInter.UserEditDialogUI;
public class UserEditDialog extends JDialog implements RegisterDialogUI,
UserEditDialogUI {
private UserEditPanel editPanel = new UserEditPanel();
private JPanel jPanel1 = new JPanel();
private JButton cancel = new JButton();
private JButton confirm = new JButton();
private GridBagLayout gridBagLayout1 = new GridBagLayout();
private JDialog dialog = this;
private int option = -1;
public UserEditDialog() {
this(null, "", true);
}
private UserEditDialog(Frame frame, String title, boolean modal) {
super(frame, title, modal);
jbInit();
Listener listener = new Listener();
confirm.addActionListener(listener);
cancel.addActionListener(listener);
this.addWindowListener(listener);
}
public int showDialog(Collection pops) {
setTitle("注册");
editPanel.setSelectUser(null);
editPanel.setPopedoms(pops);
setVisible(true);
return this.option;
}
public int getOption() {
return option;
}
public User getUser() {
return editPanel.getSelectUser();
}
public void setPopedom(Collection pops) {
editPanel.setPopedoms(pops);
}
// ---------------------------------------------------------------------------------------------
// JB9 自带控件设计方法
private void jbInit() {
getContentPane().setLayout(new BorderLayout());
cancel.setText("取消");
confirm.setText("确定");
jPanel1.setLayout(gridBagLayout1);
jPanel1.setOpaque(true);
getContentPane().add(editPanel, BorderLayout.CENTER);
this.getContentPane().add(jPanel1, BorderLayout.SOUTH);
jPanel1.add(confirm, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(
5, 153, 5, 32), 0, 0));
jPanel1.add(cancel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(
5, 0, 5, 154), 0, 0));
setSize(470, 390);
setLocation(ToolKit.getScreenCenterLocation(getSize()));
}
// ---------------------------------------------------------------------------------------------
// 继续实现事件驱动内部封装
private class Listener extends WindowAdapter implements ActionListener {
public final static String CONFIRM = "确定";
public final static String CANCEL = "取消";
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if (command.equals(CONFIRM)) {
if (editPanel.checkValues()) {
option = OK_OPTION;
setVisible(false);
}
} else if (command.equals(CANCEL)) {
option = CANCEL_OPTION;
setVisible(false);
}
}
public void windowClosing(WindowEvent e) {
option = CANCEL_OPTION;
setVisible(false);
}
}
// ---------------------------------------------------------------------------------------------
public int showDialog(User user, Collection pops) {
setTitle("编辑用户");
editPanel.setSelectUser(user);
editPanel.setPopedoms(pops);
setVisible(true);
return this.option;
}
public int showDialog() {
try {
throw new Exception();
} catch (Exception e) {
System.exit(-1);
e.printStackTrace();
}
return -1023123123;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -