private void onSave(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onSave
        toggler.setState(false);
        chooser.showSaveDialog(this);
        if (chooser.getSelectedFile() != null) {
            try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(chooser.getSelectedFile()))) {
                for (int row = 0; row < game.size(); row++) {
                    for (int col = 0; col < game.size(); col++) {
                        Entity entity = game.getEntity(row, col);
                        if (entity != null) {
                            dos.writeInt(row);
                            dos.writeInt(col);
                            dos.writeInt(entity.id);
                        }
                    }
                }
            } catch (FileNotFoundException ex) {
                game.log(Level.WARNING, "File not found");
            } catch (IOException ex) {
                game.log(Level.SEVERE, "Error saving", ex);
            }
        }
    }//GEN-LAST:event_onSave