Java Code Examples for javafx.scene.layout.Region#setMinWidth()
The following examples show how to use
javafx.scene.layout.Region#setMinWidth() .
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: RollingBufferSample.java From chart-fx with Apache License 2.0 | 5 votes |
private HBox getHeaderBar(Scene scene) { final Button newDataSet = new Button("new DataSet"); newDataSet.setOnAction(evt -> { getTask(0).run(); getTask(1).run(); }); final Button startTimer = new Button("timer"); startTimer.setOnAction(evt -> { if (timer == null) { timer = new Timer[2]; timer[0] = new Timer("sample-update-timer", true); rollingBufferBeamIntensity.reset(); timer[0].scheduleAtFixedRate(getTask(0), 0, UPDATE_PERIOD); timer[1] = new Timer("sample-update-timer", true); rollingBufferDipoleCurrent.reset(); timer[1].scheduleAtFixedRate(getTask(1), 0, UPDATE_PERIOD); } else { timer[0].cancel(); timer[1].cancel(); timer = null; // NOPMD } }); // H-Spacer Region spacer = new Region(); spacer.setMinWidth(Region.USE_PREF_SIZE); HBox.setHgrow(spacer, Priority.ALWAYS); final ProfilerInfoBox profilerInfoBox = new ProfilerInfoBox(DEBUG_UPDATE_RATE); profilerInfoBox.setDebugLevel(DebugLevel.VERSION); return new HBox(newDataSet, startTimer, spacer, profilerInfoBox); }
Example 2
Source File: Workbench.java From WorkbenchFX with Apache License 2.0 | 5 votes |
private void bindDrawerWidth(Region drawer) { drawer.setMinWidth(0); // make sure minWidth isn't larger than maxWidth drawer.maxWidthProperty().bind( Bindings.createDoubleBinding( () -> { double computedWidth = drawer.prefWidth(-1); // calculate the width the drawer can take up without being so large that it can't be // hidden anymore by clicking on the GlassPane (GlassPane covers minimum of 10%) double maxDrawerWidth = widthProperty().get() * 0.9; return Math.min(computedWidth, maxDrawerWidth); }, drawer.maxWidthProperty(), widthProperty() ) ); }
Example 3
Source File: ToolbarHelper.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** @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 4
Source File: TemplateField.java From pattypan with MIT License | 5 votes |
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 5
Source File: UIUtils.java From SONDY with GNU General Public License v3.0 | 5 votes |
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); }
Example 6
Source File: SearchBox.java From marathonv5 with Apache License 2.0 | 4 votes |
private void populateMenu(Map<DocumentType, List<SearchResult>> results) { contextMenu.getItems().clear(); for (Map.Entry<DocumentType, List<SearchResult>> entry : results.entrySet()) { boolean first = true; for(SearchResult result: entry.getValue()) { final SearchResult sr = result; final HBox hBox = new HBox(); hBox.setFillHeight(true); Label itemLabel = new Label(result.getName()); itemLabel.getStyleClass().add("item-label"); if (first) { first = false; Label groupLabel = new Label(result.getDocumentType().getPluralDisplayName()); groupLabel.getStyleClass().add("group-label"); groupLabel.setAlignment(Pos.CENTER_RIGHT); groupLabel.setMinWidth(USE_PREF_SIZE); groupLabel.setPrefWidth(70); hBox.getChildren().addAll(groupLabel,itemLabel); } else { Region spacer = new Region(); spacer.setMinWidth(USE_PREF_SIZE); spacer.setPrefWidth(70); hBox.getChildren().addAll(spacer,itemLabel); } // create a special node for hiding/showing popup content final Region popRegion = new Region(); popRegion.getStyleClass().add("search-menu-item-popup-region"); popRegion.setPrefSize(10, 10); hBox.getChildren().add(popRegion); final String name = (result.getDocumentType() == DocumentType.SAMPLE) ? result.getName() : result.getPackageName()+ ((result.getClassName() != null) ? "."+result.getClassName() : "") + ((result.getName() != null) ? "."+result.getName() : ""); final String shortDescription = (result.getShortDescription().length() == 160) ? result.getShortDescription() +"..." : result.getShortDescription(); popRegion.opacityProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { Platform.runLater( new Runnable() { // TODO runLater used here as a workaround for RT-14396 @Override public void run() { if (popRegion.getOpacity() == 1) { infoName.setText(name); infoDescription.setText(shortDescription); Point2D hBoxPos = hBox.localToScene(0, 0); extraInfoPopup.show(getScene().getWindow(), hBoxPos.getX() + contextMenu.getScene().getX() + contextMenu.getX() - infoBox.getPrefWidth() - 10, hBoxPos.getY() + contextMenu.getScene().getY() + contextMenu.getY() - 27 ); } } }); } }); // create menu item CustomMenuItem menuItem = new CustomMenuItem(hBox, true); menuItem.getStyleClass().add("search-menu-item"); contextMenu.getItems().add(menuItem); // handle item selection menuItem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { ///System.out.println("SearchBox.handle menuItem.setOnAction"); Ensemble2.getEnsemble2().goToPage(sr.getEnsemblePath(),true); } }); } } }
Example 7
Source File: SearchBox.java From marathonv5 with Apache License 2.0 | 4 votes |
private void populateMenu(Map<DocumentType, List<SearchResult>> results) { contextMenu.getItems().clear(); for (Map.Entry<DocumentType, List<SearchResult>> entry : results.entrySet()) { boolean first = true; for(SearchResult result: entry.getValue()) { final SearchResult sr = result; final HBox hBox = new HBox(); hBox.setFillHeight(true); Label itemLabel = new Label(result.getName()); itemLabel.getStyleClass().add("item-label"); if (first) { first = false; Label groupLabel = new Label(result.getDocumentType().getPluralDisplayName()); groupLabel.getStyleClass().add("group-label"); groupLabel.setAlignment(Pos.CENTER_RIGHT); groupLabel.setMinWidth(USE_PREF_SIZE); groupLabel.setPrefWidth(70); hBox.getChildren().addAll(groupLabel,itemLabel); } else { Region spacer = new Region(); spacer.setMinWidth(USE_PREF_SIZE); spacer.setPrefWidth(70); hBox.getChildren().addAll(spacer,itemLabel); } // create a special node for hiding/showing popup content final Region popRegion = new Region(); popRegion.getStyleClass().add("search-menu-item-popup-region"); popRegion.setPrefSize(10, 10); hBox.getChildren().add(popRegion); final String name = (result.getDocumentType() == DocumentType.SAMPLE) ? result.getName() : result.getPackageName()+ ((result.getClassName() != null) ? "."+result.getClassName() : "") + ((result.getName() != null) ? "."+result.getName() : ""); final String shortDescription = (result.getShortDescription().length() == 160) ? result.getShortDescription() +"..." : result.getShortDescription(); popRegion.opacityProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { Platform.runLater( new Runnable() { // TODO runLater used here as a workaround for RT-14396 @Override public void run() { if (popRegion.getOpacity() == 1) { infoName.setText(name); infoDescription.setText(shortDescription); Point2D hBoxPos = hBox.localToScene(0, 0); extraInfoPopup.show(getScene().getWindow(), hBoxPos.getX() + contextMenu.getScene().getX() + contextMenu.getX() - infoBox.getPrefWidth() - 10, hBoxPos.getY() + contextMenu.getScene().getY() + contextMenu.getY() - 27 ); } } }); } }); // create menu item CustomMenuItem menuItem = new CustomMenuItem(hBox, true); menuItem.getStyleClass().add("search-menu-item"); contextMenu.getItems().add(menuItem); // handle item selection menuItem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { ///System.out.println("SearchBox.handle menuItem.setOnAction"); Ensemble2.getEnsemble2().goToPage(sr.getEnsemblePath(),true); } }); } } }