Skip to content
Snippets Groups Projects
Select Git revision
  • 64c3380f23db8985d8d0b5ad5c20030628a088cc
  • main default protected
  • variant
3 results

Grid.java

Blame
  • Forked from COUETOUX Basile / FirefighterStarter
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    DrawerWithSave.java 1.38 KiB
    package serializer;
    
    import javafx.scene.control.Alert;
    import javafx.stage.FileChooser;
    
    import java.io.File;
    import java.io.IOException;
    
    
    public class DrawerWithSave extends state.Drawer {
    
        public DrawerWithSave(int width, int height) {
            super(width, height);
        }
    
        void write(){
        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle("Save");
        File file = fileChooser.showSaveDialog(getScene().getWindow());
        if (file == null) return;
        try {
            ShapeWriter.write(file, super.shapes);
        }
        catch (IOException e) {
            Alert alert = new Alert(Alert.AlertType.INFORMATION);
            alert.setTitle("Error Dialog");
            alert.setHeaderText(null);
            alert.setContentText("Ooops, there was an error!");
            alert.showAndWait();
        }
        }
        public void load() {
            FileChooser fileChooser = new FileChooser();
            fileChooser.setTitle("Load");
            File file = fileChooser.showOpenDialog(getScene().getWindow());
            if (file == null) return;
            try {
                super.shapes = ShapeReader.read(file);
                repaint();
            } catch (IOException e) {
                Alert alert = new Alert(Alert.AlertType.INFORMATION);
                alert.setTitle("Error Dialog");
                alert.setHeaderText(null);
                alert.setContentText("Ooops, there was an error!");
                alert.showAndWait();
            }
        }
    }