Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.programmer Subject: Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Date: Tue, 17 Jul 2012 11:32:08 -0400 Organization: A noiseless patient Spider Lines: 32 Message-ID: References: <34011151-6528-4f4c-815c-df9e8353cb71@googlegroups.com> <_40Nr.24747$cE7.24028@newsfe13.iad> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 17 Jul 2012 15:29:43 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="dbab98bdd12434f87ad48400212f412c"; logging-data="13211"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/jflJQoYdfd3Z4GhYCfIE1265f8CddlE0=" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20120613 Icedove/3.0.11 In-Reply-To: <_40Nr.24747$cE7.24028@newsfe13.iad> Cancel-Lock: sha1:4gXtXr0UkbzmfcAQoX2nt+qySKw= Xref: csiph.com comp.lang.java.programmer:16067 On 07/16/2012 05:55 PM, Daniel Pitts wrote: > On 7/16/12 1:13 PM, Jeff Higgins wrote: >> On 07/16/2012 03:53 PM, clusardi2k@aol.com wrote: >>> Hello, can anyone give me a simple/complete example to replace >>> jLst.getSelectedValues() below using jLst.getSelectedValuesList(). >>> >>> Object str_array []; >>> >>> if ( !jLst.isSelectionEmpty() ) >>> { >>> str_array = jLst.getSelectedValues(); >>> >>> System.out.println("Selected: " + str_array[0]); >>> } >> I think the java.util.List interface has a method to return an array. >> > Indeed it does, but that is terrible advice. > > jList.getSelectedValuesList().get(0) is equivalent to > jList.getSelectedValues()[0]; > Is a jList equivalent to a jLst? Are either of them equivalent to a javax.swing.JList? Upon further reflection, it seems to me that the only correct answer to clusardi2k@aol.com's question is "no" and that any /advice/s given under the assumption that a jLst is meant to indicate a javax.swing.JList are equally terrible. One is free to comment on the apparent absurdity of the code provided, but those comments are better addressed to the original poster of the code rather than to another respondent whose /advice/ is as terrible as one's own.