Ciao a tutti, premetto che di java non so moltissimo ed è da poco che lo uso.
Sto realizzando un progetto per un esame universitario, in pratica devo realizzare un software per gestire i file mp3 sul pc dell'utente, più una perversa gestione degli artisti che vuole il prof, ed è proprio su quest'ultimo punto il problema.
Il tipo artista si divide in 'gruppo' e 'solista', a seconda del tipo le proprietà sono differenti, però mettiamo che un utente si sbagli ad inserire un artista il tipo può essere modificato. Per visualizzare tutto ciò ho realizzato un JDiaog, il punto è che a seconda che l'utente scelga il tipo di artista, questa JDialog deve aggiornarsi e visualizzare i giusti campi.
Ora ho realizzato la funzione (paintOptionalComponent) per fare ciò, se l'attivo con un JButton qualsiasi che sta all'interno della JDialog funziona alla perfezione, ma se la faccio attivare legandola ad un JComboBox (nel codice si chiama 'tipo') mi viene generato il seguente errore:
codice:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException
	at java.lang.System.arraycopy(Native Method)
	at java.awt.Container.remove(Unknown Source)
	at javax.swing.JLayeredPane.remove(Unknown Source)
	at java.awt.Container.remove(Unknown Source)
	at javax.swing.JRootPane.setContentPane(Unknown Source)
	at javax.swing.JDialog.setContentPane(Unknown Source)
	at EditArtista1.repaintOptionalComponent(EditArtista1.java:569)
	at EditArtista1.actionPerformed(EditArtista1.java:595)
	at javax.swing.JComboBox.fireActionEvent(Unknown Source)
	at javax.swing.JComboBox.setSelectedItem(Unknown Source)
	at javax.swing.JComboBox.setSelectedIndex(Unknown Source)
	at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(Unknown Source)
	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
A me l'errore pare che stia nel punto 'setContentPane(CR);', però non capisco perché a volte funziona e a volte no?
Questo è il codice: http://phpfi.com/326139
Tralasciando gli altri 20mila errori concettuali che ci saranno nel mio codice , qualcuno riesce a spiegarmi dov'è l'errore? E cosa posso fare per risolverlo?

Grazie