EvilZone

Programming and Scripting => Java => : Kulverstukas October 10, 2011, 06:27:16 PM

: [Java] vCard reader with GUI
: Kulverstukas October 10, 2011, 06:27:16 PM
Simple stuff. Made a GUI for my vCard reader that I made for command line earlier (http://evilzone.org/other/(java)-vcard-reader/ (http://evilzone.org/other/(java)-vcard-reader/))
Works, but I came across few issues which I wasn't able to resolve, so I am now asking little help.

First things firs:
Jar: http://newage.ql.lt/projects/java/vCardReader/GUI/vCardReaderGUI.jar (http://newage.ql.lt/projects/java/vCardReader/GUI/vCardReaderGUI.jar)
Code: http://newage.ql.lt/projects/java/vCardReader/GUI/vCardReader.java (http://newage.ql.lt/projects/java/vCardReader/GUI/vCardReader.java)
Sample vCard: http://newage.ql.lt/projects/java/vCardReader/GUI/vCard.vcf (http://newage.ql.lt/projects/java/vCardReader/GUI/vCard.vcf)

Ok so, the problem is with jComboBox. Whenever I use "comboBox.removeAllItems();" I get an exception: "java.lang.IndexOutOfBoundsException: Index: -1, Size: N" (where N is the number of items previously in the comboBox).
I Googled what is happening and it seems that whenever you use removeAllItems() it tries to select something or something, I'm not quite sure myself.

What I've been bothered about is I don't know how to code a workaround for this.
Any ideas?

I tried using a checking whether a comboBox contains something or not, but that does not do much.

The code with the problem is on the line 96.

EDIT:
Nevermind. xor explained it to me and now it all works well. Code and Jar re-uploaded.
Seems that each time a state of the comboBox changes, an event is fired, and my event wants to select a non-existing item, which is -1, so a logical operator fixed it.

:
<xor> bithc nigger xor is da bomb yo
<xor> and guy

Fo sho thar nizzle. Crizzle bizzle, bazingizzle!