Java Code Examples for javafx.scene.layout.GridPane#setConstraints()

The following examples show how to use javafx.scene.layout.GridPane#setConstraints() . 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: MutableOfferView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private GridPane createInfoPopover() {
    GridPane infoGridPane = new GridPane();
    infoGridPane.setHgap(5);
    infoGridPane.setVgap(5);
    infoGridPane.setPadding(new Insets(10, 10, 10, 10));

    int i = 0;
    if (model.isSellOffer())
        addPayInfoEntry(infoGridPane, i++, Res.getWithCol("shared.tradeAmount"), model.tradeAmount.get());

    addPayInfoEntry(infoGridPane, i++, Res.getWithCol("shared.yourSecurityDeposit"), model.getSecurityDepositInfo());
    addPayInfoEntry(infoGridPane, i++, Res.get("createOffer.fundsBox.offerFee"), model.getTradeFee());
    addPayInfoEntry(infoGridPane, i++, Res.get("createOffer.fundsBox.networkFee"), model.getTxFee());
    Separator separator = new Separator();
    separator.setOrientation(Orientation.HORIZONTAL);
    separator.getStyleClass().add("offer-separator");
    GridPane.setConstraints(separator, 1, i++);
    infoGridPane.getChildren().add(separator);
    addPayInfoEntry(infoGridPane, i, Res.getWithCol("shared.total"), model.getTotalToPayInfo());
    return infoGridPane;
}
 
Example 2
Source File: DetailedSongPanel.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Add a label / input block to a panel.
 * <p>
 * @param panel the panel to add to.
 * @param labelText the label text to add to this block.
 * @param comp the component to add to this block.
 */
private void addBlock(GridPane panel, String labelText, Node comp, int i) {
    Label label = new Label(labelText);
    label.setLabelFor(comp);
    GridPane.setConstraints(label, 1, i);
    GridPane.setConstraints(comp, 2, i);
    panel.getChildren().add(label);
    panel.getChildren().add(comp);
}
 
Example 3
Source File: ProxyDialog.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public LocalDirPanel() {
    setPadding(new Insets(8));
    setHgap(5.0F);
    setVgap(5.0F);

    int rowIndex = 0;
    Label parentDirLabel = new Label("Local javadoc index.html file");
    parentDirLabel.setId("parent-dir-label");
    GridPane.setConstraints(parentDirLabel, 0, rowIndex);
    getChildren().add(parentDirLabel);

    rowIndex++;
    textField = new TextField();
    textField.setEditable(false);
    GridPane.setConstraints(textField, 0, rowIndex,1,1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.NEVER);

    Button button = new Button("Browse...");
    button.setId("browseButton");
    button.setMinWidth(USE_PREF_SIZE);
    GridPane.setConstraints(button, 1, rowIndex);
    button.setOnAction(new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent actionEvent) {
            FileChooser fileChooser = new FileChooser();
            fileChooser.setTitle("JavaFX 2.0 Javadoc location");
            FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("html", "*.html");
            fileChooser.getExtensionFilters().add(filter);
            File selectedFile = fileChooser.showOpenDialog(owner);
            
            okBtn.setDisable(selectedFile == null);
            if (selectedFile != null) {
                textField.setText(selectedFile.getAbsolutePath());
                docsUrl = selectedFile.toURI().toString();
                docsUrl = docsUrl.substring(0,docsUrl.lastIndexOf('/') + 1);
            }
        }
    });
    getChildren().addAll(textField, button);
}
 
