You need as many ListModel as you have different contents but only one JList
object (to display the contents)
I would suggest something like this
class MyGui extend JFrame {
private Vector m_listModels; // vector of ListModel objects
private int m_currentListModel;
private JList m_list;
public MyGui () {
m_list = new JList();
m_currentListModel = -1;
m_listModel = new Vector();
getContentPane().add(m_list);
JButton nextButton = new JButton();
nextButton.addActionListener() {new ActionListener() {
public void actionPerformed(ActionEvent ae) {
if (m_listModels.size() != 0 and m_currentListModel+1 <
m_listModels.size())
m_list.setListModel((ListModel)m_listModel.elementAt(m_currentListModel++));
}
}
getContentPane().add(nextButton);
}
public void main(String args) {
(new MyGui()).show();
}
I don't even think this is compiling but it will give you a start
In the m_listModels vector you put ListModel object . There is a default
implementation of this interface DefaultListModel which works like a vector:
add(Object o), remove(Object o), elementAt(i) ...
bye
----- Original Message -----
From: "Is'haaq Suleiman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, July 01, 2001 11:50 AM
Subject: Adding and Removing Lists
> Dear members.
>
> I am using a JList component, and I have defined
> categories of lists(e.g list1,list2,list3,list4, etc).
> I want only one list to be displayed at a time. And
> if the user clicks button marked "next", the next list
> should be displayed replacing the previous one.
>
> Could you please write me the codes which can solve
> ths problem?
>
> Thanx(ishaaq)
>
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
> _______________________________________________
> Swing mailing list
> [EMAIL PROTECTED]
> http://eos.dk/mailman/listinfo/swing
_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing