Java Code Examples for javafx.scene.control.TitledPane#setContent()

The following examples show how to use javafx.scene.control.TitledPane#setContent() . 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: MarsNode.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
public void createGreenhouses(TitledPane tp, Settlement settlement) {
 	VBox v = new VBox();
    v.setSpacing(10);
    v.setPadding(new Insets(0, 20, 10, 20));

 	List<Building> buildings = settlement.getBuildingManager().getACopyOfBuildings();

	Iterator<Building> iter1 = buildings.iterator();
	while (iter1.hasNext()) {
		Building building = iter1.next();
    	if (building.hasFunction(FunctionType.FARMING)) {
//        	try {
        		Farming farm = (Farming) building.getFunction(FunctionType.FARMING);
            	Button b = createGreenhouseDialog(farm);
            	v.getChildren().add(b);
//        	}
//        	catch (BuildingException e) {}
        }
	}


    tp.setContent(v);//"1 2 3 4 5..."));
    tp.setExpanded(true);

 }
 
Example 2
Source File: AttributeEditorPanel.java    From constellation with Apache License 2.0 5 votes vote down vote up
/**
 * multi value pane showing multiple values for an attribute
 *
 * @param attribute
 * @param attributePane
 * @param values
 */
private void createMultiValuePane(final AttributeData attribute, final TitledPane attributePane, final Object[] values) {
    final VBox dataAndMoreButtonBox = new VBox(5); // 5 = spacing

    final ScrollPane multiValuePane = new ScrollPane();

    multiValuePane.setFitToWidth(true);

    final ObservableList<Object> listData = FXCollections.observableArrayList();

    if (values.length > VISIBLE_ROWS) {
        for (int i = 0; i < VISIBLE_ROWS; i++) {
            listData.add(values[i]);
        }
    } else {
        listData.addAll(values);
    }
    final ListView<Object> listView = createListView(attribute, listData);
    final boolean moreToLoad = values.length > VISIBLE_ROWS;
    int visibleRow = moreToLoad ? VISIBLE_ROWS : listData.size();
    listView.setPrefHeight((CELL_HEIGHT * visibleRow) + 2); // +2 because if it is == then there is still a scrollbar.
    multiValuePane.setPrefHeight((CELL_HEIGHT * visibleRow) + 1);
    multiValuePane.setContent(listView);
    multiValuePane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    dataAndMoreButtonBox.setAlignment(Pos.CENTER);
    dataAndMoreButtonBox.setPadding(new Insets(0, 0, 5, 0));
    dataAndMoreButtonBox.getChildren().add(multiValuePane);
    if (moreToLoad) {
        Button loadMoreButton = createLoadMoreButton(dataAndMoreButtonBox, attribute);
        dataAndMoreButtonBox.getChildren().add(loadMoreButton);
    }
    dataAndMoreButtonBox.addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent event) -> {
        if (event.isShortcutDown() && (event.getCode() == KeyCode.A)) {
            listView.getSelectionModel().selectAll();
            event.consume();
        }
    });
    attributePane.setContent(dataAndMoreButtonBox);
}
 
Example 3
Source File: DialogErrorContent.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a control which shows the details of an exception or error to be used as the content of
 * a {@link WorkbenchDialog}.
 *
 * @param message the {@link Node} containing the standard dialog message
 * @param details about the error or exception
 */
public DialogErrorContent(Node message, String details) {
  this.message = message;
  this.details = details;

  getStyleClass().add("container");

  // add message to the dialog content
  getChildren().add(message);

  // if details were specified, add them wrapped in a TitledPane
  if (!Strings.isNullOrEmpty(details)) {
    TextArea textArea = new TextArea();
    textArea.setText(details);
    textArea.setWrapText(true);
    textArea.getStyleClass().add("error-details-text-area");

    TitledPane titledPane = new TitledPane();
    titledPane.getStyleClass().add("error-details-titled-pane");
    titledPane.setText("Details");
    titledPane.setContent(textArea);
    titledPane.setPrefHeight(300);

    getChildren().add(titledPane);
  }

}
 
Example 4
Source File: TitledPaneSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {
    stage.setTitle("TitledPane");
    Scene scene = new Scene(new Group(), 450, 250);

    TitledPane gridTitlePane = new TitledPane();
    GridPane grid = new GridPane();
    grid.setVgap(4);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("First Name: "), 0, 0);
    grid.add(new TextField(), 1, 0);
    grid.add(new Label("Last Name: "), 0, 1);
    grid.add(new TextField(), 1, 1);
    grid.add(new Label("Email: "), 0, 2);
    grid.add(new TextField(), 1, 2);
    grid.add(new Label("Attachment: "), 0, 3);
    grid.add(label, 1, 3);
    gridTitlePane.setText("Grid");
    gridTitlePane.setContent(grid);

    final Accordion accordion = new Accordion();

    for (int i = 0; i < imageNames.length; i++) {
        images[i] = new Image(getClass().getResourceAsStream(imageNames[i] + ".jpg"));
        pics[i] = new ImageView(images[i]);
        tps[i] = new TitledPane(imageNames[i], pics[i]);
    }
    accordion.getPanes().addAll(tps);

    accordion.expandedPaneProperty()
            .addListener((ObservableValue<? extends TitledPane> ov, TitledPane old_val, TitledPane new_val) -> {
                if (new_val != null) {
                    label.setText(accordion.getExpandedPane().getText() + ".jpg");
                }
            });

    HBox hbox = new HBox(10);
    hbox.setPadding(new Insets(20, 0, 0, 20));
    hbox.getChildren().setAll(gridTitlePane, accordion);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(hbox);
    stage.setScene(scene);
    stage.show();
}