jason
jason

Reputation: 1172

How do i add elements to a jList from another class?

I am using netbeans 6.9.1. I have a jframe, and the jframe has a jList and the DefaultListModel name is lm. I would like to add elements to this jList using another class, but i can't figure out how, and can't find anything on it online...I guess i have to find a way to get the DefaultListmodel into my class also...?

thanks -jason

Upvotes: 0

Views: 998

Answers (2)

npinti
npinti

Reputation: 52185

Assuming that the ListModel is created at an earlier stage (like when the JFrame class is initialized), you should have a public method that takes in the item you want to add and adds it to the list model.

Upvotes: 0

lscoughlin
lscoughlin

Reputation: 2416

I'm just guessing here... your question needs a little more detail as Nivas pointed out.

But it sounds like crosses fingers you need to expose your list model as a property and manipulate that from the external class.

Upvotes: 0

Related Questions