nyan Posted August 6, 2015 Posted August 6, 2015 i honestly cannot figure out how to check a checkbox using information i saved. the saved information is obviously true or false and true means checked and false means unchecked. if (line05 == "true") { // chckbxBoostAttack.doClick(); } else if (line05 == "false") { // chckbxBoostAttack.setEnabled(false); } right now this is all i have to give as an example and obviously the stuff commented doesn't work. any help is appreciated
Precise Posted August 6, 2015 Posted August 6, 2015 i honestly cannot figure out how to check a checkbox using information i saved. the saved information is obviously true or false and true means checked and false means unchecked. if (line05 == "true") { // chckbxBoostAttack.doClick(); } else if (line05 == "false") { // chckbxBoostAttack.setEnabled(false); } right now this is all i have to give as an example and obviously the stuff commented doesn't work. any help is appreciated add an actionlistener interface to the checkbox, then check if is selected and stuff 1
Ericthecmh Posted August 6, 2015 Posted August 6, 2015 First of all, if you're doing string comparison you should be using .equals() Second, setEnabled controls whether the checkbox is active. You're looking for setSelected() And I would recommend doing something like boolean selected = Boolean.parseSelected(line05); checkbox.setSelected(selected); Cleaner code 2
nyan Posted August 6, 2015 Author Posted August 6, 2015 First of all, if you're doing string comparison you should be using .equals() Second, setEnabled controls whether the checkbox is active. You're looking for setSelected() And I would recommend doing something like boolean selected = Boolean.parseSelected(line05); checkbox.setSelected(selected); Cleaner code wowwwww i completely overlooked setSelected() fml.. thanks though! and yeah i need to clean up my code a bit xD 1