Skip to content

Instantly share code, notes, and snippets.

@mik30s
Created September 21, 2017 18:53
Show Gist options
  • Save mik30s/7806963075d2da432e07fcfea0d50bbc to your computer and use it in GitHub Desktop.
Save mik30s/7806963075d2da432e07fcfea0d50bbc to your computer and use it in GitHub Desktop.
A dumb text editor
package lab.pkg2.texteditor;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class Lab2TextEditor extends Application {
/**
* Prepares gui components for rendering
* @param primaryStage
*/
@Override
public void start(Stage primaryStage) {
StackPane root = new StackPane();
String prompt = "Type here...";
Scene scene = new Scene(root, 300, 250);
TextArea textarea = new TextArea(prompt);
textarea.positionCaret(prompt.length());
textarea.positionCaret(5);
root.getChildren().add(textarea);
primaryStage.setTitle("Lab 2 - text editor");
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* Entry point of the app
* @param args
*/
public static void main(String[] args) {
launch(args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment