use of javafx.scene.layout.BorderPane in project mastering-java by Kingminghuang.
the class MultipleBounceBall method start.
@Override
public void start(Stage primaryStage) throws Exception {
MultipleBallPane ballPane = new MultipleBallPane();
ballPane.setStyle("-fx-border-color: red");
Button addBtn = new Button("+");
Button subtractBtn = new Button("-");
HBox hBox = new HBox(10);
hBox.getChildren().addAll(addBtn, subtractBtn);
hBox.setAlignment(Pos.CENTER);
addBtn.setOnAction(event -> ballPane.add());
subtractBtn.setOnAction(event -> ballPane.subtract());
ballPane.setOnMousePressed(event -> ballPane.pause());
ballPane.setOnMouseReleased(event -> ballPane.play());
ScrollBar speedCtrl = new ScrollBar();
speedCtrl.setMax(50);
speedCtrl.setValue(25);
ballPane.rateProperty().bind(speedCtrl.valueProperty());
BorderPane borderPane = new BorderPane();
borderPane.setCenter(ballPane);
borderPane.setTop(speedCtrl);
borderPane.setBottom(hBox);
Scene scene = new Scene(borderPane, DEFAULT_WIDTH, DEFAULT_HEIGHT);
primaryStage.setTitle("Multiple Bounce Ball");
primaryStage.setScene(scene);
primaryStage.show();
}
use of javafx.scene.layout.BorderPane in project intellij-community by JetBrains.
the class IpnbJfxUtils method createHtmlPanel.
public static JComponent createHtmlPanel(@NotNull final String source, int width) {
final JFXPanel javafxPanel = new JFXPanel() {
@Override
protected void processMouseWheelEvent(MouseWheelEvent e) {
final Container parent = getParent();
final MouseEvent parentEvent = SwingUtilities.convertMouseEvent(this, e, parent);
parent.dispatchEvent(parentEvent);
}
};
javafxPanel.setBackground(IpnbEditorUtil.getBackground());
Platform.runLater(() -> {
final WebView webView = new WebView();
webView.setContextMenuEnabled(false);
webView.setOnDragDetected(event -> {
});
final WebEngine engine = webView.getEngine();
initHyperlinkListener(engine);
final boolean hasMath = source.contains("$");
if (hasMath) {
engine.setOnStatusChanged(event -> adjustHeight(webView, javafxPanel, source));
} else {
engine.getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {
if (newValue == Worker.State.SUCCEEDED) {
adjustHeight(webView, javafxPanel, source);
}
});
}
final BorderPane pane = new BorderPane(webView);
final String prefix;
if (hasMath) {
prefix = String.format(ourMathJaxPrefix, width - 500, EditorColorsManager.getInstance().getGlobalScheme().getEditorFontSize());
} else {
prefix = String.format(ourPrefix, width - 500);
}
final String content = prefix + convertToHtml(source) + ourPostfix;
engine.loadContent(content);
final Scene scene = new Scene(pane, 0, 0);
javafxPanel.setScene(scene);
updateLaf(LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo, engine, javafxPanel);
});
return javafxPanel;
}
use of javafx.scene.layout.BorderPane in project Media-Library by The-Rain-Goddess.
the class ApplicationWindow method start.
@Override
public void start(Stage rootStage) throws Exception {
AnchorPane componentWindow = new AnchorPane();
VBox componentLayout = new VBox();
BorderPane tableDisplay = new BorderPane();
search = new TextField();
//set main window size
componentWindow.setMinHeight(WINDOW_MIN_HEIGHT);
componentWindow.setMinWidth(WINDOW_MIN_WIDTH);
//align dataTable
tableDisplay.setRight(setupMediaDataTable());
tableDisplay.setLeft(setupMediaFileBrowser());
tableDisplay.setTop(setupMediaPlayer());
;
VBox.setMargin(tableDisplay, new Insets(10, 10, 10, 10));
componentLayout.getChildren().addAll(setupMenuBar(), tableDisplay);
//add componentLayout to Window
componentWindow.getChildren().addAll(componentLayout);
//Create the scene and add the parent container to it
Scene scene = new Scene(componentWindow, WINDOW_MIN_WIDTH, WINDOW_MIN_HEIGHT);
//Add the Scene to the Stage
rootStage.setScene(scene);
rootStage.getIcons().add(new Image(this.getClass().getResourceAsStream("media_library.png")));
rootStage.show();
}
use of javafx.scene.layout.BorderPane in project aima-java by aimacode.
the class VacuumEnvironmentViewCtrl method initialize.
@Override
public void initialize(Environment env) {
if (env instanceof VacuumEnvironment) {
this.locations = ((VacuumEnvironment) env).getLocations();
envStateView.getChildren().clear();
envStateView.getColumnConstraints().clear();
ColumnConstraints colCons = new ColumnConstraints();
colCons.setPercentWidth(100.0 / locations.size());
int i = 0;
for (String loc : locations) {
BorderPane pane = new BorderPane();
pane.setTop(new Label(loc));
pane.setStyle("-fx-background-color: white");
envStateView.add(pane, i++, 0);
envStateView.getColumnConstraints().add(colCons);
}
}
super.initialize(env);
}
use of javafx.scene.layout.BorderPane in project aima-java by aimacode.
the class NQueensSearchApp method createRootPane.
/**
* Defines state view, parameters, and call-back functions and calls the
* simulation pane builder to create layout and controller objects.
*/
@Override
public Pane createRootPane() {
BorderPane root = new BorderPane();
StackPane stateView = new StackPane();
stateViewCtrl = new NQueensViewCtrl(stateView);
List<Parameter> params = createParameters();
SimulationPaneBuilder builder = new SimulationPaneBuilder();
builder.defineParameters(params);
builder.defineStateView(stateView);
builder.defineInitMethod(this::initialize);
builder.defineSimMethod(this::simulate);
simPaneCtrl = builder.getResultFor(root);
simPaneCtrl.setParam(SimulationPaneCtrl.PARAM_SIM_SPEED, 1);
return root;
}
Aggregations