Java Code Examples for javafx.scene.layout.BorderPane#setPadding()

The following examples show how to use javafx.scene.layout.BorderPane#setPadding() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DiagramSizeDialog.java    From JetUML with GNU General Public License v3.0 6 votes vote down vote up
private Scene createScene() 
{
	BorderPane layout = new BorderPane();
	layout.setPadding( new Insets(SPACING));
	
	String message = RESOURCES.getString("dialog.diagram_size.message");
	message = message.replace("#1", Integer.toString(MIN_SIZE));
	message = message.replace("#2", Integer.toString(MAX_SIZE));

	HBox top = new HBox(new Text(message));
	top.setAlignment(Pos.CENTER);
	layout.setTop(top);
	layout.setCenter(createForm());
	layout.setBottom(createButtons());
	
	return new Scene(layout);
}
 
Example 2
Source File: PropertyEditorDialog.java    From JetUML with GNU General Public License v3.0 6 votes vote down vote up
private Scene createScene(PropertySheet.PropertyChangeListener pPropertyChangeListener) 
{
	PropertySheet sheet = new PropertySheet(aElement, pPropertyChangeListener);
			
	BorderPane layout = new BorderPane();
	Button button = new Button(RESOURCES.getString("dialog.diagram_size.ok"));
	
	// The line below allows to click the button by using the "Enter" key, 
	// by making it the default button, but only when it has the focus.
	button.defaultButtonProperty().bind(button.focusedProperty());
	button.setOnAction(pEvent -> aStage.close());
	BorderPane.setAlignment(button, Pos.CENTER_RIGHT);
	
	layout.setPadding(new Insets(LAYOUT_PADDING));
	layout.setCenter(sheet);
	layout.setBottom(button);
	
	return new Scene(layout);
}
 
Example 3
Source File: RunPane.java    From constellation with Apache License 2.0 5 votes vote down vote up
public AttributeBox(final String label, final AttributeList attributeList) {
    final BorderPane borderPane = new BorderPane();
    borderPane.setTop(attributeList);

    setMaxHeight(USE_PREF_SIZE);
    setMaxWidth(Double.MAX_VALUE);
    setCenter(borderPane);

    final Label heading = new Label(label);
    heading.setStyle("-fx-font-weight: bold;");

    BorderPane labelPane = new BorderPane();
    labelPane.setPadding(new Insets(1));
    labelPane.setMinWidth(0);
    labelPane.setLeft(heading);

    final Button button = new Button("", new ImageView(ADD_IMAGE));
    button.setOnAction((ActionEvent event) -> {
        Attribute attribute = importController.showNewAttributeDialog(attributeList.getAttributeType().getElementType());
        if (attribute != null) {
            importController.createManualAttribute(attribute);
        }
    });
    button.setTooltip(new Tooltip("Add a new " + attributeList.getAttributeType().getElementType() + " attribute"));
    labelPane.setRight(button);

    setTop(labelPane);
}
 
Example 4
Source File: PluginParametersDialog.java    From constellation with Apache License 2.0 5 votes vote down vote up
/**
 * Display a dialog box containing the parameters that allows the user to
 * enter values.
 *
 * @param owner The owner for this stage.
 * @param title The dialog box title.
 * @param parameters The plugin parameters.
 * @param options The dialog box button labels, one for each button.
 */
public PluginParametersDialog(final Stage owner, final String title, final PluginParameters parameters, final String... options) {
    initStyle(StageStyle.UTILITY);
    initModality(Modality.WINDOW_MODAL);
    initOwner(owner);

    setTitle(title);

    final BorderPane root = new BorderPane();
    root.setPadding(new Insets(10));
    root.setStyle("-fx-background-color: #DDDDDD;");
    final Scene scene = new Scene(root);
    setScene(scene);

    final PluginParametersPane parametersPane = PluginParametersPane.buildPane(parameters, null);
    root.setCenter(parametersPane);

    final FlowPane buttonPane = new FlowPane();
    buttonPane.setAlignment(Pos.BOTTOM_RIGHT);
    buttonPane.setPadding(new Insets(5));
    buttonPane.setHgap(5);
    root.setBottom(buttonPane);

    final String[] labels = options != null && options.length > 0 ? options : new String[]{OK, CANCEL};
    for (final String option : labels) {
        final Button okButton = new Button(option);
        okButton.setOnAction(event -> {
            result = option;
            parameters.storeRecentValues();
            PluginParametersDialog.this.hide();
        });
        buttonPane.getChildren().add(okButton);
    }

    // Without this, some parameter panes have a large blank area at the bottom. Huh?
    this.sizeToScene();

    result = null;
}
 
