import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
public class javaSer extends Application implements Serializable {
public static int inc = 0;
public void start(Stage primaryStage) {
Button btn = new Button("open setting");
Button btn2 = new Button("save setting");
btn.setOnMouseClicked((event) -> {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("open");
File selectedFile = fileChooser.showOpenDialog(primaryStage);
_import(selectedFile.getPath());
btn2.setOnMouseClicked((event) -> {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("save");
File name = fileChooser.showSaveDialog(primaryStage);
Rectangle rect = new Rectangle();
rect.setHeight(Editor.height);
rect.setWidth(Editor.width);
rect.setOnMouseClicked((event) -> {
root.getChildren().addAll(btn, btn2, rect);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
public static class Editor implements Serializable {
public static int height = 100 + inc;
public static int width = 100 + inc;
public String fontFamily;
public boolean autoComplete;
public transient String direction;
public static void main(String[] args) {
public void _import(String Path) {
if (new File(Path).exists()) {
FileInputStream fis = new FileInputStream(Path);
ObjectInputStream ois = new ObjectInputStream(fis);
e = (Editor) ois.readObject();
System.out.println("Deserialized data has been created in the memory");
System.out.println("Language: " + e.language);
System.out.println("Encoding: " + e.encoding);
System.out.println("Font size: " + e.fontSize);
System.out.println("Font family: " + e.fontFamily);
System.out.println("Auto save: " + e.autoSave);
System.out.println("Direction: " + e.direction);
System.out.println("Auto Complete: " + e.autoComplete);
System.out.println("Height: " + e.height);
System.out.println("Width : " + e.width);
} catch (IOException | ClassNotFoundException ex) {
System.out.println(ex.getMessage());
public void _export(String Path) {
e.direction = "right to left";
e.height = e.height + inc;
System.out.println("" + e.height + " und " + e.width);
FileOutputStream fos = new FileOutputStream(Path);
ObjectOutputStream oos = new ObjectOutputStream(fos);
System.out.println("path is " + Path + "");
} catch (IOException ex) {
System.out.println(ex.getMessage());
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
public class javaSer extends Application implements Serializable {
public static int inc = 0;
@Override
public void start(Stage primaryStage) {
Button btn = new Button("open setting");
Button btn2 = new Button("save setting");
btn.setOnMouseClicked((event) -> {
try {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("open");
File selectedFile = fileChooser.showOpenDialog(primaryStage);
_import(selectedFile.getPath());
} catch (Exception e) {
}
});
btn2.setOnMouseClicked((event) -> {
try {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("save");
File name = fileChooser.showSaveDialog(primaryStage);
_export(name.getPath());
} catch (Exception e) {
}
});
VBox root = new VBox();
root.setSpacing(20);
Rectangle rect = new Rectangle();
rect.setHeight(Editor.height);
rect.setWidth(Editor.width);
rect.setFill(Color.RED);
rect.setTranslateX(0);
rect.setTranslateX(0);
rect.setOnMouseClicked((event) -> {
Editor.height += 150;
Editor.width += 150;
});
root.getChildren().addAll(btn, btn2, rect);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
public static class Editor implements Serializable {
public static int height = 100 + inc;
public static int width = 100 + inc;
public String language;
public String encoding;
public String fontSize;
public String fontFamily;
public boolean autoSave;
public boolean autoComplete;
public transient String direction;
}
public static void main(String[] args) {
launch(args);
}
public void _import(String Path) {
Editor e = new Editor();
if (new File(Path).exists()) {
try {
FileInputStream fis = new FileInputStream(Path);
ObjectInputStream ois = new ObjectInputStream(fis);
e = (Editor) ois.readObject();
fis.close();
ois.close();
System.out.println("Deserialized data has been created in the memory");
System.out.println("Language: " + e.language);
System.out.println("Encoding: " + e.encoding);
System.out.println("Font size: " + e.fontSize);
System.out.println("Font family: " + e.fontFamily);
System.out.println("Auto save: " + e.autoSave);
System.out.println("Direction: " + e.direction);
System.out.println("Auto Complete: " + e.autoComplete);
System.out.println("Height: " + e.height);
System.out.println("Width : " + e.width);
System.out.println();
} catch (IOException | ClassNotFoundException ex) {
System.out.println(ex.getMessage());
}
}
// _export( Path);
}
public void _export(String Path) {
Editor e = new Editor();
try {
e.language = "woks";
e.encoding = "utf-8";
e.fontSize = "12pt";
e.fontFamily = "tahoma";
e.autoSave = true;
e.direction = "right to left";
e.height = e.height + inc;
e.width = e.width + inc;
System.out.println("" + e.height + " und " + e.width);
FileOutputStream fos = new FileOutputStream(Path);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(e);
oos.close();
fos.flush();
fos.close();
System.out.println("path is " + Path + "");
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
}
}