Example 4
Source File: ProxyDialog.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public ProxyPanel() {
    setPadding(new Insets(8));
    setHgap(5.0F);
    setVgap(5.0F);

    int rowIndex = 0;

    Label label2 = new Label("Host Name");
    label2.setId("proxy-dialog-label");
    GridPane.setConstraints(label2, 0, rowIndex);

    Label label3 = new Label("Port");
    label3.setId("proxy-dialog-label");
    GridPane.setConstraints(label3, 1, rowIndex);
    getChildren().addAll(label2, label3);

    rowIndex++;
    hostNameBox = new TextField();
    hostNameBox.setPromptText("proxy.mycompany.com");
    hostNameBox.setPrefColumnCount(20);
    GridPane.setConstraints(hostNameBox, 0, rowIndex);

    portBox = new TextField();
    portBox.setPromptText("8080");
    portBox.setPrefColumnCount(10);
    GridPane.setConstraints(portBox, 1, rowIndex);

    ChangeListener<String> textListener = new ChangeListener<String>() {
        public void changed(ObservableValue<? extends String> ov, String t, String t1) {
            okBtn.setDisable(
                    hostNameBox.getText() == null || hostNameBox.getText().isEmpty()
                    || portBox.getText() == null || portBox.getText().isEmpty());
        }
    };
    hostNameBox.textProperty().addListener(textListener);
    portBox.textProperty().addListener(textListener);

    getChildren().addAll(hostNameBox, portBox);
}
 
Example 5
Source File: DocPage.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private Node createSideBar(ObservableList<SamplePage> relatedSamples) {
    GridPane sidebar = new GridPane() {
        // stretch to allways fill height of scrollpane
        @Override protected double computePrefHeight(double width) {
            return Math.max(
                    super.computePrefHeight(width),
                    getParent().getBoundsInLocal().getHeight()
            );
        }
    };
    sidebar.getStyleClass().add("right-sidebar");
    sidebar.setMaxWidth(Double.MAX_VALUE);
    sidebar.setMaxHeight(Double.MAX_VALUE);
    int sideRow = 0;
    // create side bar content
    // description
    Label discTitle = new Label("Related Samples");
    discTitle.getStyleClass().add("right-sidebar-title");
    GridPane.setConstraints(discTitle, 0, sideRow++);
    sidebar.getChildren().add(discTitle);
    // add sample tiles
    for (SamplePage sp: relatedSamples) {
        Node tile = sp.createTile();
        GridPane.setConstraints(tile, 0, sideRow++);
        sidebar.getChildren().add(tile);
    }
    return sidebar;
}
 
Example 6
Source File: ToggleButtonSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public ToggleButtonSample() {
    // create label to show result of selected toggle button
    final Label label = new Label();
    label.setStyle("-fx-font-size: 2em;");
    // create 3 toggle buttons and a toogle group for them
    final ToggleButton tb1 = new ToggleButton("Cat");
    final ToggleButton tb2 = new ToggleButton("Dog");
    final ToggleButton tb3 = new ToggleButton("Horse");
    ToggleGroup group = new ToggleGroup();
    tb1.setToggleGroup(group);
    tb2.setToggleGroup(group);
    tb3.setToggleGroup(group);
    group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        @Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle selectedToggle) {
            if(selectedToggle!=null) {
                label.setText(((ToggleButton) selectedToggle).getText());
            }
            else {
                label.setText("...");
            }
        }
    });
    // select the first button to start with
    group.selectToggle(tb1);
    // add buttons and label to grid and set their positions
    GridPane.setConstraints(tb1,0,0);
    GridPane.setConstraints(tb2,1,0);
    GridPane.setConstraints(tb3,2,0);
    GridPane.setConstraints(label,0,1,3,1);
    GridPane grid = new GridPane();
    grid.setVgap(20);
    grid.setHgap(10);
    getChildren().add(grid);
    grid.getChildren().addAll(tb1, tb2, tb3, label);
}
 
