Java Code Examples for javafx.scene.layout.Pane#setStyle()
The following examples show how to use
javafx.scene.layout.Pane#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: MarsNode.java From mars-sim with GNU General Public License v3.0 | 6 votes |
/** * Creates settlement nodes *@param color *@return Pane */ public Pane createPane(String color) { Pane pane = new Pane(); //pane.setPrefSize(400, 200); pane.setStyle("-fx-background-color: " + color); //pane.setEffect(new DropShadow(2d, 0d, +2d, Color.BLACK)); VBox v = new VBox(10); v.setSpacing(10); v.setPadding(new Insets(20, 20, 20, 20)); Collection<Settlement> settlements = Simulation.instance().getUnitManager().getSettlements(); List<Settlement> settlementList = new ArrayList<Settlement>(settlements); Iterator<Settlement> i = settlementList.iterator(); while(i.hasNext()) { Settlement settlement = i.next(); v.getChildren().addAll(createEach(settlement)); } pane.getChildren().add(v); return pane; }
Example 2
Source File: DockZones.java From AnchorFX with GNU Lesser General Public License v3.0 | 6 votes |
private void buildCircleStage() { circleStage = new Stage(); circleStage.initStyle(StageStyle.TRANSPARENT); circleStage.initOwner(this); circleZone = new Circle(CIRCLE_RADIUS); circleZone.setCenterX(CIRCLE_RADIUS); circleZone.setCenterY(CIRCLE_RADIUS); circleZone.getStyleClass().add("dockzone-circle-container-selectors"); circleStageRoot = new Pane(circleZone); circleStageRoot.setStyle("-fx-background-color:rgba(0,0,0,0);"); circleStageScene = new Scene(circleStageRoot, CIRCLE_RADIUS * 2, CIRCLE_RADIUS * 2, Color.TRANSPARENT); circleStage.setScene(circleStageScene); circleStageRoot.setOpacity(0); }
Example 3
Source File: RawColorType.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
@Override public Node getCellNode(TreeTableCell<ModularFeatureListRow, ObjectProperty<Color>> cell, TreeTableColumn<ModularFeatureListRow, ObjectProperty<Color>> coll, ObjectProperty<Color> value, RawDataFile raw) { Pane pane = new Pane(); pane.setStyle("-fx-background-color: #" + ColorsFX.toHexString(value.getValue() == null ? Color.BLACK : value.getValue())); return pane; }
Example 4
Source File: FillPatternStyleHelper.java From chart-fx with Apache License 2.0 | 5 votes |
private static Image createDefaultHatch(final Paint color, final double strokeWidth) { WeakHashMap<Double, Image> checkCache = FillPatternStyleHelper.defaultHatchCacheWithStrokeWidth.get(color); if (checkCache != null) { final Image val = checkCache.get(Double.valueOf(strokeWidth)); if (val != null) { // found existing Image with given parameter return val; } } // need to recompute hatch pattern image final Pane pane = new Pane(); pane.setPrefSize(10, 10); final Line fw = new Line(-5, -5, 25, 25); final Line bw = new Line(-5, 25, 25, -5); fw.setSmooth(false); bw.setSmooth(false); fw.setStroke(color); bw.setStroke(color); fw.setStrokeWidth(strokeWidth); bw.setStrokeWidth(strokeWidth); pane.getChildren().addAll(fw, bw); pane.setStyle("-fx-background-color: rgba(0, 0, 0, 0.0)"); final Scene scene = new Scene(pane); scene.setFill(Color.TRANSPARENT); final Image retVal = pane.snapshot(null, null); // add retVal to cache if (checkCache == null) { final WeakHashMap<Double, Image> temp = new WeakHashMap<>(); temp.put(Double.valueOf(strokeWidth), retVal); FillPatternStyleHelper.defaultHatchCacheWithStrokeWidth.put(color, temp); // checkCache = new WeakHashMap<>(); } else { checkCache.put(Double.valueOf(strokeWidth), retVal); } return retVal; }
Example 5
Source File: FillPatternStyleHelper.java From chart-fx with Apache License 2.0 | 5 votes |
private static Image createHatch(final FillPattern fillPattern, final Paint color, final double strokeWidth) { final Pane pane = new Pane(); pane.setPrefSize(FillPatternStyleHelper.HATCH_WINDOW_SIZE, FillPatternStyleHelper.HATCH_WINDOW_SIZE); pane.setStyle("-fx-background-color: rgba(0, 0, 0, 0.0)"); final int hatchAngle = 45; final int windowSize = 5 * FillPatternStyleHelper.HATCH_WINDOW_SIZE; FillPatternStyleHelper.drawHatching(pane, fillPattern, -windowSize, -windowSize, windowSize, windowSize, color, strokeWidth, hatchAngle, FillPatternStyleHelper.hatchSpacing); final Scene scene = new Scene(pane); scene.setFill(Color.TRANSPARENT); return pane.snapshot(null, null); }
Example 6
Source File: SidesPaneSample.java From chart-fx with Apache License 2.0 | 5 votes |
@Override public void start(final Stage stage) { stage.setTitle("TitledPane"); final Label label = new Label("top content\ntop content"); final Pane topContent = new Pane(label); topContent.setStyle("-fx-background-color: rgba(0,255,0,0.2)"); final Pane leftContent = new Pane(new Label("left content")); leftContent.setStyle("-fx-background-color: rgba(255,0,0,0.2)"); final Button button1 = new Button("press me to shrink"); button1.setOnAction(evt -> topContent.setPrefHeight(50)); final Button button2 = new Button("press me to enlarge"); button2.setOnAction(evt -> topContent.setPrefHeight(100)); final Pane mainContent = new Pane(new HBox(new Label("main content"), button1, button2)); final SidesPane pane = new SidesPane(); pane.setTriggerDistance(50); final Scene scene = new Scene(pane, 800, 600); pane.setTop(topContent); pane.setLeft(leftContent); pane.setContent(mainContent); topContent.setOnMouseClicked(mevt -> { final boolean isPinned = !pane.isPinned(Side.TOP); pane.setPinned(Side.TOP, isPinned); label.textProperty().set(String.format("top content(%b)%ntop content(%b)", isPinned, isPinned)); }); stage.setScene(scene); stage.show(); }
Example 7
Source File: NodeMenuItem.java From PDF4Teachers with Apache License 2.0 | 5 votes |
public void setLeftData(Node data){ Pane pane = new Pane(); if(fat){ pane.setStyle("-fx-font-size: 13; -fx-padding: 7 0 7 10;"); // top - right - bottom - left data.setTranslateY(7); }else{ pane.setStyle("-fx-font-size: 13; -fx-padding: 3 0 3 10;"); // top - right - bottom - left data.setTranslateY(3); } data.setTranslateX(10); pane.getChildren().add(data); getNode().getChildren().set(0, pane); }
Example 8
Source File: NodeMenuItem.java From PDF4Teachers with Apache License 2.0 | 5 votes |
public void setImage(ImageView image){ Pane pane = new Pane(); if(fat){ pane.setStyle("-fx-padding: 7 0 7 10;"); // top - right - bottom - left image.setTranslateY(7); }else{ pane.setStyle("-fx-padding: 3 0 3 10;"); // top - right - bottom - left image.setTranslateY(3); } image.setTranslateX(10); pane.getChildren().add(image); getNode().getChildren().set(1, pane); }
Example 9
Source File: DotHTMLLabelJavaFxNode.java From gef with Eclipse Public License 2.0 | 5 votes |
private void applyCssAttributesOnTdPane(Pane labelPane, HtmlTag tdTag, HtmlTag tableTag) { StringBuilder css = new StringBuilder(); /* * TODO Cellpadding * * Attributes that are not relevant for layouting of the HTML label * Href, Port, Title, Tooltip * * Currently unsupported throughout: Gefdot, Id */ // FIXEDSIZE="FALSE|TRUE" used in HEIGHT and WIDTH attributes HtmlAttr fixedSize = DotHtmlLabelHelper.getAttributeForTag(tdTag, "fixedsize"); //$NON-NLS-1$ appendBgcolorAttribute(css, DotHtmlLabelHelper.getAttributeForTag(tdTag, "bgcolor"), //$NON-NLS-1$ DotHtmlLabelHelper.getAttributeForTag(tdTag, "style"), //$NON-NLS-1$ DotHtmlLabelHelper.getAttributeForTag(tdTag, "gradientangle")); //$NON-NLS-1$ appendBorderAttribute(css, borderAttributeForTd(tdTag, tableTag)); appendColorAttribute(css, DotHtmlLabelHelper.getAttributeForTags("color", //$NON-NLS-1$ tdTag, tableTag)); appendHeightAttribute(css, DotHtmlLabelHelper.getAttributeForTag(tdTag, "height"), //$NON-NLS-1$ fixedSize); appendSidesAttribute(css, DotHtmlLabelHelper.getAttributeForTags("sides", tdTag, //$NON-NLS-1$ tableTag)); appendWidthAttribute(css, DotHtmlLabelHelper.getAttributeForTag(tdTag, "width"), //$NON-NLS-1$ fixedSize); labelPane.setStyle(css.toString()); }
Example 10
Source File: ParameterListInputPane.java From constellation with Apache License 2.0 | 4 votes |
private static void colorPaneByListPosition(final Pane pane, final int pos) { final String color = (pos % 2) == 0 ? EVEN_PARAM_COLOR : ODD_PARAM_COLOR; pane.setStyle(PARAM_COLOR_PROPERTY + color); }
Example 11
Source File: PluginParametersPane.java From constellation with Apache License 2.0 | 4 votes |
@Override public Pane getParamPane(final PluginParametersNode node) { if (node.getChildren().isEmpty()) { return null; } final GridPane paramGroupPane = new PluginParametersPane(); paramGroupPane.setMinHeight(0); GridPane.setHalignment(paramGroupPane, HPos.LEFT); paramGroupPane.setPadding(Insets.EMPTY); int row = 0; final DoubleProperty descriptionWidth = new SimpleDoubleProperty(); DoubleProperty maxLabelWidth = new SimpleDoubleProperty(); for (final PluginParametersNode child : node.getChildren()) { while (child.getFormatter().nextElement(child)) { final RowConstraints rowConstraints = new RowConstraints(); rowConstraints.setVgrow(Priority.NEVER); rowConstraints.setFillHeight(true); paramGroupPane.getRowConstraints().addAll(rowConstraints); final LabelDescriptionBox label = child.getFormatter().getParamLabel(child); if (label != null) { paramGroupPane.add(label, 0, row); GridPane.setValignment(label, VPos.TOP); GridPane.setHgrow(label, Priority.ALWAYS); GridPane.setFillHeight(label, false); label.bindDescriptionToProperty(descriptionWidth); maxLabelWidth = label.updateBindingWithLabelWidth(maxLabelWidth); } final Pane paramPane = child.getFormatter().getParamPane(child); if (paramPane != null) { paramPane.setStyle("-fx-padding: " + PADDING); GridPane.setValignment(paramPane, VPos.TOP); GridPane.setFillHeight(paramPane, false); if (label == null) { paramGroupPane.add(paramPane, 0, row, 2, 1); } else { paramGroupPane.add(paramPane, 1, row); } } final Button paramHelp = child.getFormatter().getParamHelp(child); if (paramHelp != null) { paramGroupPane.add(paramHelp, 2, row); GridPane.setMargin(paramHelp, new Insets(PADDING, PADDING, 0, 0)); GridPane.setValignment(paramHelp, VPos.TOP); GridPane.setFillHeight(paramHelp, false); } row++; } } descriptionWidth.bind(Bindings.max(50, maxLabelWidth)); return paramGroupPane; }
Example 12
Source File: SelectSongsDialog.java From Quelea with GNU General Public License v3.0 | 4 votes |
/** * Set the songs to be shown in the dialog. * <p/> * @param songs the list of songs to be shown. * @param checkList a list corresponding to the song list - each position is * true if the checkbox should be selected, false otherwise. * @param defaultVal the default value to use for the checkbox if checkList * is null or smaller than the songs list. */ public void setSongs(final List<SongDisplayable> songs, final Map<SongDisplayable, Boolean> checkList, final boolean defaultVal) { this.songs = songs; gridPane.getChildren().clear(); checkBoxes.clear(); gridPane.getColumnConstraints().add(new ColumnConstraints(20)); ColumnConstraints titleConstraints = new ColumnConstraints(); titleConstraints.setHgrow(Priority.ALWAYS); titleConstraints.setPercentWidth(50); gridPane.getColumnConstraints().add(titleConstraints); ColumnConstraints authorConstraints = new ColumnConstraints(); authorConstraints.setHgrow(Priority.ALWAYS); authorConstraints.setPercentWidth(45); gridPane.getColumnConstraints().add(authorConstraints); Label titleHeader = new Label(LabelGrabber.INSTANCE.getLabel("title.label")); titleHeader.setAlignment(Pos.CENTER); Label authorHeader = new Label(LabelGrabber.INSTANCE.getLabel("author.label")); authorHeader.setAlignment(Pos.CENTER); gridPane.add(titleHeader, 1, 0); gridPane.add(authorHeader, 2, 0); for(int i = 0; i < songs.size(); i++) { SongDisplayable song = songs.get(i); CheckBox checkBox = new CheckBox(); checkBox.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) { checkEnableButton(); } }); if(checkList != null) { final Boolean result = checkList.get(song); if(result!=null) { checkBox.setSelected(!result); } } checkBoxes.add(checkBox); gridPane.add(checkBox, 0, i + 1); gridPane.add(new Label(song.getTitle()), 1, i + 1); gridPane.add(new Label(song.getAuthor()), 2, i + 1); } for(int i = 0; i < 2; i++) { Node n = gridPane.getChildren().get(i); if(n instanceof Control) { Control control = (Control) n; control.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); control.setStyle("-fx-alignment: center;-fx-font-weight: bold;"); } if(n instanceof Pane) { Pane pane = (Pane) n; pane.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); pane.setStyle("-fx-alignment: center;-fx-font-weight: bold;"); } } gridScroll.setVvalue(0); checkEnableButton(); }
Example 13
Source File: ViewUtils.java From ApkToolPlus with Apache License 2.0 | 4 votes |
/** * 创建一个有光晕效果的矩形光圈 * * @param shadowSize 光晕大小 * @param r 0-255 * @param g 0-255 * @param b 0-255 * @param a 0-1 * @return */ // Create a shadow effect as a halo around the pane and not within // the pane's content area. public static Pane createShadowPane(int shadowSize, int r, int g, int b, float a) { StringBuilder rgbaBuider = new StringBuilder(); rgbaBuider.append(r).append(",") .append(g).append(",") .append(b).append(",") .append(a); Pane shadowPane = new Pane(); // a "real" app would do this in a CSS stylesheet. shadowPane.setStyle( "-fx-background-color: white;" + "-fx-effect: dropshadow(gaussian, rgba(" + rgbaBuider.toString() + "), " + shadowSize + ", 0, 0, 0);" + "-fx-background-insets: " + shadowSize + ";" ); Rectangle innerRect = new Rectangle(); Rectangle outerRect = new Rectangle(); shadowPane.layoutBoundsProperty().addListener( (observable, oldBounds, newBounds) -> { innerRect.relocate( newBounds.getMinX() + shadowSize, newBounds.getMinY() + shadowSize ); innerRect.setWidth(newBounds.getWidth() - shadowSize * 2); innerRect.setHeight(newBounds.getHeight() - shadowSize * 2); outerRect.setWidth(newBounds.getWidth()); outerRect.setHeight(newBounds.getHeight()); Shape clip = Shape.subtract(outerRect, innerRect); shadowPane.setClip(clip); } ); return shadowPane; }
Example 14
Source File: Exercise_16_01.java From Intro-to-Java-Programming with MIT License | 4 votes |
@Override // Override the stage method in the Application class public void start(Stage primaryStage) { HBox paneForButtons = new HBox(20); Button btLeft = new Button("<="); Button btRight = new Button("=>"); paneForButtons.getChildren().addAll(btLeft, btRight); paneForButtons.setAlignment(Pos.CENTER); BorderPane pane = new BorderPane(); pane.setBottom(paneForButtons); HBox paneForRadioButtons = new HBox(20); RadioButton rbRed = new RadioButton("Red"); RadioButton rbYellow = new RadioButton("Yellow"); RadioButton rbBlack = new RadioButton("Black"); RadioButton rbOrange = new RadioButton("Orange"); RadioButton rbGreen = new RadioButton("Green"); paneForRadioButtons.getChildren().addAll(rbRed, rbYellow, rbBlack, rbOrange, rbGreen); ToggleGroup group = new ToggleGroup(); rbRed.setToggleGroup(group); rbYellow.setToggleGroup(group); rbBlack.setToggleGroup(group); rbOrange.setToggleGroup(group); rbGreen.setToggleGroup(group); Pane paneForText = new Pane(); paneForText.setStyle("-fx-border-color: black"); paneForText.getChildren().add(text); pane.setCenter(paneForText); pane.setTop(paneForRadioButtons); btLeft.setOnAction(e -> text.setX(text.getX() - 10)); btRight.setOnAction(e -> text.setX(text.getX() + 10)); rbRed.setOnAction(e -> { if (rbRed.isSelected()) { text.setFill(Color.RED); } }); rbYellow.setOnAction(e -> { if (rbYellow.isSelected()) { text.setFill(Color.YELLOW); } }); rbBlack.setOnAction(e -> { if (rbBlack.isSelected()) { text.setFill(Color.BLACK); } }); rbOrange.setOnAction(e -> { if (rbOrange.isSelected()) { text.setFill(Color.ORANGE); } }); rbGreen.setOnAction(e -> { if (rbGreen.isSelected()) { text.setFill(Color.GREEN); } }); // Create a scene and place it in the stage Scene scene = new Scene(pane, 450, 150); primaryStage.setTitle("Exercise_16_01"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 15
Source File: DockZones.java From AnchorFX with GNU Lesser General Public License v3.0 | 3 votes |
private void buildUI() { mainRoot = new Pane(); mainRoot.setStyle("-fx-background-color:rgba(0,0,0,0);"); scene = new Scene(mainRoot, ownerStation.getWidth(), ownerStation.getHeight(), Color.TRANSPARENT); setScene(scene); Point2D screenOrigin = ownerStation.localToScreen(ownerStation.getBoundsInLocal().getMinX(), ownerStation.getBoundsInLocal().getMinY()); setX(screenOrigin.getX()); setY(screenOrigin.getY()); }