开发者

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 开发者_如何学Pythonto 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...?

  • I know how to add elements within the jframe class, using addElement() however from a different class i am stumped.

thanks -jason


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