List of usage examples for javax.swing JList JList
public JList(final Vector<? extends E> listData)
JList
that displays the elements in the specified Vector
. From source file:eu.europeana.sip.gui.SipCreatorGUI.java
public SipCreatorGUI() throws FileStoreException { super("Delving SIP Creator"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); MetadataModel metadataModel = loadMetadataModel(); File fileStoreDirectory = getFileStoreDirectory(); FileStore fileStore = new FileStoreImpl(fileStoreDirectory, metadataModel); GroovyCodeResource groovyCodeResource = new GroovyCodeResource(); this.dataSetListModel = new DataSetListModel(new DataSetListModel.ConnectedStatus() { @Override//w w w . j a va2 s. c o m public boolean isConnected() { return connectedBox.isSelected(); } }); this.dataSetList = new JList(dataSetListModel); this.sipModel = new SipModel(fileStore, metadataModel, groovyCodeResource, new PopupExceptionHandler()); this.dataSetClient = new DataSetClient(new DataSetClient.Context() { @Override public String getServerUrl() { return sipModel.getAppConfigModel().getServerUrl(); } @Override public String getAccessKey() { return sipModel.getAppConfigModel().getAccessKey(); } @Override public void setInfo(DataSetInfo dataSetInfo) { dataSetListModel.setDataSetInfo(dataSetInfo); dataSetActions.setDataSetInfo(dataSetInfo); } @Override public void setList(List<DataSetInfo> list) { if (list != null) { Set<String> untouched = dataSetListModel.setDataSetInfoList(list); if (!untouched.isEmpty()) { dataSetActions.setUntouched(untouched); } for (DataSetInfo dataSetInfo : list) { dataSetActions.setDataSetInfo(dataSetInfo); } } else { log.warn("received empty list from the server"); } } @Override public void tellUser(String message) { sipModel.getUserNotifier().tellUser(message); } @Override public void disconnected() { connectedBox.setSelected(false); sipModel.getUserNotifier().tellUser(String.format("Disconnected from Repository at %s", sipModel.getAppConfigModel().getServerHostPort())); } }); dataSetActions = new DataSetActions(this, sipModel, dataSetClient, new Runnable() { @Override public void run() { dataSetListModel.clear(); for (FileStore.DataSetStore dataSetStore : sipModel.getFileStore().getDataSetStores().values()) { dataSetListModel.setDataSetStore(dataSetStore); } dataSetListModel.setPattern(filter.getText()); } }); setJMenuBar(createMenuBar()); JPanel main = new JPanel(new BorderLayout(MARGIN, MARGIN)); main.setBorder(BorderFactory.createEmptyBorder(MARGIN, MARGIN, MARGIN, MARGIN)); JPanel north = new JPanel(new BorderLayout()); north.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(MARGIN, MARGIN, 0, MARGIN), BorderFactory.createRaisedBevelBorder())); titleLabel.setOpaque(true); titleLabel.setFont(new Font("Sans", Font.BOLD, 24)); JLabel northRight = new JLabel(new ImageIcon(getClass().getResource("/delving-logo.png"))); north.add(createFilterPanel(), BorderLayout.WEST); north.add(titleLabel, BorderLayout.CENTER); north.add(northRight, BorderLayout.EAST); getContentPane().add(north, BorderLayout.NORTH); getContentPane().add(main, BorderLayout.CENTER); JPanel south = new JPanel(new GridLayout(1, 0)); south.add(createConnectPanel()); south.add(createFinishedPanel()); getContentPane().add(south, BorderLayout.SOUTH); main.add(createList(), BorderLayout.CENTER); main.add(dataSetActions.getPanel(), BorderLayout.EAST); setSize(SIZE); setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - SIZE.width) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - SIZE.height) / 2); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { for (FileStore.DataSetStore dataSetStore : sipModel.getFileStore().getDataSetStores().values()) { dataSetListModel.setDataSetStore(dataSetStore); } } }); }
From source file:ExtendedDnDDemo.java
private JPanel createList() { DefaultListModel listModel = new DefaultListModel(); listModel.addElement("List 0"); listModel.addElement("List 1"); listModel.addElement("List 2"); listModel.addElement("List 3"); listModel.addElement("List 4"); listModel.addElement("List 5"); listModel.addElement("List 6"); listModel.addElement("List 7"); listModel.addElement("List 8"); JList list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); JScrollPane scrollPane = new JScrollPane(list); scrollPane.setPreferredSize(new Dimension(400, 100)); list.setDragEnabled(true);/*from ww w . j av a2s. com*/ list.setTransferHandler(new ListTransferHandler()); JPanel panel = new JPanel(new BorderLayout()); panel.add(scrollPane, BorderLayout.CENTER); panel.setBorder(BorderFactory.createTitledBorder("List")); return panel; }
From source file:fr.free.hd.servers.gui.PhonemView.java
@Override protected JComponent createControl() { final JPanel view = new JPanel(new BorderLayout()); Collection<Phonem> phonesList = phonemsDAO.getPhonems(); Map<String, Phonem> mapList = new HashMap<String, Phonem>(); for (Phonem phonem : phonesList) { mapList.put(phonem.getPhonem(), phonem); }// w ww .j ava 2s. co m final StatementListModel model = new StatementListModel(mapList); printCommand.setModel(model); printCommand.setFace(face); copyCommand.setModel(model); copyCommand.setFace(face); list = new JList(model); final JScrollPane sp = new JScrollPane(list); final JTextField field = new JTextField(); field.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { model.setString(field.getText()); } @Override public void insertUpdate(DocumentEvent e) { model.setString(field.getText()); } @Override public void removeUpdate(DocumentEvent e) { model.setString(field.getText()); } }); final PhonemListModel phonemModel = new PhonemListModel((List<Phonem>) phonesList); final JList phonemList = new JList(phonemModel); final JScrollPane spPhonemList = new JScrollPane(phonemList); phonemList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { // private int oldIndex = -1; @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting() == false) { Phonem innerPhonem = (Phonem) phonemModel.getElementAt(phonemList.getSelectedIndex()); field.setText(field.getText() + innerPhonem.getPhonem()); } } }); phonemList.setCellRenderer(new PhonemListRenderer()); list.setCellRenderer(new StatementPhonemListRenderer(face)); list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); list.setLayoutOrientation(JList.HORIZONTAL_WRAP); list.setVisibleRowCount(1); view.add(spPhonemList, BorderLayout.WEST); view.add(sp, BorderLayout.CENTER); view.add(field, BorderLayout.SOUTH); field.requestFocus(); return view; }
From source file:uk.co.petertribble.jangle.SnmpTreePanel.java
/** * Create a new SnmpTreePanel, starting exploration at the specified OID. * * @param startOID the OID to start from *///from www . ja va 2 s .com public SnmpTreePanel(String startOID) { this.startOID = startOID; setLayout(new BorderLayout()); jtpl = new JTabbedPane(); model = new DefaultListModel(); oidList = new ArrayList<SnmpObject>(); slist = new JList(model); slist.addListSelectionListener(this); slist.setCellRenderer(new SnmpListCellRenderer()); jtpl.add(SnmpResources.getString("SNMP.LIST.TEXT"), new JScrollPane(slist)); // we use explicit placement so the tabs can be manipulated later jtpr = new JTabbedPane(); // details tab jp1 = new JPanel(new BorderLayout()); jp2 = new JPanel(new BorderLayout()); tp = new JingleTextPane("text/plain"); jp1.add(new JScrollPane(tp)); // jp2 holds the chart jp2 = new JPanel(new BorderLayout()); JSplitPane jpt = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jp1, jp2); jpt.setOneTouchExpandable(true); jpt.setDividerLocation(120); jtpr.insertTab(SnmpResources.getString("SNMP.DETAILS.TEXT"), (Icon) null, jpt, (String) null, TAB_D); tpdesc = new JingleTextPane("text/plain"); jtpr.insertTab(SnmpResources.getString("SNMP.ABOUT.TEXT"), (Icon) null, new JScrollPane(tpdesc), (String) null, TAB_A); // siblings tab tpsiblings = new JingleTextPane("text/plain"); jp3 = new JPanel(new BorderLayout()); jp3t = new JPanel(new BorderLayout()); JSplitPane jps = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jp3t, jp3); jps.setOneTouchExpandable(true); jps.setDividerLocation(200); jtpr.insertTab(SnmpResources.getString("SNMP.SIBLINGS.TEXT"), (Icon) null, jps, (String) null, TAB_S); // cousins tab tpcousins = new JingleTextPane("text/plain"); jp4 = new JPanel(new BorderLayout()); jp4t = new JPanel(new BorderLayout()); JSplitPane jpc = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jp4t, jp4); jpc.setOneTouchExpandable(true); jpc.setDividerLocation(200); jtpr.insertTab(SnmpResources.getString("SNMP.COUSINS.TEXT"), (Icon) null, jpc, (String) null, TAB_C); // split pane to hold the lot JSplitPane psplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jtpl, jtpr); psplit.setOneTouchExpandable(true); psplit.setDividerLocation(200); add(psplit); }
From source file:org.jdal.swing.Selector.java
/** * Initialize component after construction. */// w w w . j a v a 2 s . c om @PostConstruct public void init() { if (availableList == null) { availableList = new JList<T>(available); } else { availableList.setModel(available); } if (selectedList == null) { selectedList = new JList<T>(selected); } else { selectedList.setModel(selected); } availableSearch.setVisible(showSearchFields); selectedSearch.setVisible(showSearchFields); JButton addButton = new JButton(new AddSelectedAction()); JButton removeButton = new JButton(new RemoveSelectedAction()); addButton.setMinimumSize(new Dimension(buttonWidth, buttonHeight)); removeButton.setMinimumSize(new Dimension(buttonWidth, buttonHeight)); JScrollPane availableScroll = new JScrollPane(availableList); JScrollPane selectedScroll = new JScrollPane(selectedList); availableScroll.setPreferredSize(new Dimension(listWidth, listheight)); selectedScroll.setPreferredSize(new Dimension(listWidth, listheight)); availableScroll.setMinimumSize(new Dimension(listWidth, listheight)); selectedScroll.setMinimumSize(new Dimension(listWidth, listheight)); // test message source if (messageSource == null) { messageSource = new ResourceBundleMessageSource(); ((ResourceBundleMessageSource) messageSource).setBasename("i18n.jdal"); } MessageSourceAccessor msa = new MessageSourceAccessor(messageSource); BoxFormBuilder fb = new BoxFormBuilder(); fb.row(Short.MAX_VALUE); fb.startBox(); fb.row(); fb.add(availableSearch); fb.row(); fb.add(FormUtils.newLabelForBox(msa.getMessage("Selector.available"))); fb.row(Short.MAX_VALUE); fb.add(availableScroll); fb.endBox(); fb.startBox(); fb.row(Short.MAX_VALUE); fb.add(Box.createVerticalGlue()); fb.row(buttonHeight); fb.add(removeButton); fb.row(Short.MAX_VALUE); fb.add(Box.createVerticalGlue()); fb.endBox(); fb.setMaxWidth(buttonWidth); fb.startBox(); fb.row(Short.MAX_VALUE); fb.add(Box.createVerticalGlue()); fb.row(buttonHeight); fb.add(addButton); fb.row(Short.MAX_VALUE); fb.add(Box.createVerticalGlue()); fb.endBox(); fb.setMaxWidth(buttonWidth); fb.startBox(); fb.row(); fb.add(selectedSearch); fb.row(); fb.add(FormUtils.newLabelForBox(msa.getMessage("Selector.selected"))); fb.row(Short.MAX_VALUE); fb.add(selectedScroll); fb.endBox(); setLayout(new BorderLayout()); add(fb.getForm(), BorderLayout.CENTER); }
From source file:events.FocusEventDemo.java
public void addComponentsToPane(final Container pane) { GridBagLayout gridbag = new GridBagLayout(); pane.setLayout(gridbag);//from w w w .j a v a2s . c o m GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; //Make column as wide as possible. JTextField textField = new JTextField("A TextField"); textField.setMargin(new Insets(0, 2, 0, 2)); textField.addFocusListener(this); gridbag.setConstraints(textField, c); add(textField); c.weightx = 0.1; //Widen every other column a bit, when possible. c.fill = GridBagConstraints.NONE; JLabel label = new JLabel("A Label"); label.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); label.addFocusListener(this); gridbag.setConstraints(label, c); add(label); String comboPrefix = "ComboBox Item #"; final int numItems = 15; Vector<String> vector = new Vector<String>(numItems); for (int i = 0; i < numItems; i++) { vector.addElement(comboPrefix + i); } JComboBox comboBox = new JComboBox(vector); comboBox.addFocusListener(this); gridbag.setConstraints(comboBox, c); add(comboBox); c.gridwidth = GridBagConstraints.REMAINDER; JButton button = new JButton("A Button"); button.addFocusListener(this); gridbag.setConstraints(button, c); add(button); c.weightx = 0.0; c.weighty = 0.1; c.fill = GridBagConstraints.BOTH; String listPrefix = "List Item #"; Vector<String> listVector = new Vector<String>(numItems); for (int i = 0; i < numItems; i++) { listVector.addElement(listPrefix + i); } JList list = new JList(listVector); list.setSelectedIndex(1); //It's easier to see the focus change //if an item is selected. list.addFocusListener(this); JScrollPane listScrollPane = new JScrollPane(list); gridbag.setConstraints(listScrollPane, c); add(listScrollPane); c.weighty = 1.0; //Make this row as tall as possible. c.gridheight = GridBagConstraints.REMAINDER; //Set up the area that reports focus-gained and focus-lost events. display = new JTextArea(); display.setEditable(false); //The setRequestFocusEnabled method prevents a //component from being clickable, but it can still //get the focus through the keyboard - this ensures //user accessibility. display.setRequestFocusEnabled(false); display.addFocusListener(this); JScrollPane displayScrollPane = new JScrollPane(display); gridbag.setConstraints(displayScrollPane, c); add(displayScrollPane); setPreferredSize(new Dimension(450, 450)); ((JPanel) pane).setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:gui.QTLResultsPanel.java
/** QTLResultsPanel(). * // ww w. j av a 2 s .c om * @param qtlResult = the QTL results to show. * @param order = the ordered result data this QTL was created from. */ public QTLResultsPanel(QTLResult qtlResult, OrderedResult order) { this.qtlResult = qtlResult; this.order = order; // Trait listbox traitModel = new DefaultListModel<Trait>(); for (Trait trait : qtlResult.getTraits()) { traitModel.addElement(trait); } traitList = new JList<Trait>(traitModel); traitList.addListSelectionListener(this); traitList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane sp1 = new JScrollPane(traitList); sp1.setPreferredSize(new Dimension(125, 50)); // Details text box details = new JTextArea(); details.setFont(new Font("Monospaced", Font.PLAIN, 11)); details.setMargin(new Insets(2, 5, 2, 5)); details.setEditable(false); details.setTabSize(6); JScrollPane sp4; if (AppFrame.tpmmode == AppFrame.TPMMODE_QTL) { simpleDetails = new JScrollPane(); simpleDetails.setFont(new Font("Monospaced", Font.PLAIN, 11)); simplesplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); simpleright = new JTextArea(); simpleright.setFont(new Font("Monospaced", Font.PLAIN, 11)); simpleright.setMargin(new Insets(2, 5, 2, 5)); simpleright.setEditable(false); simpleright.setTabSize(6); simplesplit.setRightComponent(new JScrollPane(simpleright)); simplesplit.setLeftComponent(simpleDetails); sp4 = new JScrollPane(simplesplit); } else { // TPM MODE NONSNP simpleright = new JTextArea(); simpleright.setFont(new Font("Monospaced", Font.PLAIN, 11)); simpleright.setMargin(new Insets(2, 5, 2, 5)); simpleright.setEditable(false); sp4 = new JScrollPane(simpleright); } lodDetails = new JTextArea(); lodDetails.setFont(new Font("Monospaced", Font.PLAIN, 11)); lodDetails.setMargin(new Insets(2, 5, 2, 5)); lodDetails.setEditable(false); lodDetails.setTabSize(6); JScrollPane sp3 = new JScrollPane(lodDetails); JTabbedPane tabs = new JTabbedPane(); JScrollPane sp2 = new JScrollPane(details); tabs.add(sp2, "Full Model"); tabs.add(sp4, "Simple Model"); tabs.add(sp3, "LOD Details"); // The splitpane splits = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splits.setTopComponent(new JPanel()); splits.setBottomComponent(tabs); splits.setResizeWeight(0.5); // pane2 JSplitPane splits2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splits2.setLeftComponent(sp1); splits2.setRightComponent(splits); setLayout(new BorderLayout()); add(new GradientPanel("QTL Analysis Results"), BorderLayout.NORTH); // add(sp1, BorderLayout.WEST); // add(splits); add(splits2); add(toolbar = new QTLResultsToolBar(this), BorderLayout.EAST); }
From source file:events.ListDataEventDemo.java
public ListDataEventDemo() { super(new BorderLayout()); //Create and populate the list model. listModel = new DefaultListModel(); listModel.addElement("Whistler, Canada"); listModel.addElement("Jackson Hole, Wyoming"); listModel.addElement("Squaw Valley, California"); listModel.addElement("Telluride, Colorado"); listModel.addElement("Taos, New Mexico"); listModel.addElement("Snowbird, Utah"); listModel.addElement("Chamonix, France"); listModel.addElement("Banff, Canada"); listModel.addElement("Arapahoe Basin, Colorado"); listModel.addElement("Kirkwood, California"); listModel.addElement("Sun Valley, Idaho"); listModel.addListDataListener(new MyListDataListener()); //Create the list and put it in a scroll pane. list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); list.setSelectedIndex(0);/* ww w .ja va2 s.c om*/ list.addListSelectionListener(this); JScrollPane listScrollPane = new JScrollPane(list); //Create the list-modifying buttons. addButton = new JButton(addString); addButton.setActionCommand(addString); addButton.addActionListener(new AddButtonListener()); deleteButton = new JButton(deleteString); deleteButton.setActionCommand(deleteString); deleteButton.addActionListener(new DeleteButtonListener()); ImageIcon icon = createImageIcon("Up16"); if (icon != null) { upButton = new JButton(icon); upButton.setMargin(new Insets(0, 0, 0, 0)); } else { upButton = new JButton("Move up"); } upButton.setToolTipText("Move the currently selected list item higher."); upButton.setActionCommand(upString); upButton.addActionListener(new UpDownListener()); icon = createImageIcon("Down16"); if (icon != null) { downButton = new JButton(icon); downButton.setMargin(new Insets(0, 0, 0, 0)); } else { downButton = new JButton("Move down"); } downButton.setToolTipText("Move the currently selected list item lower."); downButton.setActionCommand(downString); downButton.addActionListener(new UpDownListener()); JPanel upDownPanel = new JPanel(new GridLayout(2, 1)); upDownPanel.add(upButton); upDownPanel.add(downButton); //Create the text field for entering new names. nameField = new JTextField(15); nameField.addActionListener(new AddButtonListener()); String name = listModel.getElementAt(list.getSelectedIndex()).toString(); nameField.setText(name); //Create a control panel, using the default FlowLayout. JPanel buttonPane = new JPanel(); buttonPane.add(nameField); buttonPane.add(addButton); buttonPane.add(deleteButton); buttonPane.add(upDownPanel); //Create the log for reporting list data events. log = new JTextArea(10, 20); JScrollPane logScrollPane = new JScrollPane(log); //Create a split pane for the log and the list. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, listScrollPane, logScrollPane); splitPane.setResizeWeight(0.5); //Put everything together. add(buttonPane, BorderLayout.PAGE_START); add(splitPane, BorderLayout.CENTER); }
From source file:ListCutPaste.java
public ListCutPaste() { super(new BorderLayout()); lh = new ListTransferHandler(); JPanel panel = new JPanel(new GridLayout(1, 3)); DefaultListModel list1Model = new DefaultListModel(); list1Model.addElement("alpha"); list1Model.addElement("beta"); list1Model.addElement("gamma"); list1Model.addElement("delta"); list1Model.addElement("epsilon"); list1Model.addElement("zeta"); JList list1 = new JList(list1Model); list1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane sp1 = new JScrollPane(list1); sp1.setPreferredSize(new Dimension(400, 100)); list1.setDragEnabled(true);/* w w w. j a v a 2s . c o m*/ list1.setTransferHandler(lh); list1.setDropMode(DropMode.ON_OR_INSERT); setMappings(list1); JPanel pan1 = new JPanel(new BorderLayout()); pan1.add(sp1, BorderLayout.CENTER); pan1.setBorder(BorderFactory.createTitledBorder("Greek Alphabet")); panel.add(pan1); DefaultListModel list2Model = new DefaultListModel(); list2Model.addElement("uma"); list2Model.addElement("dois"); list2Model.addElement("tres"); list2Model.addElement("quatro"); list2Model.addElement("cinco"); list2Model.addElement("seis"); JList list2 = new JList(list2Model); list2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list2.setDragEnabled(true); JScrollPane sp2 = new JScrollPane(list2); sp2.setPreferredSize(new Dimension(400, 100)); list2.setTransferHandler(lh); list2.setDropMode(DropMode.INSERT); setMappings(list2); JPanel pan2 = new JPanel(new BorderLayout()); pan2.add(sp2, BorderLayout.CENTER); pan2.setBorder(BorderFactory.createTitledBorder("Portuguese Numbers")); panel.add(pan2); DefaultListModel list3Model = new DefaultListModel(); list3Model.addElement("adeen"); list3Model.addElement("dva"); list3Model.addElement("tri"); list3Model.addElement("chyetirye"); list3Model.addElement("pyat"); list3Model.addElement("shest"); JList list3 = new JList(list3Model); list3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list3.setDragEnabled(true); JScrollPane sp3 = new JScrollPane(list3); sp3.setPreferredSize(new Dimension(400, 100)); list3.setTransferHandler(lh); list3.setDropMode(DropMode.ON); setMappings(list3); JPanel pan3 = new JPanel(new BorderLayout()); pan3.add(sp3, BorderLayout.CENTER); pan3.setBorder(BorderFactory.createTitledBorder("Russian Numbers")); panel.add(pan3); setPreferredSize(new Dimension(500, 200)); add(panel, BorderLayout.CENTER); }
From source file:csh.vctt.launcher.Launcher.java
/** * Prompt the user to select their character from a dialog. * @return Unique id number of the selected character. *///w ww . j a v a 2 s . com private String getPlayerSelection() { String selectedId = "-1"; String outfitMembersJson = DataManager.execQuery(DataManager.M_OUTFITMEMBER_SELECT_QUERY); List<Player> outfitMembers = DataManager.getOutfitMembers(outfitMembersJson); Object[] outfitMembersArrObj = outfitMembers.toArray(); Player[] outfitMembersArr = new Player[outfitMembersArrObj.length]; for (int i = 0; i < outfitMembersArrObj.length; i++) { outfitMembersArr[i] = (Player) outfitMembersArrObj[i]; } JList<Player> memSelList = new JList<Player>(outfitMembersArr); memSelList.setVisibleRowCount(10); JScrollPane memScrollPane = new JScrollPane(memSelList); memScrollPane.setPreferredSize(new Dimension(200, 400)); int userAction = JOptionPane.showConfirmDialog(null, memScrollPane, "Select Character and Press Ok", JOptionPane.PLAIN_MESSAGE); Player selectedPlayer = null; if (userAction == JOptionPane.YES_OPTION) { selectedPlayer = memSelList.getSelectedValue(); } if (selectedPlayer != null) { selectedId = selectedPlayer.getId(); } return selectedId; }