Example 7
Source File: DocPage.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private Node createSideBar(ObservableList<SamplePage> relatedSamples) {
    GridPane sidebar = new GridPane() {
        // stretch to allways fill height of scrollpane
        @Override protected double computePrefHeight(double width) {
            return Math.max(
                    super.computePrefHeight(width),
                    getParent().getBoundsInLocal().getHeight()
            );
        }
    };
    sidebar.getStyleClass().add("right-sidebar");
    sidebar.setMaxWidth(Double.MAX_VALUE);
    sidebar.setMaxHeight(Double.MAX_VALUE);
    int sideRow = 0;
    // create side bar content
    // description
    Label discTitle = new Label("Related Samples");
    discTitle.getStyleClass().add("right-sidebar-title");
    GridPane.setConstraints(discTitle, 0, sideRow++);
    sidebar.getChildren().add(discTitle);
    // add sample tiles
    for (SamplePage sp: relatedSamples) {
        Node tile = sp.createTile();
        GridPane.setConstraints(tile, 0, sideRow++);
        sidebar.getChildren().add(tile);
    }
    return sidebar;
}
 
Example 8
Source File: AlertDialog.java    From Animu-Downloaderu with MIT License 5 votes vote down vote up
public AlertDialog(String title, String message) {
	var dialogPane = getDialogPane();
	setTitle(title);
	dialogPane.getStylesheets().add(getClass().getResource("/css/combo.css").toExternalForm());

	var label = new Label(message);

	dialogPane.getButtonTypes().addAll(ButtonType.CLOSE);

	GridPane.setConstraints(label, 1, 2);
	dialogPane.setContent(label);
}
 
Example 9
Source File: DonateDialog.java    From Animu-Downloaderu with MIT License 5 votes vote down vote up
public DonateDialog() {
	var buttonType = new ButtonType("Yes", ButtonData.YES);
	var dialogPane = getDialogPane();

	setTitle("Donate :3");
	dialogPane.getStylesheets().add(getClass().getResource("/css/combo.css").toExternalForm());

	var gridPane = new GridPane();

	gridPane.setVgap(10);
	String question = "Thank you for clicking the donate button!! <3\n\n"
			+ "You can donate via liberapay, paypal, or help me by subscribing to my patreon!\n\n";

	Label librapay = new Label("Liberapay");
	Label paypal = new Label("Paypal");
	Label patrion = new Label("Patreon");
	HBox donateButtons = new HBox(15);
	donateButtons.setAlignment(Pos.CENTER);
	librapay.setCursor(Cursor.HAND);
	paypal.setCursor(Cursor.HAND);
	patrion.setCursor(Cursor.HAND);
	librapay.setId("link");
	paypal.setId("link");
	patrion.setId("link");

	librapay.setOnMouseClicked(e -> handleClick("https://liberapay.com/codingotaku/donate"));
	paypal.setOnMouseClicked(e -> handleClick("https://paypal.me/codingotaku"));
	patrion.setOnMouseClicked(e -> handleClick("https://www.patreon.com/bePatron?u=13678963"));
	donateButtons.getChildren().addAll(librapay, paypal, patrion);

	dialogPane.getButtonTypes().addAll(ButtonType.CLOSE);

	var label = new Label(question);
	GridPane.setConstraints(label, 1, 2);
	GridPane.setConstraints(donateButtons, 1, 3, 2, 1);
	gridPane.getChildren().addAll(label, donateButtons);
	dialogPane.setContent(gridPane);
	setResultConverter(dialogButton -> dialogButton == buttonType);
}
 
Example 10
Source File: FlowGridPane.java    From OEE-Designer with MIT License 5 votes vote down vote up
private void relayout() {
    ObservableList<Node> children = getChildren();
    int    lastColSpan = 0;
    int    lastRowSpan = 0;
    for (Node child : children ) {
        int offs = children.indexOf(child);
        GridPane.setConstraints(child, offsetToCol(offs + lastColSpan), offsetToRow(offs + lastRowSpan));
        //lastColSpan = GridPane.getColumnSpan(child) == null ? 0 : GridPane.getColumnSpan(child);
        //lastRowSpan = GridPane.getRowSpan(child) == null ? 0 : GridPane.getRowSpan(child);
    }
}
 