Example 5
Source File: PluginManagerPane.java    From Recaf with MIT License 5 votes vote down vote up
private Node createPluginView(BasePlugin plugin) {
	BorderPane pane = new BorderPane();
	pane.setPadding(new Insets(15));
	// Content
	VBox box = new VBox();
	box.setSpacing(10);
	HBox title = new HBox();
	BufferedImage icon = manager.getPluginIcons().get(plugin.getName());
	if (icon != null) {
		IconView iconView = new IconView(UiUtil.toFXImage(icon), 32);
		BorderPane wrapper = new BorderPane(iconView);
		wrapper.setPadding(new Insets(4, 8, 0, 0));
		title.getChildren().add(wrapper);
	}
	title.getChildren().add(new SubLabeled(plugin.getName(), plugin.getDescription()));
	box.getChildren().add(title);
	pane.setCenter(box);
	// Controls
	HBox horizontal = new HBox();
	CheckBox chkEnabled = new CheckBox(LangUtil.translate("misc.enabled"));
	chkEnabled.setSelected(manager.getPluginStates().get(plugin.getName()));
	chkEnabled.selectedProperty()
			.addListener((ob, o, n) -> manager.getPluginStates().put(plugin.getName(), n));
	horizontal.getChildren().add(chkEnabled);
	box.getChildren().add(horizontal);
	return pane;
}
 
Example 6
Source File: Exercise_15_02.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a rectangle
	Rectangle rectangle = new Rectangle();
	rectangle.setWidth(90);
	rectangle.setHeight(40);
	rectangle.setFill(Color.RED);
	rectangle.setStroke(Color.BLACK);

	// Create a button
	Button btRotate = new Button("Rotate");

	// Process events
	btRotate.setOnAction(e -> 
		rectangle.setRotate(rectangle.getRotate() + 15));

	// Create a border pane and set its properties
	BorderPane pane = new BorderPane();
	pane.setCenter(rectangle);
	pane.setBottom(btRotate);
	BorderPane.setAlignment(rectangle, Pos.CENTER);
	BorderPane.setAlignment(btRotate, Pos.CENTER);
	pane.setPadding(new Insets(5, 5, 5, 5));

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 170, 170);
	primaryStage.setTitle("Exercise_15_02"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage; 
}
 
