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

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

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

and i cant add names anywhere else aprt from that method

Put this line

StringArray name= new StringArray();

outside the displayNames() method.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.