Example 11
Source File: MutableOfferView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addPayInfoEntry(GridPane infoGridPane, int row, String labelText, String value) {
    Label label = new AutoTooltipLabel(labelText);
    TextField textField = new TextField(value);
    textField.setMinWidth(500);
    textField.setEditable(false);
    textField.setFocusTraversable(false);
    textField.setId("payment-info");
    GridPane.setConstraints(label, 0, row, 1, 1, HPos.RIGHT, VPos.CENTER);
    GridPane.setConstraints(textField, 1, row);
    infoGridPane.getChildren().addAll(label, textField);
}
 
Example 12
Source File: DataSetMeasurements.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
protected void addParameterValueEditorItems() {
    if (measType.getControlParameterNames().isEmpty()) {
        return;
    }
    final String toolTip = "math function parameter - usually in units of the x-axis";
    for (String controlParameter : measType.getControlParameterNames()) {
        final Label label = new Label(controlParameter + ": "); // NOPMD - done only once
        final CheckedNumberTextField parameterField = new CheckedNumberTextField(1.0); // NOPMD - done only once
        label.setTooltip(new Tooltip(toolTip)); // NOPMD - done only once
        GridPane.setConstraints(label, 0, lastLayoutRow);
        parameterField.setTooltip(new Tooltip(toolTip)); // NOPMD - done only once
        GridPane.setConstraints(parameterField, 1, lastLayoutRow++);

        this.parameterFields.add(parameterField);
        this.getDialogContentBox().getChildren().addAll(label, parameterField);
    }
    switch (measType) {
    case TRENDING_SECONDS:
    case TRENDING_TIMEOFDAY_UTC:
    case TRENDING_TIMEOFDAY_LOCAL:
        parameterFields.get(0).setText("600.0");
        parameterFields.get(1).setText("10000");
        Button resetButton = new Button("reset history");
        resetButton.setTooltip(new Tooltip("press to reset trending history"));
        resetButton.setOnAction(evt -> this.trendingDataSet.reset());
        GridPane.setConstraints(resetButton, 1, lastLayoutRow++);
        this.getDialogContentBox().getChildren().addAll(resetButton);
        break;
    default:
        break;
    }
}
 
Example 13
Source File: DataSetSelector.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
public DataSetSelector(final ParameterMeasurements plugin, final int requiredNumberOfDataSets) {
    super();
    if (plugin == null) {
        throw new IllegalArgumentException("plugin must not be null");
    }

    // wrap observable Array List, to prevent resetting the selection model whenever getAllDatasets() is called
    // somewhere in the code.
    allDataSets = plugin.getChart() != null ? FXCollections.observableArrayList(plugin.getChart().getAllDatasets()) : FXCollections.emptyObservableList();

    final Label label = new Label("Selected Dataset: ");
    GridPane.setConstraints(label, 0, 0);
    dataSetListView = new ListView<>(allDataSets);
    GridPane.setConstraints(dataSetListView, 1, 0);
    dataSetListView.setOrientation(Orientation.VERTICAL);
    dataSetListView.setPrefSize(-1, DEFAULT_SELECTOR_HEIGHT);
    dataSetListView.setCellFactory(list -> new DataSetLabel());
    dataSetListView.setPrefHeight(Math.max(2, allDataSets.size()) * ROW_HEIGHT + 2.0);
    MultipleSelectionModel<DataSet> selModel = dataSetListView.getSelectionModel();
    if (requiredNumberOfDataSets == 1) {
        selModel.setSelectionMode(SelectionMode.SINGLE);
    } else if (requiredNumberOfDataSets >= 2) {
        selModel.setSelectionMode(SelectionMode.MULTIPLE);
    }

    // add default initially selected DataSets
    if (selModel.getSelectedIndices().isEmpty() && allDataSets.size() >= requiredNumberOfDataSets) {
        for (int i = 0; i < requiredNumberOfDataSets; i++) {
            selModel.select(i);
        }
    }

    if (requiredNumberOfDataSets >= 1) {
        getChildren().addAll(label, dataSetListView);
    }
}
 
