01: package com.calipso.reportgenerator.usermanager;
02:
03: import com.calipso.reportgenerator.common.LanguageTraslator;
04: import com.calipso.reportgenerator.common.AbsoluteLayout;
05: import com.calipso.reportgenerator.common.AbsoluteConstraints;
06:
07: import javax.swing.*;
08: import java.util.ArrayList;
09: import java.awt.*;
10: import java.awt.event.ActionListener;
11: import java.awt.event.ActionEvent;
12:
13: /**
14: * frame para agregar usuarios a la lista de userManagerModifyFrame
15: */
16: public class AddRoltoUserFrame extends JDialog {
17: private JPanel jpanel;
18: private JList listRols;
19: private DefaultListModel listModel;
20: private JButton accept;
21: private JButton cancel;
22: private Object[] rols;
23: private ArrayList list;
24:
25: public AddRoltoUserFrame(JDialog parent, ArrayList list) {
26: super (parent, true);
27: this .list = list;
28: initComponents();
29: }
30:
31: private void initComponents() {
32: jpanel = new JPanel();
33:
34: accept = new JButton();
35: cancel = new JButton();
36:
37: getContentPane().setLayout(new AbsoluteLayout());
38: jpanel.setLayout(new AbsoluteLayout());
39:
40: listModel = new DefaultListModel();
41:
42: for (int i = 0; i < list.size(); i++) {
43: listModel.addElement(list.get(i));
44: }
45:
46: listRols = new JList(listModel);
47:
48: listRols
49: .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
50:
51: listRols.setVisible(true);
52:
53: JScrollPane scrollpane = new JScrollPane(listRols);
54:
55: accept.setText(LanguageTraslator.traslate("112"));
56: jpanel.add(accept, new AbsoluteConstraints(5, 190, 90, 25));
57: accept.addActionListener(new Listener());
58:
59: cancel.setText(LanguageTraslator.traslate("113"));
60: jpanel.add(cancel, new AbsoluteConstraints(90, 190, 90, 25));
61:
62: jpanel.add(scrollpane, new AbsoluteConstraints(0, 0, 180, 180));
63:
64: setResizable(false);
65: getContentPane().add(jpanel,
66: new AbsoluteConstraints(0, 0, 180, 220));
67:
68: Dimension scrn = getToolkit().getScreenSize();
69:
70: this .setLocation((scrn.width - getWidth()) / 3 + 270,
71: (scrn.height - getHeight()) / 3 + 150);
72:
73: cancel.addActionListener(new Listener());
74: accept.addActionListener(new Listener());
75: pack();
76:
77: }
78:
79: class Listener implements ActionListener {
80:
81: public void actionPerformed(ActionEvent e) {
82: if (e.getSource() == cancel) {
83: setVisible(false);
84: } else if (e.getSource() == accept
85: && listRols.getSelectedValues() != null) {
86: rols = new Object[listRols.getSelectedValues().length];
87:
88: rols = listRols.getSelectedValues();
89: setVisible(false);
90: }
91: }
92: }
93:
94: public Object[] getRols() {
95:
96: return rols;
97: }
98:
99: }
|