How to access the variables inside a class which has been called more than once as a tab in JTabbedPane (Java) -
How to access the variables inside a class which has been called more than once as a tab in JTabbedPane (Java) -
i creating java app.
i have 1 class q2a2 jpanel design shown follows: -img-
suppose if item selected combo-box , "create account" button clicked. 1 tab added jtabbedpane. every item has mutual tab. did created 1 class , adding everytime on button click. class name q2a2_add. panel well. image follows...
after having 3 items app looks like
the code is:
public void addclass(int a) { if(jtabbedpane1.gettabcount()<13) { //variable name of tabbedpane string s=(string) maincb.getitemat(a); //maincb variable name of main combobox int dont=0; for(int j=0;j<tabname.length;j++){ //just ensure 2 accounts should not same if(s.equals(tabname[j])){ dont=1; break; } } if(dont==0){ for(int j=0;j<12;j++) { if(index[j]==0){ q2a2_add subpanel2=new q2a2_add(this); //calling sec class jtabbedpane1.add(s,subpanel2); //here adding panel subpanel2.heading(s); // heading() method defined in q2a2_add() rename jtextfield same argument s; tabname[j]=s; index[j]=1; break; } } } else { joptionpane.showconfirmdialog(null, (string) maincb.getitemat(a)+" created","information", joptionpane.plain_message); } } else { joptionpane.showconfirmdialog(null, "account overload. delete wrong business relationship , create","caution", joptionpane.plain_message); } } now question is. seen in function. everytime same class has been called , added. how can access various comboboxes , textboxes in different tabs. want store , opearate values entered user. example- how read inputs accounts receivable, accounts payable , office supplies differently.
please reply.
i expose functionality require within q2a2_add class. instance, if want alter textbox value, add together function within q2a2_add class called settextboxvalue() takes string parameter. within function, can set textbox value. same goes retrieving info it. remaining problem how maintain track of different tabs. recommend (which may simplify have) create hashmap maps string types q2a2_add types. then, when want add together new tab panel, can check if string exists in hashmap instead of searching through check titles. if doesn't exist, can add together hashmap stored within of outer jpanel class. then, when want access tabpanels, can access them string within hashmap , get/set properties please.
java class applet netbeans-7
Comments
Post a Comment