Example 14
Source File: DirectoryChooserSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(final Stage stage) {
    stage.setTitle("Directory Chooser Sample");

    final DirectoryChooser directoryChooser = new DirectoryChooser();
    final Button openButton = new Button("Select a folder...");

    openButton.setOnAction((final ActionEvent e) -> {
        File file = directoryChooser.showDialog(stage);
        if (file != null) {
            openFile(file);
        }
    });

    final GridPane inputGridPane = new GridPane();

    GridPane.setConstraints(openButton, 0, 1);
    inputGridPane.setHgap(6);
    inputGridPane.setVgap(6);
    inputGridPane.getChildren().addAll(openButton);

    final Pane rootGroup = new VBox(12);
    rootGroup.getChildren().addAll(inputGridPane);
    rootGroup.setPadding(new Insets(12, 12, 12, 12));

    stage.setScene(new Scene(rootGroup));
    stage.show();
}
 
Example 15
Source File: LoginApplication.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 150);
    stage.setScene(scene);
    stage.setTitle("Text Field Sample");

    GridPane grid = new GridPane();
    grid.setPadding(new Insets(10, 10, 10, 10));
    grid.setVgap(5);
    grid.setHgap(5);

    scene.setRoot(grid);

    final TextField name = new TextField();
    name.setPromptText("User Name:");
    HBox.setHgrow(name, Priority.ALWAYS);
    GridPane.setConstraints(name, 0, 0);
    grid.getChildren().add(name);

    final TextField lastName = new TextField();
    lastName.setPromptText("Password:");
    HBox.setHgrow(lastName, Priority.ALWAYS);
    GridPane.setConstraints(lastName, 0, 1);
    grid.getChildren().add(lastName);

    Button submit = new Button("Submit");
    GridPane.setConstraints(submit, 0, 2);
    grid.getChildren().add(submit);

    submit.setOnAction((ActionEvent e) -> {
        ProcessBuilder pb = new ProcessBuilder("java", "-cp", System.getProperty("java.class.path"),
                ButtonSample.class.getName());
        try {
            if (System.getenv("USER_JTO") != null) {
                pb.environment().put("JAVA_TOOL_OPTIONS", System.getenv("USER_JTO"));
            }
            Process process = pb.start();
            System.exit(0);
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    });

    stage.show();
}
 
Example 16
Source File: WebViewEventDispatcher.java    From oim-fx with MIT License 4 votes vote down vote up
public WebViewPane() {
	VBox.setVgrow(this, Priority.ALWAYS);
	setMaxWidth(Double.MAX_VALUE);
	setMaxHeight(Double.MAX_VALUE);

	TextField locationField = new TextField("http://www.baidu.com");
	Button goButton = new Button("Go");

	WebEngine webEngine = webView.getEngine();
	page = Accessor.getPageFor(webEngine);
	page.setJavaScriptEnabled(true);

	webView.setMinSize(500, 400);
	webView.setPrefSize(500, 400);

	webEngine.load("http://www.baidu.com");

	page.setEditable(true);

	// EventDispatcher eventDispatcher=new EventDispatcher() {
	//
	// @Override
	// public Event dispatchEvent(Event event, EventDispatchChain tail)
	// {
	// //tail.dispatchEvent(event);
	// if(event.getEventType()==MouseEvent.ANY) {
	//
	// }
	// return event;
	// }
	//
	// };
	registerEventHandlers();
	

	webView.setEventDispatcher(internalEventDispatcher);
	
	System.out.println(webView.getEventDispatcher());
	// webView.addEventHandler(eventType, eventHandler);
	// webView.buildEventDispatchChain(tail)

	EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
		@Override
		public void handle(ActionEvent event) {
			webEngine.load(locationField.getText().startsWith("http://") ? locationField.getText() : "http://" + locationField.getText());
		}
	};

	goButton.setDefaultButton(true);
	goButton.setOnAction(goAction);

	locationField.setMaxHeight(Double.MAX_VALUE);
	locationField.setOnAction(goAction);

	webEngine.locationProperty().addListener(new ChangeListener<String>() {
		@Override
		public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
			locationField.setText(newValue);
		}
	});

	GridPane grid = new GridPane();
	grid.setVgap(5);
	grid.setHgap(5);
	GridPane.setConstraints(locationField, 0, 0, 1, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.SOMETIMES);
	GridPane.setConstraints(goButton, 1, 0);
	GridPane.setConstraints(webView, 0, 1, 2, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
	grid.getColumnConstraints().addAll(
			new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.ALWAYS, HPos.CENTER, true),
			new ColumnConstraints(40, 40, 40, Priority.NEVER, HPos.CENTER, true));
	grid.getChildren().addAll(locationField, goButton, webView);
	getChildren().add(grid);
}
 
