java - How to iterate through an ArrayList and only pull out 1 field from each object -
I am working on a jellist issue. I have an array list of the arrays in which there are 3 fields. I want to give the last name, first name in JLIS but only to find out how to remove the last objects from ArrayList
any help Would be appreciated. Thanks
Import java.awt.EventQueue; Import java.lang.reflect.Array; Import java.util.ArrayList; Import java.util.list; Import javax.swing.JFrame; Import javax.swing.JList; Import javax.swing.ListModel; Import javax.swing.List SelectionModel; Import javax.swing.AbstractListModel; Public Class Testing Listings {Private Jeffrey Frame; string value; / ** * Launch Application * / Public Fixed Zero Main (String [] Elps) {EventQueue.invokeLater (New Runnabal () (Public Zero Void) ({TestingListsGUI window = New TestingListsGUI (); window.frame.setVisible (true );} Catch (exception e) {e.printStackTrace ();}}}};} / ** * create apps * / public test list () {start ();} / ** * start the content of the frame * / Private Zero Start () {frame = new JFrame (); frame.Setbound (100, 100, 450, 300); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); frame.getContentPane () setLayout (zero). // Array Create list & Ultimate list & lt; JListsTesting & gt; MyList = New Arrestist & lt; JListsTesting & gt; (); MyList.add (New Jellies Testing ("Bruce", "James", "Completely Amazing")); MyList MyList.add (New Jellies Testing ("Sanders", "Colonel", "The Chicken Mister")); MyList.add (New Jellies Testing ("Potter", "Harry", "A Magician"); MyList.add New Jellies Testing ("Bond", "James", "To Get License")) Value = New String [myList.size ()]; For (int i = 0; i
- do not use
Blank
LayoutManager
. read ahead. -
Use the next code to fill the values:
for (int i = 0; i
-
You need a custom model for JList
, just type code with the code manufacturer JList
Create:
JList & lt; String & gt; List = New JList & lt; String & gt; (Values);
Also read
Comments
Post a Comment