"AWT-EventQueue-0" java.lang.NullPointerException

I am changing an existing program that used to work fine in JRE1.3. When I upgraded to JRE 1.6, the dialog box hang and does not display ComboBox.

Below is the code and the stack trace.

import irsccmacros.back_end.common.ComboBoxItem;

public class DefaultComboBoxRenderer

extends javax.swing.JLabel

implements javax.swing.ListCellRenderer {

/**

* ProcessingKindComboBoxRenderer constructor comment.

*/

public DefaultComboBoxRenderer() {

setOpaque(true);

setHorizontalAlignment(LEFT);

setVerticalAlignment(CENTER);

}

/**

* Return a component that has been configured to display the specified

* value. That component's <code>paint</code> method is then called to

* "render" the cell. If it is necessary to compute the dimensions

* of a list because the list cells do not have a fixed size, this method

* is called to generate a component on which <code>getPreferredSize</code>

* can be invoked.

*

* @param list The JList we're painting.

* @param value The value returned by list.getModel().getElementAt(index).

* @param index The cells index.

* @param isSelected True if the specified cell was selected.

* @param cellHasFocus True if the specified cell has the focus.

* @return A component whose paint() method will render the specified value.

*

* @see JList

* @see ListSelectionModel

* @see ListModel

*/

public java.awt.Component getListCellRendererComponent(

javax.swing.JList list,

Object value,

int index,

boolean isSelected,

boolean cellHasFocus) {

if (isSelected) {

setBackground(list.getSelectionBackground());

setForeground(list.getSelectionForeground());

} else {

setBackground(list.getBackground());

setForeground(list.getForeground());

}

if (value instanceof ComboBoxItem) {

if (((ComboBoxItem) value).getValue() >= 0) setText(((ComboBoxItem) value).getName());

} else setText(value.toString());

return this;

}

}

//////////////////////////////////////////////////////////////////////////////////////

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

[15:12:47,901,System.out]

at irsccmacros.front_end.common.presentation.DefaultComboBoxRenderer.getListCellRendererComponent(DefaultComboBoxRenderer.java)

[15:12:47,901,System.out]

at javax.swing.plaf.basic.BasicComboBoxUI.paintCurrentValue(Unknown Source)

[15:12:47,901,System.out]

at com.sun.java.swing.plaf.windows.WindowsComboBoxUI.paintCurrentValue(Unknown Source)

[15:12:47,901,System.out]

at javax.swing.plaf.basic.BasicComboBoxUI.paint(Unknown Source)

[15:12:47,901,System.out]

at com.sun.java.swing.plaf.windows.WindowsComboBoxUI.paint(Unknown Source)

[15:12:47,901,System.out]

at javax.swing.plaf.ComponentUI.update(Unknown Source)

[15:12:47,901,System.out]

at javax.swing.JComponent.paintComponent(Unknown Source)

[15:12:47,901,System.out]

at javax.swing.JComponent.paint(Unknown Source)

[15:12:47,901,System.out]

at javax.swing.JComponent.paintChildren(Unknown Source)

[15:12:47,901,System.out]

at javax.swing.JComponent.paint(Unknown Source)

[15:12:47,901,System.out]

at javax.swing.JComponent.paintChildren(Unknown Source)

[15:12:47,901,System.out]

at javax.swing.JComponent.paint(Unknown Source)

[15:12:47,901,System.out]

at javax.swing.JComponent.paintChildren(Unknown Source)

[15:12:47,901,System.out]

at javax.swing.JComponent.paint(Unknown Source)

[15:12:47,901,System.out]

at javax.swing.JComponent.paintChildren(Unknown Source)

[3895 byte] By [tn2001a] at [2007-11-27 5:17:46]
# 1
Can you put some more effort into this? Exactly what reference is null?
Hippolytea at 2007-7-12 10:40:40 > top of Java-index,Java Essentials,Java Programming...