Example 17
Source File: ConstraintsDisplay.java    From scenic-view with GNU General Public License v3.0 4 votes vote down vote up
public void setPropertiesMap(final Map<String, Object> value) {
    getChildren().clear();

    propMap = value;

    if (propMap != null) {
        final Object keys[] = propMap.keySet().toArray();
        int row = 0;
        for (int i = 0; i < keys.length; i++) {
            if (keys[i] instanceof String) {
                final String propkey = (String) keys[i];
                if (propkey.contains("pane-") || propkey.contains("box-")) {
                    final Object keyvalue = propMap.get(propkey);
                    final Label label = new Label(propkey + ":");
                    label.getStyleClass().add("key");
                    GridPane.setConstraints(label, 0, row);
                    GridPane.setValignment(label, VPos.TOP);
                    GridPane.setHalignment(label, HPos.RIGHT);
                    getChildren().add(label);
                    
                    if (propkey.endsWith("margin")) {
                        final InsetsDisplay marginDisplay = new InsetsDisplay();
                        marginDisplay.setInsetsTarget((Insets) keyvalue);
                        GridPane.setConstraints(marginDisplay, 1, row++);
                        GridPane.setHalignment(marginDisplay, HPos.LEFT);
                        getChildren().add(marginDisplay);
                    } else {
                        final Label valueLabel = new Label(keyvalue.toString());
                        valueLabel.getStyleClass().add("value");
                        GridPane.setConstraints(valueLabel, 1, row++);
                        GridPane.setHalignment(valueLabel, HPos.LEFT);
                        getChildren().add(valueLabel);
                    }
                }
            }
        }
    } else {
        final Text novalue = new Text("-");
        GridPane.setConstraints(novalue, 0, 0);
        getChildren().add(novalue);
    }

    // FIXME without this we have ghost text appearing where the layout
    // constraints should be
    if (getChildren().isEmpty()) {
        getChildren().add(new Rectangle(1, 1, Color.TRANSPARENT));
    }

    requestLayout();
}
 
Example 18
Source File: CloudToTweetStep.java    From TweetwallFX with MIT License 4 votes vote down vote up
private Pane createInfoBox(
        final WordleSkin wordleSkin,
        final MachineContext context,
        final Tweet displayTweet,
        final Point2D lowerLeft) {
    final Tweet originalTweet = displayTweet.getOriginTweet();

    Image profileImage = context.getDataProvider(TweetUserProfileImageDataProvider.class).getImage(originalTweet.getUser());
    ImageView imageView = new ImageView(profileImage);
    Rectangle clip = new Rectangle(64, 64);
    clip.setArcWidth(10);
    clip.setArcHeight(10);
    imageView.setClip(clip);

    HBox imageBox = new HBox(imageView);
    imageBox.setPadding(new Insets(10));

    Label name = new Label(originalTweet.getUser().getName());
    name.getStyleClass().setAll("name");

    Label handle = new Label("@" + originalTweet.getUser().getScreenName() + " - " + wordleSkin.getDf().format(originalTweet.getCreatedAt()));
    handle.getStyleClass().setAll("handle");

    HBox firstLineBox = new HBox();
    HBox secondLineBox = new HBox(name);
    HBox thirdLineBox = new HBox(handle);

    if (originalTweet.getUser().isVerified()) {
        FontAwesomeIconView verifiedIcon = new FontAwesomeIconView();
        verifiedIcon.getStyleClass().addAll("verifiedAccount");

        secondLineBox.getChildren().add(verifiedIcon);
        HBox.setMargin(verifiedIcon, new Insets(9, 10, 0, 5));
    }

    if (displayTweet.isRetweet()) {
        FontAwesomeIconView retweetIconBack = new FontAwesomeIconView();
        retweetIconBack.getStyleClass().addAll("retweetBack");

        FontAwesomeIconView retweetIconFront = new FontAwesomeIconView();
        retweetIconFront.getStyleClass().addAll("retweetFront");

        Label retweetName = new Label(displayTweet.getUser().getName());
        retweetName.getStyleClass().setAll("retweetName");

        GlyphsStack stackedIcon = GlyphsStack.create()
                .add(retweetIconBack)
                .add(retweetIconFront);

        firstLineBox.getChildren().addAll(stackedIcon, retweetName);
        HBox.setMargin(stackedIcon, new Insets(0, 10, 0, 0));
    }

    if (wordleSkin.getFavIconsVisible()) {
        if (0 < originalTweet.getRetweetCount()) {
            FontAwesomeIconView faiReTwCount = new FontAwesomeIconView();
            faiReTwCount.getStyleClass().setAll("retweetCount");

            Label reTwCount = new Label(String.valueOf(originalTweet.getRetweetCount()));
            reTwCount.getStyleClass().setAll("handle");

            thirdLineBox.getChildren().addAll(faiReTwCount, reTwCount);
            HBox.setMargin(faiReTwCount, new Insets(5, 10, 0, 5));
        }

        if (0 < originalTweet.getFavoriteCount()) {
            FontAwesomeIconView faiFavCount = new FontAwesomeIconView();
            faiFavCount.getStyleClass().setAll("favoriteCount");

            Label favCount = new Label(String.valueOf(originalTweet.getFavoriteCount()));
            favCount.getStyleClass().setAll("handle");

            thirdLineBox.getChildren().addAll(faiFavCount, favCount);
            HBox.setMargin(faiFavCount, new Insets(5, 10, 0, 5));
        }
    }

    final GridPane infoBox = new GridPane();

    infoBox.setStyle("-fx-padding: 20px;");
    infoBox.setPrefHeight(100);
    infoBox.setMaxHeight(100);
    infoBox.setLayoutX(lowerLeft.getX());
    infoBox.setLayoutY(lowerLeft.getY());
    infoBox.setAlignment(Pos.CENTER);
    infoBox.getChildren().addAll(imageBox, firstLineBox, secondLineBox, thirdLineBox);

    GridPane.setConstraints(imageBox, 0, 1, 1, 2);
    GridPane.setConstraints(firstLineBox, 1, 0);
    GridPane.setConstraints(secondLineBox, 1, 1);
    GridPane.setConstraints(thirdLineBox, 1, 2);

    return infoBox;
}
 
Example 19
Source File: SeparatorSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 350, 150);
    stage.setScene(scene);
    stage.setTitle("Separator Sample");

    GridPane grid = new GridPane();
    grid.setPadding(new Insets(10, 10, 10, 10));
    grid.setVgap(2);
    grid.setHgap(5);

    scene.setRoot(grid);
    scene.getStylesheets().add("separatorsample/controlStyle.css");

    Image cloudImage = new Image(getClass().getResourceAsStream("cloud.jpg"));
    Image sunImage = new Image(getClass().getResourceAsStream("sun.jpg"));

    caption.setFont(Font.font("Verdana", 20));

    GridPane.setConstraints(caption, 0, 0);
    GridPane.setColumnSpan(caption, 8);
    grid.getChildren().add(caption);

    final Separator sepHor = new Separator();
    sepHor.setValignment(VPos.CENTER);
    GridPane.setConstraints(sepHor, 0, 1);
    GridPane.setColumnSpan(sepHor, 7);
    grid.getChildren().add(sepHor);

    friday.setFont(Font.font("Verdana", 18));
    GridPane.setConstraints(friday, 0, 2);
    GridPane.setColumnSpan(friday, 2);
    grid.getChildren().add(friday);

    final Separator sepVert1 = new Separator();
    sepVert1.setOrientation(Orientation.VERTICAL);
    sepVert1.setValignment(VPos.CENTER);
    sepVert1.setPrefHeight(80);
    GridPane.setConstraints(sepVert1, 2, 2);
    GridPane.setRowSpan(sepVert1, 2);
    grid.getChildren().add(sepVert1);

    saturday.setFont(Font.font("Verdana", 18));
    GridPane.setConstraints(saturday, 3, 2);
    GridPane.setColumnSpan(saturday, 2);
    grid.getChildren().add(saturday);

    final Separator sepVert2 = new Separator();
    sepVert2.setOrientation(Orientation.VERTICAL);
    sepVert2.setValignment(VPos.CENTER);
    sepVert2.setPrefHeight(80);
    GridPane.setConstraints(sepVert2, 5, 2);
    GridPane.setRowSpan(sepVert2, 2);
    grid.getChildren().add(sepVert2);

    sunday.setFont(Font.font("Verdana", 18));
    GridPane.setConstraints(sunday, 6, 2);
    GridPane.setColumnSpan(sunday, 2);
    grid.getChildren().add(sunday);

    final ImageView cloud = new ImageView(cloudImage);
    GridPane.setConstraints(cloud, 0, 3);
    grid.getChildren().add(cloud);

    final Label t1 = new Label("16");
    t1.setFont(Font.font("Verdana", 20));
    GridPane.setConstraints(t1, 1, 3);
    grid.getChildren().add(t1);

    final ImageView sun1 = new ImageView(sunImage);
    GridPane.setConstraints(sun1, 3, 3);
    grid.getChildren().add(sun1);

    final Label t2 = new Label("18");
    t2.setFont(Font.font("Verdana", 20));
    GridPane.setConstraints(t2, 4, 3);
    grid.getChildren().add(t2);

    final ImageView sun2 = new ImageView(sunImage);
    GridPane.setConstraints(sun2, 6, 3);
    grid.getChildren().add(sun2);

    final Label t3 = new Label("20");
    t3.setFont(Font.font("Verdana", 20));
    GridPane.setConstraints(t3, 7, 3);
    grid.getChildren().add(t3);

    stage.show();
}
 
Example 20
Source File: HTMLEditorSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public HTMLEditorSample() {
    final VBox root = new VBox();
    root.setPadding(new Insets(8, 8, 8, 8));
    root.setSpacing(5);
    root.setAlignment(Pos.BOTTOM_LEFT);

    final GridPane grid = new GridPane();
    grid.setVgap(5);
    grid.setHgap(10);

    final ChoiceBox sendTo = new ChoiceBox(FXCollections.observableArrayList("To:", "Cc:", "Bcc:"));

    sendTo.setPrefWidth(100);
    GridPane.setConstraints(sendTo, 0, 0);
    grid.getChildren().add(sendTo);

    final TextField tbTo = new TextField();
    tbTo.setPrefWidth(400);
    GridPane.setConstraints(tbTo, 1, 0);
    grid.getChildren().add(tbTo);

    final Label subjectLabel = new Label("Subject:");
    GridPane.setConstraints(subjectLabel, 0, 1);
    grid.getChildren().add(subjectLabel);

    final TextField tbSubject = new TextField();
    tbTo.setPrefWidth(400);
    GridPane.setConstraints(tbSubject, 1, 1);
    grid.getChildren().add(tbSubject);

    root.getChildren().add(grid);

    Platform.runLater(() -> {
        final HTMLEditor htmlEditor = new HTMLEditor();
        htmlEditor.setPrefHeight(370);
        root.getChildren().addAll(htmlEditor, new Button("Send"));
    });

    final Label htmlLabel = new Label();
    htmlLabel.setWrapText(true);
    getChildren().add(root);
}