📄 usertorolemappingdialog.java
字号:
package custom_management;
import javax.swing.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collections;
import java.util.Collection;
import java.util.ArrayList;
import java.util.*;
public class UserToRoleMappingDialog
extends JDialog {
private UserDialog frame = new UserDialog();
// private String action = "";
public UserToRoleMappingDialog() {
}
public UserToRoleMappingDialog(UserDialog frame1 ,String title ,boolean model) {
super(frame1,title,model);
frame = frame1;
// action = frame1.action;
try {
jbInit();
initRoleMappedAndNotMapped();////
}
catch (Exception ex) {
ex.printStackTrace();
}
}
private void jbInit() throws Exception {
this.getContentPane().setLayout(xYLayout1);
this.setSize(new Dimension(400,350));
jLabel1.setText("用户编号");
jLabel2.setText("姓名");
jLabel3.setText("未映射的角色");
jLabel4.setText("已映射的角色");
jButton1.setText("添加 >>");
jButton1.addActionListener(new
UserToRoleMappingDialog_jButton1_actionAdapter(this));
jButton2.setText("删除 <<");
jButton2.addActionListener(new
UserToRoleMappingDialog_jButton2_actionAdapter(this));
jButton3.setText("确 定");
jButton3.addActionListener(new
UserToRoleMappingDialog_jButton3_actionAdapter(this));
jButton4.setText("取 消");
jButton4.addActionListener(new
UserToRoleMappingDialog_jButton4_actionAdapter(this));
this.getContentPane().add(jTextField2, new XYConstraints(233, 16, 117, -1));
this.getContentPane().add(jTextField1, new XYConstraints(69, 16, 117, -1));
this.getContentPane().add(jScrollPane1, new XYConstraints(17, 77, 128, 169));
this.getContentPane().add(jScrollPane2, new XYConstraints(227, 77, 128, 169));
jScrollPane2.getViewport().add(jList2);
jScrollPane1.getViewport().add(jList1);
this.getContentPane().add(jButton4, new XYConstraints(227, 266, -1, -1));
this.getContentPane().add(jButton3, new XYConstraints(88, 266, -1, -1));
this.getContentPane().add(jButton2, new XYConstraints(152, 161, 69, -1));
this.getContentPane().add(jButton1, new XYConstraints(152, 117, -1, -1));
this.getContentPane().add(jLabel4, new XYConstraints(227, 56, -1, -1));
this.getContentPane().add(jLabel3, new XYConstraints(17, 52, -1, -1));
this.getContentPane().add(jLabel2, new XYConstraints(203, 16, -1, -1));
this.getContentPane().add(jLabel1, new XYConstraints(16, 16, -1, -1));
jTextField1.setText(frame.jTextField1.getText());
jTextField2.setText(frame.jTextField2.getText());
jTextField1.setEditable(false);
jTextField2.setEditable(false);
}
private void initRoleMappedAndNotMapped()
{
jList1.setModel(listModel1);
jList2.setModel(listModel2);
jList1.setListData(frame.roleNotMapped.toArray());
jList2.setListData(frame.roleMapped.toArray());
}
XYLayout xYLayout1 = new XYLayout();
JTextField jTextField1 = new JTextField();
JTextField jTextField2 = new JTextField();
JScrollPane jScrollPane1 = new JScrollPane();
JList jList1 = new JList();
DefaultListModel listModel1 = new DefaultListModel();
DefaultListModel listModel2 = new DefaultListModel();
JList jList2 = new JList();
JScrollPane jScrollPane2 = new JScrollPane();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JButton jButton4 = new JButton();
public void jButton3_actionPerformed(ActionEvent actionEvent) {
this.dispose();
}
public void jButton1_actionPerformed(ActionEvent actionEvent) {
Object[] ob = jList1.getSelectedValues();
if (ob != null && ob.length > 0)
for (int i = 0, len = ob.length; i < len; i++) {
frame.roleNotMapped.remove(ob[i]);
frame.roleMapped.add(ob[i]);
jList1.setListData(frame.roleNotMapped.toArray());
jList2.setListData(frame.roleMapped.toArray());
}
}
public void jButton2_actionPerformed(ActionEvent actionEvent) {
Object[] ob = jList2.getSelectedValues();
if (ob != null && ob.length > 0 )
for(int i=0 ,len = ob.length ; i < len; i++) {
frame.roleNotMapped.add(ob[i]);
frame.roleMapped.remove(ob[i]);
jList1.setListData(frame.roleNotMapped.toArray());
jList2.setListData(frame.roleMapped.toArray());
}
}
public void jButton4_actionPerformed(ActionEvent actionEvent) {
this.dispose();
}
}
class UserToRoleMappingDialog_jButton4_actionAdapter
implements ActionListener {
private UserToRoleMappingDialog adaptee;
UserToRoleMappingDialog_jButton4_actionAdapter(UserToRoleMappingDialog
adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent) {
adaptee.jButton4_actionPerformed(actionEvent);
}
}
class UserToRoleMappingDialog_jButton2_actionAdapter
implements ActionListener {
private UserToRoleMappingDialog adaptee;
UserToRoleMappingDialog_jButton2_actionAdapter(UserToRoleMappingDialog
adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent) {
adaptee.jButton2_actionPerformed(actionEvent);
}
}
class UserToRoleMappingDialog_jButton1_actionAdapter
implements ActionListener {
private UserToRoleMappingDialog adaptee;
UserToRoleMappingDialog_jButton1_actionAdapter(UserToRoleMappingDialog
adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent) {
adaptee.jButton1_actionPerformed(actionEvent);
}
}
class UserToRoleMappingDialog_jButton3_actionAdapter
implements ActionListener {
private UserToRoleMappingDialog adaptee;
UserToRoleMappingDialog_jButton3_actionAdapter(UserToRoleMappingDialog
adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent) {
adaptee.jButton3_actionPerformed(actionEvent);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -