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

The following examples show how to use javafx.scene.layout.BorderPane#setStyle() . 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: Undecorator.java    From DevToolBox with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Prepare Stage for dock feedback display
 */
void buildDockFeedbackStage() {
    dockFeedbackPopup = new Stage(StageStyle.TRANSPARENT);
    dockFeedback = new Rectangle(0, 0, 100, 100);
    dockFeedback.setArcHeight(10);
    dockFeedback.setArcWidth(10);
    dockFeedback.setFill(Color.TRANSPARENT);
    dockFeedback.setStroke(Color.BLACK);
    dockFeedback.setStrokeWidth(2);
    dockFeedback.setCache(true);
    dockFeedback.setCacheHint(CacheHint.SPEED);
    dockFeedback.setEffect(new DropShadow(BlurType.TWO_PASS_BOX, Color.BLACK, 10, 0.2, 3, 3));
    dockFeedback.setMouseTransparent(true);
    BorderPane borderpane = new BorderPane();
    borderpane.setStyle("-fx-background-color:transparent"); //J8
    borderpane.setCenter(dockFeedback);
    Scene scene = new Scene(borderpane);
    scene.setFill(Color.TRANSPARENT);
    dockFeedbackPopup.setScene(scene);
    dockFeedbackPopup.sizeToScene();
}
 
Example 2
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 3
Source File: MirrorScanWindowFX.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the frame.
 */
public MirrorScanWindowFX() {
  contentPane = new BorderPane();
  contentPane.setStyle("-fx-border-width: 5;");
  contentPane.setPrefSize(800, 800);

  this.setScene(new Scene(contentPane));
}
 
Example 4
Source File: Main.java    From Face-Recognition with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage)
{
	try
	{
                       
		FXMLLoader loader = new FXMLLoader(getClass().getResource("JFXoverlay.fxml"));
		BorderPane root = (BorderPane) loader.load();
		// set a whitesmoke background
		root.setStyle("-fx-background-color: whitesmoke;");
		// create and style a scene
		Scene scene = new Scene(root, 800, 600);
		scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
		// create the stage with the given title and the previously created
		// scene
		primaryStage.setTitle("Face Detection and Tracking");
		primaryStage.setScene(scene);
		// show the GUI
		primaryStage.show();
		
		// init the controller
		FXController controller = loader.getController();
		controller.init();
	}
	catch (Exception e)
	{
		e.printStackTrace();
	}
}
 
Example 5
Source File: ConsolidatedDialog.java    From constellation with Apache License 2.0 4 votes vote down vote up
/**
 * A generic multiple matches dialog which can be used to display a
 * collection of ObservableList items
 *
 * @param title The title of the dialog
 * @param observableMap The map of {@code ObservableList} objects
 * @param message The (help) message that will be displayed at the top of
 * the dialog window
 * @param listItemHeight The height of each list item. If you have a single
 * row of text then set this to 24.
 */
public ConsolidatedDialog(String title, Map<String, ObservableList<Container<K, V>>> observableMap, String message, int listItemHeight) {
    final BorderPane root = new BorderPane();
    root.setStyle("-fx-background-color: #DDDDDD;-fx-border-color: #3a3e43;-fx-border-width: 4px;");

    // add a title
    final Label titleLabel = new Label();
    titleLabel.setText(title);
    titleLabel.setStyle("-fx-font-size: 11pt;-fx-font-weight: bold;");
    titleLabel.setAlignment(Pos.CENTER);
    titleLabel.setPadding(new Insets(5));
    root.setTop(titleLabel);

    final Accordion accordion = new Accordion();
    for (String identifier : observableMap.keySet()) {
        final ObservableList<Container<K, V>> objects = observableMap.get(identifier);
        ListView<Container<K, V>> listView = new ListView<>(objects);
        listView.setEditable(false);
        listView.setPrefHeight((listItemHeight * objects.size()));
        listView.getSelectionModel().selectedItemProperty().addListener(event -> {
            listView.getItems().get(0).getKey();
            final Container<K, V> container = listView.getSelectionModel().getSelectedItem();
            if (container != null) {
                selectedObjects.add(new Pair<>(container.getKey(), container.getValue()));
            } else {
                // the object was unselected so go through the selected objects and remove them all because we don't know which one was unselected
                for (Container<K, V> object : listView.getItems()) {
                    selectedObjects.remove(new Pair<>(object.getKey(), object.getValue()));
                }
            }
        });

        final TitledPane titledPane = new TitledPane(identifier, listView);
        accordion.getPanes().add(titledPane);
    }

    final HBox help = new HBox();
    help.getChildren().add(helpMessage);
    help.getChildren().add(new ImageView(UserInterfaceIconProvider.HELP.buildImage(16, ConstellationColor.AZURE.getJavaColor())));
    help.setPadding(new Insets(10, 0, 10, 0));
    helpMessage.setText(message + "\n\nNote: To deselect hold Ctrl when you click.");
    helpMessage.setStyle("-fx-font-size: 11pt;");
    helpMessage.setWrapText(true);
    helpMessage.setPadding(new Insets(5));

    final VBox box = new VBox();
    box.getChildren().add(help);

    // add the multiple matching accordion
    box.getChildren().add(accordion);

    final ScrollPane scroll = new ScrollPane();
    scroll.setContent(box);
    scroll.setFitToWidth(true);
    scroll.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
    root.setCenter(scroll);

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

    useButton = new Button("Continue");
    buttonPane.getChildren().add(useButton);
    accordion.expandedPaneProperty().set(null);

    final Scene scene = new Scene(root);
    fxPanel.setScene(scene);
    fxPanel.setPreferredSize(new Dimension(500, 500));
}
 
