Skip to content

Instantly share code, notes, and snippets.

@jewelsea
Created February 9, 2012 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jewelsea/1775799 to your computer and use it in GitHub Desktop.
Save jewelsea/1775799 to your computer and use it in GitHub Desktop.
Display a Quadratic formula in JavaFX using MathML in a WebView
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class WebViewQuadratic extends Application {
public static void main(String[] args) { Application.launch(args); }
@Override public void start(Stage primaryStage) {
WebView webView = new WebView();
webView.getEngine().loadContent(
"<math display=\"block\"><mrow><mi>x</mi><mo>=</mo><mfrac><mrow><mo>−</mo><mi>b</mi><mo>±</mo><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mo>−</mo><mn>4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></mrow></math>"
);
primaryStage.setScene(new Scene(webView));
primaryStage.show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment