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