Example 7
Source File: Exercise_15_03.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Hold four buttons in a HBox
	HBox hBox = new HBox(5);
	hBox.setAlignment(Pos.CENTER);
	Button btLeft = new Button("Left");
	Button btRight = new Button("Right");
	Button btUp = new Button("Up");
	Button btDown = new Button("Down");
	hBox.getChildren().addAll(btLeft, btRight, btUp, btDown);

	// Create and register the handler
	btLeft.setOnAction(e -> ballPane.left());
	btRight.setOnAction(e -> ballPane.right());
	btUp.setOnAction(e -> ballPane.up());
	btDown.setOnAction(e -> ballPane.down());

	// Create a border pane
	BorderPane pane = new BorderPane();
	pane.setPadding(new Insets(0, 10, 5, 10));
	pane.setCenter(ballPane);
	pane.setBottom(hBox);

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 250, 250);
	primaryStage.setTitle("Exercise_15_03"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 8
Source File: Exercise_20_13.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
@Override /** Override the start method in the Application class */
public void start(Stage primaryStage) {
	// Create a hbox for the shuffle button and verification status
	HBox paneForStatus = new HBox(5);
	paneForStatus.getChildren().addAll(lblStatus, btShuffle);
	paneForStatus.setAlignment(Pos.CENTER_RIGHT);

	// Create a hbox for expression and verify button
	HBox paneForExpression = new HBox(5);
	paneForExpression.getChildren().addAll(
		new Label("Enter an expression: "), textField, btVerify);
	paneForExpression.setAlignment(Pos.CENTER);

	// Pick and display 4 random cards from deck
	shuffle();

	// Create a pane and add nodes
	BorderPane pane = new BorderPane();
	pane.setTop(paneForStatus);
	pane.setCenter(paneForCards);
	pane.setBottom(paneForExpression);
	pane.setPadding(new Insets(5, 5, 5, 5));

	// Create and register handlers
	btShuffle.setOnAction(e -> shuffle());
	btVerify.setOnAction(e -> verify());

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 400, 180);
	primaryStage.setTitle("Exercise_20_13"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 9
Source File: DemoDragTabs.java    From jfxutils with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) {

	Tab f = makeTab("Files", "File system view here");
	Tab t = makeTab("Type Hierarchy","Type hierarchy view here");
	Tab d = makeTab("Debug","Debug view here");

	Tab p = makeTab("Properties","Ah, the ubiquitous 'properties' panel");
	Tab c = makeTab("Console","Console output here");
	Tab o = makeTab("Outline","Outline of fields/methods view here");

	TabPane left = new TabPane(f,t,d);
	TabUtil.makeDroppable(left); //////////////// see

	TabPane right = new TabPane(p,c,o);
	TabUtil.makeDroppable(right); /////////////// see

	left.setStyle("-fx-border-color: black;");
	right.setStyle("-fx-border-color: black;");

	BorderPane main = new BorderPane();
	main.setPadding(new Insets(0, 20, 0, 20));
	main.setTop(new Label("Menubar and toolbars"));
	main.setLeft(left);
	main.setCenter(new Label("Central work area here"));
	main.setRight(right);
	main.setBottom(new Label("Statusbar"));

	primaryStage.setScene(new Scene(main, 800, 600));
	primaryStage.show();
}
 
Example 10
Source File: UICodePluginItem.java    From tcMenu with Apache License 2.0 4 votes vote down vote up
public UICodePluginItem(CodePluginManager mgr, CodePluginItem item, UICodeAction action, Consumer<CodePluginItem> evt) {
    super();

    this.eventHandler = evt;

    this.mgr = mgr;
    this.item = item;

    titleLabel = new Label(item.getDescription());
    titleLabel.setStyle("-fx-font-weight: bold; -fx-font-size: 110%;");

    descriptionArea = new Label(item.getExtendedDescription());
    descriptionArea.setWrapText(true);
    descriptionArea.setAlignment(Pos.TOP_LEFT);
    descriptionArea.setPrefWidth(1900);

    whichPlugin = new Label("Plugin loading");
    whichPlugin.setStyle("-fx-font-size: 90%;");
    whichPlugin.setPadding(new Insets(10, 5, 5, 5));

    licenseLink = new Hyperlink("License unknown");
    licenseLink.setDisable(true);
    licenseLink.setPadding(new Insets(10, 0, 5, 0));
    licenseLink.setStyle("-fx-font-size: 90%;");

    vendorLink = new Hyperlink("Vendor unknown");
    vendorLink.setDisable(true);
    vendorLink.setPadding(new Insets(10, 0, 5, 0));
    vendorLink.setStyle("-fx-font-size: 90%;");

    docsLink = new Hyperlink("No Docs");
    docsLink.setDisable(true);
    docsLink.setPadding(new Insets(10, 0, 5, 0));
    docsLink.setStyle("-fx-font-size: 90%;");

    infoContainer = new HBox(5);
    infoContainer.setAlignment(Pos.CENTER_LEFT);
    infoContainer.getChildren().add(whichPlugin);
    infoContainer.getChildren().add(docsLink);
    infoContainer.getChildren().add(licenseLink);
    infoContainer.getChildren().add(vendorLink);

    innerBorder = new BorderPane();
    innerBorder.setPadding(new Insets(4));
    innerBorder.setTop(titleLabel);
    innerBorder.setCenter(descriptionArea);
    innerBorder.setBottom(infoContainer);

    actionButton = new Button(action == UICodeAction.CHANGE ? "Change" : "Select");
    actionButton.setStyle("-fx-font-size: 110%; -fx-font-weight: bold;");
    actionButton.setMaxSize(2000, 2000);
    actionButton.setOnAction(event-> eventHandler.accept(item));

    setRight(actionButton);
    setCenter(innerBorder);

    setItem(item);
}
 
Example 11
Source File: BlastProgram.java    From megan-ce with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    final TextField queryField = new TextField();
    queryField.setFont(Font.font("Courier New"));
    queryField.setPromptText("Query");
    queryField.setPrefColumnCount(80);
    final ChoiceBox<String> programChoice = new ChoiceBox<>();
    programChoice.setMinWidth(100);
    final ChoiceBox<String> databaseChoice = new ChoiceBox<>();
    databaseChoice.setMinWidth(100);

    programChoice.setOnAction(e -> {
        databaseChoice.getItems().setAll(RemoteBlastClient.getDatabaseNames(
                RemoteBlastClient.BlastProgram.valueOf(programChoice.getValue())));
        databaseChoice.getSelectionModel().select(databaseChoice.getItems().get(0));
    });
    for (RemoteBlastClient.BlastProgram program : RemoteBlastClient.BlastProgram.values()) {
        programChoice.getItems().add(program.toString());
    }
    programChoice.getSelectionModel().select(RemoteBlastClient.BlastProgram.blastx.toString());
    final HBox topPane = new HBox();
    topPane.setSpacing(5);
    topPane.getChildren().addAll(new VBox(new Label("Query:"), queryField),
            new VBox(new Label("Program:"), programChoice), new VBox(new Label("Database:"), databaseChoice));

    final TextArea alignmentArea = new TextArea();
    alignmentArea.setFont(Font.font("Courier New"));
    alignmentArea.setPromptText("Enter a query and then press Apply to compute alignments");
    alignmentArea.setEditable(false);

    final ProgressBar progressBar = new ProgressBar();
    progressBar.setVisible(false);
    final Button loadExampleButton = new Button("Load Example");
    loadExampleButton.setOnAction(e -> queryField.setText("TAATTAGCCATAAAGAAAAACTGGCGCTGGAGAAAGATATTCTCTGGAGCGTCGGGCGAGCGATAATTCAGCTGATTATTGTCGGCTATGTGCTGAAGTAT"));
    loadExampleButton.disableProperty().bind(queryField.textProperty().isNotEmpty());

    final Button cancelButton = new Button("Cancel");
    final Button applyButton = new Button("Apply");
    final ButtonBar bottomBar = new ButtonBar();
    bottomBar.getButtons().addAll(progressBar, loadExampleButton, new Label("        "), cancelButton, applyButton);

    final BorderPane root = new BorderPane();
    root.setTop(topPane);
    root.setCenter(alignmentArea);
    root.setBottom(bottomBar);
    root.setPadding(new Insets(5, 5, 5, 5));

    final BlastService blastService = new BlastService();
    blastService.messageProperty().addListener((observable, oldValue, newValue) -> alignmentArea.setText(alignmentArea.getText() + newValue + "\n"));
    blastService.setOnScheduled(e -> {
        progressBar.setVisible(true);
        progressBar.progressProperty().bind(blastService.progressProperty());
        alignmentArea.clear();
    });
    blastService.setOnSucceeded(e -> {
        if (blastService.getValue().length() > 0)
            alignmentArea.setText(blastService.getValue());
        else
            alignmentArea.setText(alignmentArea.getText() + "*** No hits found ***\n");
        progressBar.progressProperty().unbind();
        progressBar.setVisible(false);
    });
    blastService.setOnCancelled(e -> {
        progressBar.progressProperty().unbind();
        alignmentArea.setText(alignmentArea.getText() + "*** Canceled ***\n");
        progressBar.setVisible(false);
    });
    blastService.setOnFailed(e -> {
        progressBar.progressProperty().unbind();
        alignmentArea.setText(alignmentArea.getText() + "*** Failed ***\n");
        progressBar.setVisible(false);
    });

    queryField.disableProperty().bind(blastService.runningProperty());
    cancelButton.setOnAction(e -> blastService.cancel());
    cancelButton.disableProperty().bind(blastService.runningProperty().not());

    applyButton.setOnAction(e -> {
        blastService.setProgram(RemoteBlastClient.BlastProgram.valueOf(programChoice.getValue()));
        blastService.setDatabase(databaseChoice.getValue());
        blastService.setQuery("read", queryField.getText());
        blastService.restart();
    });
    applyButton.disableProperty().bind(queryField.textProperty().isEmpty().or(blastService.runningProperty()));

    Scene scene = new Scene(root, 800, 600);
    primaryStage.setScene(scene);
    primaryStage.setTitle("NCBI Blast Client");
    primaryStage.show();
}
 
