java - Error in Importing Boolean variable -


i have 2 classes , 1 called adminmenu class variable votecycle boolean variable enables voter vote provided votecycle enabled , class called loginmenu utilize it.

i'm doing school project.

the problem have if select enable meant change boolean value true , i'm still getting false output.. if don't understand mean, code below should explain it.

its basic programming.

the class

 public class adminmenu extends javax.swing.jframe {     public boolean votecycle; 

the method

private void votecomboboxactionperformed(java.awt.event.actionevent evt) { if(vcycle.getselecteditem().tostring().equalsignorecase("true")) { votecycle=true; } else if(vcycle.getselecteditem().tostring().equalsignorecase("false")) { votecycle=false; } } 

this class use variable allow users log in. class called loginmenu(). @ start of class created object of class variable defined in using

adminmenu adminmenu=new adminmenu(); datavalidation validate=new datavalidation(); connectdb db=new connectdb(); 

i post relevant code class:

private void enterbtnactionperformed(java.awt.event.actionevent evt) { if(adminmenu.votecycle) {      string voter=voter.gettext();       boolean detail = false;      if (validate.verify(voter))// validates data     {         try         {             detail = db.voterlogin(voter);         }         catch (exception e)         {             system.out.println(e.getmessage());         }         if (detail)         {             new votermenu().setvisible(true);             this.dispose();         }         else         {             joptionpane.showmessagedialog(null, "the username or password entered incorrect");// error message         }         }  } else { joptionpane.showmessagedialog(null, "voting disabled", "error",     joptionpane.error_message);   } 

even after selecting combo box option enabled, return loginmenu class , if attempt login receive "voting disabled" error.

i appreciate offered , thank you!

p.s : i'm unsure how use toggle button , allow state kept when logging administrators menu or how use toggle button @ all.

so instead i'm using combox box set variables values.

the problem have if select enable meant change boolean value true , i'm still getting false output..

because, elements of jcombobox vcycle { "disabled", "enabled", " " } whereas, checking selecteditem true , false. should compare selected value of vcycle diabled or enabled instead of true , false.

if(vcycle.getselecteditem().tostring().equalsignorecase("disabled")) { votecycle=true; } else if(vcycle.getselecteditem().tostring().equalsignorecase("enabled")) { votecycle=false; } } 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -