public
Last active

Display a Quadratic formula in JavaFX using MathML in a WebView

  • Download Gist
WebViewQuadratic.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
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();
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.