Tuesday 15 September 2015

java - JCombobox accepting array of characters -



java - JCombobox accepting array of characters -

i want jcombobox take array of characters. can't seem find workaround this. basically, want jcombobox hold values '0' - '9', chars instead of int.

char[] levels = {'0', '1', '2', '3'}; skilllevelcombo = new jcombobox<object>(levels); //does not work

how around this? create character array? if so, how char values later on?

this works fine:

character[] levels = {'0', '1', '2', '3'}; skilllevelcombo = new jcombobox<character>(levels);

e.g.,

import javax.swing.jcombobox; import javax.swing.joptionpane; public class combofun { private static jcombobox<character> skilllevelcombo; public static void main(string[] args) { character[] levels = {'0', '1', '2', '3'}; skilllevelcombo = new jcombobox<character>(levels); joptionpane.showmessagedialog(null, skilllevelcombo); } }

please note integers work too:

integer[] levels = {0, 1, 2, 3}; final jcombobox<integer> skilllevelcombo = new jcombobox<integer>(levels);

java arrays swing jcombobox

No comments:

Post a Comment