1 package com.calipso.reportgenerator.usermanager; 2 3 import com.calipso.reportgenerator.common.LanguageTraslator; 4 import com.calipso.reportgenerator.common.AbsoluteLayout; 5 import com.calipso.reportgenerator.common.AbsoluteConstraints; 6 7 import javax.swing.*; 8 import java.util.ArrayList ; 9 import java.awt.*; 10 import java.awt.event.ActionListener ; 11 import java.awt.event.ActionEvent ; 12 13 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.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 49 50 listRols.setVisible(true); 51 52 JScrollPane scrollpane = new JScrollPane(listRols); 53 54 accept.setText(LanguageTraslator.traslate("112")); 55 jpanel.add(accept,new AbsoluteConstraints(5,190,90,25)); 56 accept.addActionListener(new Listener ()); 57 58 cancel.setText(LanguageTraslator.traslate("113")); 59 jpanel.add(cancel,new AbsoluteConstraints(90,190,90,25)); 60 61 jpanel.add(scrollpane, new AbsoluteConstraints(0, 0, 180, 180)); 62 63 setResizable(false); 64 getContentPane().add(jpanel, new AbsoluteConstraints(0, 0, 180,220)); 65 66 Dimension scrn = getToolkit().getScreenSize(); 67 68 this.setLocation((scrn.width-getWidth())/3+270,(scrn.height-getHeight())/3+150); 69 70 cancel.addActionListener(new Listener ()); 71 accept.addActionListener(new Listener ()); 72 pack(); 73 74 } 75 76 class Listener implements ActionListener { 77 78 public void actionPerformed(ActionEvent e) { 79 if( e.getSource() == cancel) { 80 setVisible(false); 81 } 82 else if( e.getSource() == accept && listRols.getSelectedValues() != null ) { 83 rols = new Object [listRols.getSelectedValues().length]; 84 85 rols = listRols.getSelectedValues(); 86 setVisible(false); 87 } 88 } 89 } 90 91 public Object [] getRols() { 92 93 return rols; 94 } 95 96 97 } 98 | Popular Tags |