Jump to content

GUI save/load checkboxes


Recommended Posts

Posted

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 :D

Posted

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 biggrin.png

add an actionlistener interface to the checkbox, then check if is selected and stuff :)

  • Like 1
Posted

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

  • Like 2
Posted

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

 

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...