001 package sharpster.client.gui; 002 003 /** 004 * <p>Title: </p> 005 * <p>Description: </p> 006 * <p>Copyright: Copyright (c) 2003</p> 007 * <p>Company: Kafka</p> 008 * @author Tommy Eriksson 009 * @version 1.0 010 */ 011 012 import java.awt.*; 013 import java.awt.event.*; 014 import javax.swing.*; 015 016 017 public class ListAllFrame extends JDialog { 018 JPanel contentPane; 019 JButton jButtonOk = new JButton(); 020 JTextField jTextField1 = new JTextField(); 021 JLabel jLabelAddUser = new JLabel(); 022 JLabel jLabeInGroup = new JLabel(); 023 JScrollPane jScrollPane1 = new JScrollPane(); 024 String[] lista = {"tommy", "maria", "fiffi", "inja", "bajs", "kiss"}; 025 JList jList1 = new JList(lista); 026 String str = null; 027 028 029 // Construct the frame 030 public ListAllFrame() { 031 enableEvents(AWTEvent.WINDOW_EVENT_MASK); 032 try { 033 jbInit(); 034 } 035 catch (Exception e) { 036 e.printStackTrace(); 037 } 038 } 039 040 // Component initialization 041 private void jbInit() throws Exception { 042 contentPane = (JPanel) this.getContentPane(); 043 jButtonOk.setBounds(new Rectangle(74, 144, 47, 25)); 044 jButtonOk.setText("Ok"); 045 jButtonOk.addActionListener(new ListAllFrame_jButtonOk_actionAdapter(this)); 046 contentPane.setLayout(null); 047 this.setTitle("Sharpster"); 048 this.setSize(new Dimension(212, 214)); 049 050 jTextField1.setText("jTextField1"); 051 jTextField1.setBounds(new Rectangle(78, 23, 115, 21)); 052 jLabelAddUser.setVerifyInputWhenFocusTarget(true); 053 jLabelAddUser.setText("Add User:"); 054 jLabelAddUser.setBounds(new Rectangle(21, 26, 49, 15)); 055 jLabeInGroup.setText("In Group:"); 056 jLabeInGroup.setBounds(new Rectangle(24, 61, 50, 15)); 057 jScrollPane1.setBounds(new Rectangle(76, 61, 118, 69)); 058 contentPane.add(jTextField1, null); 059 contentPane.add(jLabelAddUser, null); 060 contentPane.add(jLabeInGroup, null); 061 contentPane.add(jButtonOk, null); 062 contentPane.add(jScrollPane1, null); 063 064 ListSelectionModel selectionModel = new SingleSelectionModel() { 065 public void updateSingleSelection(int oldIndex, int newIndex) { 066 str = (String)jList1.getModel().getElementAt(newIndex); 067 System.out.println(str); 068 } 069 }; 070 071 072 jList1.setSelectionModel(selectionModel); 073 jScrollPane1.getViewport().add(jList1, null); 074 } 075 076 void jButtonOk_actionPerformed(ActionEvent e) { 077 System.out.println(jTextField1.getText()); 078 System.out.println(str); 079 } 080 081 } 082 083 084 class ListAllFrame_jButtonOk_actionAdapter implements java.awt.event.ActionListener { 085 ListAllFrame adaptee; 086 087 ListAllFrame_jButtonOk_actionAdapter(ListAllFrame adaptee) { 088 this.adaptee = adaptee; 089 } 090 public void actionPerformed(ActionEvent e) { 091 adaptee.jButtonOk_actionPerformed(e); 092 } 093 }