> Hello there,
>
[quoted text clipped - 47 lines]
>
> Thanks
You can't do that directly onto JList or its model.
If your current code is:
listModel.addElement(userString);
then, repeatedly update the userString after each key press and
call listModel.setElementAt(index, userString);
Remi Arntzen - 05 Oct 2006 20:43 GMT
> > Hello there,
> >
[quoted text clipped - 52 lines]
> then, repeatedly update the userString after each key press and
> call listModel.setElementAt(index, userString);
It works for me
//GUIExam.java
import javax.swing.*;
public class GUIExam {
public static void main(String[] args) {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame f = new JFrame("GUI TEST");
DefaultListModel listModel = new DefaultListModel();
JList list = new JList(listModel);
f.getContentPane().add(list);
f.setSize(200, 324);
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setVisible(true);
try {
for (int i = 0; i < 15; i++) {
listModel.addElement(i);
Thread.sleep(1000);
}
} catch (InterruptedException thrown) {
//meh
thrown.printStackTrace();
}
f.setVisible(false);
f.dispose();
}
}
Remi Arntzen - 05 Oct 2006 20:52 GMT
> It works for me
I am using jdk 6 so maybe things have changed internally within the
JList.java source code.
It may not work on your machine, but at least you know that it should
work.
Remi Arntzen - 05 Oct 2006 20:48 GMT
> > Hello there,
> >
[quoted text clipped - 52 lines]
> then, repeatedly update the userString after each key press and
> call listModel.setElementAt(index, userString);
It works for me
//GUIExam.java
import javax.swing.*;
public class GUIExam {
public static void main(String[] args) {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame f = new JFrame("GUI TEST");
DefaultListModel listModel = new DefaultListModel();
JList list = new JList(listModel);
f.getContentPane().add(list);
f.setSize(200, 324);
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setVisible(true);
try {
for (int i = 0; i < 15; i++) {
listModel.addElement(i);
Thread.sleep(1000);
}
} catch (InterruptedException thrown) {
//meh
thrown.printStackTrace();
}
f.setVisible(false);
f.dispose();
}
}