gbcbr
asked on
Putting boolean value in permanent state.
I have JToggleButton which change value of boolean flag0s and set it for another class DecisionCenter (DC).
In the same time this class get value of another boolean bl0 from the third class BusinessLogic (BL) and when this variable come to DC flag0s start to be false again.
Please advice how to protect value of flag0s from any changes apart of command from ToggleButton.
Thank you.
In the same time this class get value of another boolean bl0 from the third class BusinessLogic (BL) and when this variable come to DC flag0s start to be false again.
Please advice how to protect value of flag0s from any changes apart of command from ToggleButton.
Thank you.
private void jToggleButton1_mouseClicked(MouseEvent e) throws Exception {
AbstractButton abstractButton = (AbstractButton) e.getSource();
boolean flag0s = abstractButton.getModel().isSelected();
dc_EURUSD_S = new DecisionCenter_EURUSD_S(flag0s).getInstance(flag0s);
System.out.println("Action - flaf0s = " + flag0s + "\n");
if (flag0s == true) {
jToggleButton1.setBackground(Color.green);
} else {
jToggleButton1.setBackground(Color.red);
}
}
public class DecisionCenter_EURUSD_S {
private static DecisionCenter_EURUSD_S dc_EURUSD_S;
ISide side;
boolean flag0s;
public DecisionCenter_EURUSD_S(boolean flag0s) {
}
public static DecisionCenter_EURUSD_S getInstance(boolean flag0s) {
if (flag0s == true)
{
System.out.println("$$$$$$$$ flag0s " + flag0s);
dc_EURUSD_S = new DecisionCenter_EURUSD_S(flag0s);
}
return dc_EURUSD_S;
}
public void decisionCenter_EURUSD_S(boolean bl0) throws Exception {
System.out.println(" bl0 " + bl0);
System.out.println(" &&&&&&& flag0s " + flag0s);
try {
if (bl0 == false && flag0s == true
side = SideFactory.SELL;
System.out.println(" side " + side);
AlgoTradeMarket_EURUSD.getInstance(null).algoTradeMarket(side);
} catch (Exception ex) {
Logger.getLogger(BusinessLogic_EURUSD.class.getName()).log(Level.SEVERE,
null,
ex);
}
}
}
public class BusinessLogic_EURUSD {
boolean bl0;
boolean flag0s;
boolean flag0b;
public BusinessLogic_EURUSD() throws Exception {
}
public void businessLogic_EURUSD(double[] outY0) throws Exception {
if (outY0 != null) {
try {
if (outY0[0] < 0 && outY0[1] < 0 && outY0[2] < 0 &&
outY0[3] < 0 && outY0[4] < 0 && outY0[5] < 0) {
bl0 = false;
System.out.println(" bl0 = " + bl0 + "\n");
DecisionCenter_EURUSD_S.getInstance(flag0s).decisionCenter_EURUSD_S(bl0);
// Initial output after pressing button
$$$$$$$$ flag0s true // from DecisionCenter
Action - flaf0s = true // from BusinessLogicControl
// Output after sending value bl0 = false to DecisionCenter
bl0 = false //from BusinessLogic
bl0 false // from DecisionCenter
&&&&&&& flag0s false //
side null //
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>You just create anothe bololean myFlag and assign: ....
Where would you do that (which line number)?
Where would you do that (which line number)?
ASKER
It works! Thank you
public static DecisionCenter_EURUSD_S getInstance(boolean flag0s) {
if (flag0s == true)
{
System.out.println("$$$$$$$$ flag0s " + flag0s);
dc_EURUSD_S = new DecisionCenter_EURUSD_S(flag0s);
mflag0s = flag0s;
}
return dc_EURUSD_S;
}
public void decisionCenter_EURUSD_S(boolean bl0) throws Exception {
System.out.println(" bl0 " + bl0);
System.out.println(" &&&&&&& flag0s " + flag0s);
System.out.println(" ^^^^^^^ mflag0s " + mflag0s);
try {
if (bl0 == false && mflag0s == true)
side = SideFactory.SELL;
System.out.println(" side " + side);
bl0 = false
bl0 false
&&&&&&& flag0s false
^^^^^^^ mflag0s true
side SideFactory:Sell (2)
EUR/USD
Margin use = 0.4857042663291346%
Thu Feb 17 18:07:40 EET 2011
Unless that listener method is being used for something other than just that toggle button, that's impossible (the boolean variable is local to the method)