Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #16047 > unrolled thread
| Started by | clusardi2k@aol.com |
|---|---|
| First post | 2012-07-16 12:53 -0700 |
| Last post | 2012-07-17 09:30 -0700 |
| Articles | 6 on this page of 26 — 13 participants |
Back to article view | Back to comp.lang.java.programmer
Using getSelectedValuesList() instead of the deprecated getSelectedValues() clusardi2k@aol.com - 2012-07-16 12:53 -0700
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Jeff Higgins <jeff@invalid.invalid> - 2012-07-16 16:13 -0400
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-07-16 14:55 -0700
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Jeff Higgins <jeff@invalid.invalid> - 2012-07-16 19:47 -0400
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() markspace <-@.> - 2012-07-16 18:05 -0700
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Lew <lewbloch@gmail.com> - 2012-07-16 19:46 -0700
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Jeff Higgins <jeff@invalid.invalid> - 2012-07-17 07:38 -0400
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Steven Simpson <ss@domain.invalid> - 2012-07-17 13:45 +0100
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Lars Enderin <lars.enderin@telia.com> - 2012-07-17 19:46 +0200
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-07-17 20:47 +0200
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-07-17 12:26 -0700
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Lew <lewbloch@gmail.com> - 2012-07-17 14:16 -0700
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Joerg Meier <joergmmeier@arcor.de> - 2012-07-18 16:08 +0200
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Martin Gregorie <martin@address-in-sig.invalid> - 2012-07-18 21:33 +0000
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-07-18 23:36 +0200
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Martin Gregorie <martin@address-in-sig.invalid> - 2012-07-18 21:53 +0000
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-07-19 00:12 +0200
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() markspace <-@.> - 2012-07-18 15:53 -0700
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-07-18 16:18 -0700
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Gene Wirchenko <genew@ocis.net> - 2012-07-18 18:06 -0700
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Martin Gregorie <martin@address-in-sig.invalid> - 2012-07-18 23:44 +0000
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Jeff Higgins <jeff@invalid.invalid> - 2012-07-17 11:32 -0400
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2012-07-16 14:12 -0700
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Lew <lewbloch@gmail.com> - 2012-07-16 14:12 -0700
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Jeff Higgins <jeff@invalid.invalid> - 2012-07-17 07:29 -0400
Re: Using getSelectedValuesList() instead of the deprecated getSelectedValues() Roedy Green <see_website@mindprod.com.invalid> - 2012-07-17 09:30 -0700
Page 2 of 2 — ← Prev page 1 [2]
| From | Martin Gregorie <martin@address-in-sig.invalid> |
|---|---|
| Date | 2012-07-18 23:44 +0000 |
| Message-ID | <ju7hov$fc8$1@localhost.localdomain> |
| In reply to | #16093 |
On Thu, 19 Jul 2012 00:12:10 +0200, Daniele Futtorovic wrote: > On 18/07/2012 23:53, Martin Gregorie allegedly wrote: >> On Wed, 18 Jul 2012 23:36:28 +0200, Daniele Futtorovic wrote: >>> On 18/07/2012 23:33, Martin Gregorie allegedly wrote: >>>> BAAFNRAA = Bugs Anywhere, Anytime For No Reason At All. >>> >>> Rubbish. There's always a reason for bugs. >>> >>> /readies excuse calendar/ Try me. >> >> Even if the 'reason' is "We don't believe in regression testing"? > > Hmm. I was thinking more along the lines of solar flares, alignment of > planets, the bus having a flat tire or the NIC having run out of bits. > > I think one should generally avoid faith-based bug-reasoning. Too easy > to attack; not peremptory enough. Amateurish, in a nutshell. /waves > disdainfully/ > If you must know, I couldn't resist misquoting some Frank Zappa initial slang: AAFNRAA (Anything Anytime For No Reason At All). This is equivalent, roughly, to the statement that anything is art if you put a frame round it. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |
[toc] | [prev] | [next] | [standalone]
| From | Jeff Higgins <jeff@invalid.invalid> |
|---|---|
| Date | 2012-07-17 11:32 -0400 |
| Message-ID | <ju40d7$csr$1@dont-email.me> |
| In reply to | #16054 |
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<E> 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.
[toc] | [prev] | [next] | [standalone]
| From | Knute Johnson <nospam@rabbitbrush.frazmtn.com> |
|---|---|
| Date | 2012-07-16 14:12 -0700 |
| Message-ID | <ju2031$u73$1@dont-email.me> |
| In reply to | #16047 |
On 7/16/2012 12: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]);
> }
>
import javax.swing.*;
import java.util.*;
public class test {
public static void main(String[] args) {
String[] data = {"Hello","World!"};
JList<String> list = new JList<String>(data);
// select some
list.setSelectedIndices(new int[] {0,1});
// print the selected list
System.out.println(list.getSelectedValuesList());
}
}
C:\Documents and Settings\Knute Johnson>java test
[Hello, World!]
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-07-16 14:12 -0700 |
| Message-ID | <c33579d6-f154-45d7-bf84-f51d6bb113f5@googlegroups.com> |
| In reply to | #16047 |
(unknown) 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]);
> }
http://sscce.org/
FIrst, please follow the Java Coding Conventions, particularly with
respect to naming conventions. (Your opening-brace placement is
a commonly-accepted variation.)
Second, use names that are more indicative of purpose rather
than type, and are somewhat more verbose.
Third, show the types of your variables in code samples, at a
minimum. What is the type of 'jLst'?
I assume that 'getSelectedValues()' returns a collection of some kind.
For some bizarre reason you want to copy that collection into an
array simply to obtain the element in the first position. Is that correct?
Why not use 'get(0)' or 'iterator().next()'?
If you truly need an array, Jeff Higgins's advice is good.
What is the base type of the collection returned by 'getSelectedValues()'?
--
Lew
[toc] | [prev] | [next] | [standalone]
| From | Jeff Higgins <jeff@invalid.invalid> |
|---|---|
| Date | 2012-07-17 07:29 -0400 |
| Message-ID | <ju3i76$k9v$1@dont-email.me> |
| In reply to | #16047 |
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]);
> }
No.[1]
[1] It was pointed out in <_40Nr.24747$cE7.24028@newsfe13.iad> that I
gave you terrible advice. Please accept my apology.
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-07-17 09:30 -0700 |
| Message-ID | <om4b08hic80il5b44031grslin01c9mrg4@4ax.com> |
| In reply to | #16047 |
On Mon, 16 Jul 2012 12:53:57 -0700 (PDT), clusardi2k@aol.com wrote, quoted or indirectly quoted someone who said : >Hello, can anyone give me a simple/complete example to replace jLst.getSelectedValues() below using jLst.getSelectedValuesList(). this is a general tip for that sort of problem. Just google for "getSelectedValuesList" There is so much Java code spidered, you will likely find something well-commented. Make sure it is the right class and package though. -- Roedy Green Canadian Mind Products http://mindprod.com The greatest shortcoming of the human race is our inability to understand the exponential function. ~ Dr. Albert A. Bartlett (born: 1923-03-21 age: 89) http://www.youtube.com/watch?v=F-QA2rkpBSY
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.java.programmer
csiph-web