Friday 15 May 2015

user interface - populate check boxes dynamically from text in java -



user interface - populate check boxes dynamically from text in java -

i working on project have display set of records user can select 1 or more of these records move them set.

i think appropiate componenet utilize checkboxes. probelm cant add together check boxes frame automatically while reading file. added panel, , added check box still doesnt appear after using paint, or updateui. code:

bufferedreader reader = new bufferedreader(new inputstreamreader(new fileinputstream(file.getabsolutepath()), "utf-8")); string line = reader.readline(); string text = ""; while (line != null) { text += line; line = reader.readline(); } arraylist<string> records = new arraylist<string>(arrays.aslist(text.split(""))); for(string rec: records){ respanal.add(new jcheckbox(rec)); } respanal.updateui();

the number of records not constant, need way add together components = number of records found. open other suggestions can help other check boxes

for interested: tried @terrystorm suggested in little programme button, , each time button clicked box added

private void addcbactionperformed(java.awt.event.actionevent evt) { jcheckbox box=new jcheckbox("add"); box.setvisible(true); jpanel1.add(box); jpanel1.updateui(); }

java user-interface checkbox populate

No comments:

Post a Comment