Changing the text color of a JList

Hi,

Is it possible to set the color of only one line in a JList?

I have this small program and i want the text added to the JList to be changing between the color red and the color blue.

publicclass changeColorextends JFrame{

private JScrollPane jScroll;

private JList jList1;

private DefaultListModel listModel;

private JTextField jTextField1;

publicchangeColor(){

super();

initComponents();

}

privatevoid initComponents(){

listModel =new DefaultListModel();

jList1 =new JList(listModel);

jScroll =new JScrollPane (jList1);

jScroll.setMaximumSize(new Dimension(620,400));

jTextField1 =new JTextField();

jTextField1.setMaximumSize(new Dimension(620,20));

jTextField1.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent arg0){

listModel.addElement(jTextField1.getText());

jTextField1.setText(null);

}

});

Container cp = getContentPane();

cp.setLayout(new FlowLayout());

cp.add(jScroll);

cp.add( jTextField1);

setSize(1000,1000);

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

setVisible(true);

}

publicstaticvoid main(String[] args){

JFrame frame =new changeColor ();

}

}

i can change the color of the complete JList but that is not what i want.

Can anyone help me with this please

Greetz

R. Merckx

[2678 byte] By [Merckxa] at [2007-11-26 22:47:43]
# 1
check out: http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/ListCellRenderer.htmland http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JList.html#setCellRenderer(javax.swing.ListCellRenderer)
Nethera at 2007-7-10 12:06:49 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thx
Merckxa at 2007-7-10 12:06:49 > top of Java-index,Desktop,Core GUI APIs...