Java Code Examples for javafx.scene.layout.Region#setMaxWidth()

The following examples show how to use javafx.scene.layout.Region#setMaxWidth() . 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: Builders.java    From PDF4Teachers with Apache License 2.0 6 votes vote down vote up
public static void setHBoxPosition(Region element, double width, double height, Insets margin){

        if(width == -1){
            HBox.setHgrow(element, Priority.ALWAYS);
            element.setMaxWidth(Double.MAX_VALUE);
        }else if(width != 0){
            element.setPrefWidth(width);
            element.minWidthProperty().bind(new SimpleDoubleProperty(width));
        }
        if(height == -1){
            VBox.setVgrow(element, Priority.ALWAYS);
        }else if(height != 0){
            element.setPrefHeight(height);
            element.minHeightProperty().bind(new SimpleDoubleProperty(height));
        }
        HBox.setMargin(element, margin);
    }
 
Example 2
Source File: Builders.java    From PDF4Teachers with Apache License 2.0 6 votes vote down vote up
public static void setVBoxPosition(Region element, double width, double height, Insets margin){

        if(width == -1){
            HBox.setHgrow(element, Priority.ALWAYS);
            element.setMaxWidth(Double.MAX_VALUE);
        }else if(width != 0){
            element.setPrefWidth(width);
            element.minWidthProperty().bind(new SimpleDoubleProperty(width));
        }
        if(height == -1){
            VBox.setVgrow(element, Priority.ALWAYS);
        }else if(height != 0){
            element.setPrefHeight(height);
            element.minHeightProperty().bind(new SimpleDoubleProperty(height));
        }
        VBox.setMargin(element, margin);
    }
 
Example 3
Source File: ScreenManager.java    From HubTurbo with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Calculates a stage's boundaries based on the screen information given as argument. If the list of screens
 * is empty, then the boundaries will have the default value of Region.USE_COMPUTED_SIZE (-1.0).
 *
 * @param intersectingScreenBounds A list of screens, which should be non-empty
 * @return A Region object containing relevant information in the maxHeight, minHeight and maxWidth fields.
 */
public static Region getStageBounds(List<Rectangle2D> intersectingScreenBounds) {
    DoubleSummaryStatistics occupyingHeights = intersectingScreenBounds.stream()
            .mapToDouble(Rectangle2D::getHeight)
            .summaryStatistics();

    double maxHeight = occupyingHeights.getMax();
    double minHeight = occupyingHeights.getMin();
    double sumWidths = intersectingScreenBounds.stream().mapToDouble(Rectangle2D::getWidth).sum();

    Region stageBounds = new Region();
    if (maxHeight >= 0 && minHeight >= 0) {
        stageBounds.setMaxHeight(maxHeight);
        stageBounds.setMinHeight(minHeight);
        stageBounds.setMaxWidth(sumWidths);
    }

    return stageBounds;
}
 
Example 4
Source File: ToolbarHelper.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** @param width Desired width
 *  @return 'Strut' that occupies requested width
 */
public static Node createStrut(int width)
{
    final Region sep = new Region();
    sep.setPrefWidth(width);
    sep.setMinWidth(Region.USE_PREF_SIZE);
    sep.setMaxWidth(Region.USE_PREF_SIZE);
    return sep;
}
 
Example 5
Source File: TemplateField.java    From pattypan with MIT License 5 votes vote down vote up
public VBox getRow() {
  Region spacer = new Region();
  spacer.setMinWidth(20);

  VBox vb = new VBox(5);
  HBox hb = new HBox(10);
  HBox hbCheckbox = new HBox(10);

  valueText.setText(Settings.getSetting("var-" + name + "-value"));
  value = Settings.getSetting("var-" + name + "-value");
  setSelection(Settings.getSetting("var-" + name + "-selection"));

  hb.getChildren().addAll(labelElement,
          buttonYes, buttonConst, buttonNo,
          spacer, valueText, new Region());
  vb.getChildren().add(hb);

  if (name.equals("date")) {
    Region r = new Region();
    r.setMaxWidth(622);
    r.setPrefWidth(622);
    r.setMinWidth(420);
    r.setMinHeight(30);

    CheckBox checkbox = new CheckBox(Util.text("choose-columns-exif"));
    checkbox.setMaxWidth(500);
    checkbox.setPrefWidth(500);
    checkbox.setMinWidth(305);
    checkbox.setSelected(Settings.getSetting("exifDate").equals("true"));
    checkbox.setOnAction((ActionEvent e) -> {
      Settings.setSetting("exifDate", checkbox.isSelected() ? "true" : "");
    });

    hbCheckbox.getChildren().addAll(r, checkbox);
    vb.getChildren().add(hbCheckbox);
  }

  return vb;
}
 
Example 6
Source File: HPane.java    From FxDock with Apache License 2.0 5 votes vote down vote up
protected void massage(Node n)
{
	// once in an HPane, surrender your limitations!
	if(n instanceof Region)
	{
		Region r = (Region)n;
		r.setMaxHeight(Double.MAX_VALUE);
		r.setMaxWidth(Double.MAX_VALUE);
	}
}
 
Example 7
Source File: CPane.java    From FxDock with Apache License 2.0 5 votes vote down vote up
protected void addPrivate(Node nd, CC cc)
{
	Entry en = getEntry(nd);
	if(en == null)
	{
		// once in a CPane, surrender your limitations!
		if(nd instanceof Region)
		{
			Region r = (Region)nd;
			r.setMaxWidth(Double.MAX_VALUE);
			r.setMaxHeight(Double.MAX_VALUE);
		}
		
		en = new Entry();
		en.node = nd;
		
		entries.add(en);
		
		if(!cc.border)
		{
			int mxc = cc.col2;
			while(cols.size() <= mxc)
			{
				cols.add(new LC());
			}
			
			int mxr = cc.row2;
			while(rows.size() <= mxr)
			{
				rows.add(new LC());
			}
		}
	}

	en.cc = cc;
	getChildren().add(nd);
}
 
Example 8
Source File: VPane.java    From FxDock with Apache License 2.0 5 votes vote down vote up
protected void massage(Node n)
{
	// once in an VPane, surrender your limitations!
	if(n instanceof Region)
	{
		Region r = (Region)n;
		r.setMaxHeight(Double.MAX_VALUE);
		r.setMaxWidth(Double.MAX_VALUE);
	}
}
 
Example 9
Source File: UIUtils.java    From SONDY with GNU General Public License v3.0 5 votes vote down vote up
public static void setSize(final Region region, int width, int height){
    region.setPrefSize(width, height);
    region.setMinWidth(width);
    region.setMaxWidth(width);
    region.setMinHeight(height);
    region.setMaxHeight(height);
}