0

hey,
i got a method that returns value which is java.util.List<java.lang.String>. this method actually contain data that was stored from .txt file which is simply names of people.


how can i display this in the JList or how can i convert this value to a simple array so later i can work with it.
this is a method that i need to work with

public StringArray displayNames() {

    StringArray name= new StringArray();

      
              name.add("tom");   
              name.add("james");
              name.add("lawrence");

     return name;
    }

i call this method and the value returned from it needs to be displayed in JList

Thank You

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by quuba
0

Don't see why you don't use the JList for data processing.
After all a JList is just an ArrayList with GUI features

0

thanks for the replys,
@quuba

well for your number two i already have added the names to the list as shown in the example method above. and i cant add names anywhere else aprt from that method (that is how it has to work..)

im still not very clear how to structure the code ...
could you send me a different example using my method please so i would be a bit more clearer how structure the code.


thank you very much

0

and i cant add names anywhere else aprt from that method

Put this line

StringArray name= new StringArray();

outside the displayNames() method.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.