Example 6
Source File: ChatTopPane.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {
	this.getChildren().add(baseBorderPane);

	nameLabel.setStyle("-fx-font-size:18px;");

	nameHBox.getChildren().add(nameLabel);
	textHBox.getChildren().add(textLabel);

	VBox infoVBox = new VBox();
	infoVBox.setPadding(new Insets(10, 0, 5, 28));
	infoVBox.getChildren().add(nameHBox);
	infoVBox.getChildren().add(textHBox);

	// this.setPadding(new Insets(0, 0, 0, 8));

	// textBox.setStyle("-fx-background-color:rgba(255, 255, 255, 0.92)");

	toolBar.setBackground(Background.EMPTY);
	//toolBar.setPadding(new Insets(0, 0, 0, 0));
	toolBar.setPadding(new Insets(0, 0, 0, 28));
	
	rightToolBox.setAlignment(Pos.CENTER_RIGHT);

	
	HBox toolHBox = new HBox();
	
	toolHBox.setAlignment(Pos.CENTER_LEFT);
	toolHBox.getChildren().add(toolBar);
	
	BorderPane toolBorderPane = new BorderPane();
	toolBorderPane.setStyle("-fx-background-color:rgba(255, 255, 255, 0.9)");
	toolBorderPane.setCenter(toolHBox);
	toolBorderPane.setRight(rightToolBox);
	
	HBox topLine = new HBox();
	topLine.setMinHeight(1);
	topLine.setStyle("-fx-background-color:#d6d6d6;");

	VBox topVBox = new VBox();
	topVBox.setPadding(new Insets(0, 0, 0, 0));
	topVBox.getChildren().add(infoVBox);
	topVBox.getChildren().add(topLine);
	
	baseBorderPane.setCenter(topVBox);
	baseBorderPane.setBottom(toolBorderPane);
}
 
Example 7
Source File: MainPane.java    From oim-fx with MIT License 4 votes vote down vote up
public MainPane() {

		findTextField.getStyleClass().clear();
		findTextField.setBackground(Background.EMPTY);
		findTextField.setStyle("-fx-text-fill: #ffffff;-fx-prompt-text-fill: #a9a9a9;-fx-text-font-size: 14px;");
		
		HBox findHBox = new HBox();
		findHBox.setAlignment(Pos.CENTER_LEFT);
		findHBox.getChildren().add(findImageView);
		
		BorderPane findBorderPane=new BorderPane();
		findBorderPane.setStyle("-fx-background-color:#26292e");
		findBorderPane.setPrefSize(245, 30);
		findBorderPane.setLeft(findHBox);
		findBorderPane.setCenter(findTextField);
		
		VBox findVBox = new VBox();
		findVBox.setAlignment(Pos.CENTER);
		findVBox.setPadding(new Insets(5, 10, 5, 10));
		findVBox.getChildren().add(findBorderPane);
		
		topVBox.getChildren().add(personalPane);
		topVBox.getChildren().add(findVBox);
		
		final StackPane centerStackPane = new StackPane();

		centerStackPane.getChildren().add(tabPanel);
		centerStackPane.getChildren().add(findListPane);

		leftBorderPane.setPrefWidth(280);
		leftBorderPane.setTop(topVBox);
		leftBorderPane.setCenter(centerStackPane);

		leftBorderPane.setStyle("-fx-background-color:#2e3238;");

		this.setPrefHeight(600);
		this.setLeft(leftBorderPane);
		
		tabPanel.setVisible(true);
		findListPane.setVisible(false);
		
		initEvent();
		initTest();
		
		//tabPanel.setSide(Side.RIGHT);
		tabPanel.setTabSize(45);
	}
 
Example 8
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);
}
 
Example 9
Source File: Exercise_16_19.java    From Intro-to-Java-Programming with MIT License 4 votes vote down vote up
/** Returns a fan pane */
public BorderPane getFan() {
	// Create three buttons
	Button btPause = new Button("Pause");
	Button btResume = new Button("Resume");
	Button btReverse = new Button("Reverse");

	// Place buttons in a hbox
	HBox paneForButtons = new HBox(5);
	paneForButtons.getChildren().addAll(btPause, btResume, btReverse);

	// Create a fan pane
	FanPane fan = new FanPane();

	// Create a slider and set its properties
	Slider slider = new Slider();
	slider.setMax(5);
	fan.rateProperty().bind(slider.valueProperty());

	// Create a border pane
	BorderPane pane = new BorderPane();
	pane.setStyle("-fx-border-color: black");
	pane.setTop(paneForButtons);
	pane.setCenter(fan);
	pane.setBottom(slider);

	// Create and register the handlers
	btPause.setOnAction(e -> {
		fan.pause();
	});

	btResume.setOnAction(e -> {
		fan.play();
	});

	btReverse.setOnAction(e -> {
		fan.reverse();
	});

	return pane;
}