This site requires JavaScript, please enable it in your browser!
Greenfoot back
DogeOverlord
DogeOverlord wrote ...

2016/4/16

Method to check if being simulated

DogeOverlord DogeOverlord

2016/4/16

#
I'd appreciate if there was a method to check if code is being simulated because I use some JOptionPane's and it is weird when they randomly pop up because their code was simulated.
danpost danpost

2016/4/17

#
DogeOverlord wrote...
I'd appreciate if there was a method to check if code is being simulated because I use some JOptionPane's and it is weird when they randomly pop up because their code was simulated.
Code only does what you program it to do. If you have panes showing up at random times then you have code that tells it to do so. You should show the code around which you are using the 'JOptionPane' class.
DogeOverlord DogeOverlord

2016/4/19

#
I'll be able to get back to you on that either tomorrow or Wednesday.
DogeOverlord DogeOverlord

2016/4/19

#
So it is being called by
at Button.act(Button.java:50)
	at greenfoot.core.Simulation.actActor(Simulation.java:594)
	at greenfoot.core.Simulation.runOneLoop(Simulation.java:552)
	at greenfoot.core.Simulation.runContent(Simulation.java:215)
	at greenfoot.core.Simulation.run(Simulation.java:205)
which I know because I made it error. It is executed from
public void act() 
    {
        if(Greenfoot.mouseClicked(this))
        {
            switch(type)
            {
                case "teacup": type = "teancodetext"; setPicture(); break;
                case "teancodetext": type = "teacup"; setPicture(); break;
                case "world": Greenfoot.setWorld(world); break;
                case "back": Greenfoot.setWorld(world); break;
                case "help": Greenfoot.setWorld(new HelpWorld(world)); break;
                case "newgame": Greenfoot.setWorld(new HubWorld(false));
                case "continuegame": Greenfoot.setWorld(new HubWorld(true));
                case "save": Save.saveWarn(Save.prepareString(),"Save.sav");
            }
        }
    }
and
static void saveWarn(String toWrite, String path)
    {
        int response = JOptionPane.showConfirmDialog(null,"Warning: Saving will overwrite the current save. Continue?");
        if(response == JOptionPane.OK_OPTION)
            writeSave(toWrite,path);
    }
when type is "save" but I never click on a button with a type of "save" and the JOptionPane pops up anyway.
danpost danpost

2016/4/19

#
You are missing 'break;' statements after cases "newgame", "continuegame" and "save".
DogeOverlord DogeOverlord

2016/4/19

#
smh thank you
You need to login to post a reply.