Jump to content

GUI save/load checkboxes


nyan

Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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