Example 12
Source File: FXColorPicker.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Constructs a new {@link FXColorPicker}.
 *
 * @param parent
 *            The parent {@link Composite}.
 * @param color
 *            The initial {@link Color} to set.
 */
public FXColorPicker(final Composite parent, Color color) {
	super(parent, SWT.NONE);
	setLayout(new FillLayout());

	FXCanvas canvas = new FXCanvas(this, SWT.NONE);

	// container
	Group colorPickerGroup = new Group();
	HBox hbox = new HBox();
	colorPickerGroup.getChildren().add(hbox);

	// color wheel
	WritableImage colorWheelImage = new WritableImage(64, 64);
	renderColorWheel(colorWheelImage, 0, 0, 64);
	ImageView colorWheel = new ImageView(colorWheelImage);
	colorWheel.setFitWidth(16);
	colorWheel.setFitHeight(16);

	BorderPane colorWheelPane = new BorderPane();
	Insets insets = new Insets(2.0);
	colorWheelPane.setPadding(insets);
	colorWheelPane.setCenter(colorWheel);
	// use background color of parent composite (the wheel image is
	// transparent outside the wheel, so otherwise the hbox color would look
	// through)
	colorWheelPane.setStyle("-fx-background-color: "
			+ computeRgbString(Color.rgb(parent.getBackground().getRed(),
					parent.getBackground().getGreen(),
					parent.getBackground().getBlue())));

	colorRectangle = new Rectangle(50, 20);
	// bind to ColorWheel instead of buttonPane to prevent layout
	// problems.
	colorRectangle.widthProperty().bind(colorWheel.fitWidthProperty()
			.add(insets.getLeft()).add(insets.getRight()).multiply(2.5));
	colorRectangle.heightProperty().bind(colorWheelPane.heightProperty());

	// draw 'border' around hbox (and fill background, which covers the
	// space beween color rect and wheel
	hbox.setStyle("-fx-border-color: " + computeRgbString(Color.DARKGREY)
			+ "; -fx-background-color: "
			+ computeRgbString(Color.DARKGREY));
	hbox.getChildren().addAll(colorRectangle, colorWheelPane);
	hbox.setSpacing(0.5);

	// interaction
	colorWheelPane.setOnMouseClicked(new EventHandler<MouseEvent>() {
		@Override
		public void handle(MouseEvent event) {
			Color colorOrNull = FXColorPicker.pickColor(getShell(),
					getColor());
			if (colorOrNull != null) {
				setColor(colorOrNull);
			}
		}
	});

	Scene scene = new Scene(colorPickerGroup);

	// copy background color from parent composite
	org.eclipse.swt.graphics.Color backgroundColor = parent.getBackground();
	scene.setFill(Color.rgb(backgroundColor.getRed(),
			backgroundColor.getGreen(), backgroundColor.getBlue()));
	canvas.setScene(scene);

	// initialize some color
	setColor(color);

	colorRectangle.fillProperty().bind(this.color);
}