Java Code Examples for javafx.scene.control.Label#setStyle()
The following examples show how to use
javafx.scene.control.Label#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: AutoCompleteItem.java From BlockMap with MIT License | 6 votes |
public AutoCompleteItem() { name = new Label(); name.setAlignment(Pos.CENTER_LEFT); name.setStyle("-fx-font-weight: bold;"); path = new Label(); path.setMaxWidth(Double.POSITIVE_INFINITY); HBox.setHgrow(path, Priority.ALWAYS); HBox.setMargin(path, new Insets(0, 8, 0, 0)); path.setAlignment(Pos.CENTER_RIGHT); path.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS); graphic = new ImageView(); graphic.setPreserveRatio(true); graphic.fitHeightProperty().bind(Bindings.createDoubleBinding(() -> name.getFont().getSize() * 1.2, name.fontProperty())); setText(null); setGraphic(new HBox(2, graphic, name, path)); setPrefWidth(0); }
Example 2
Source File: DefaultUIProvider.java From fxlauncher with Apache License 2.0 | 5 votes |
public Parent createUpdater(FXManifest manifest) { progressBar = new ProgressBar(); progressBar.setStyle(manifest.progressBarStyle); Label label = new Label(manifest.updateText); label.setStyle(manifest.updateLabelStyle); VBox wrapper = new VBox(label, progressBar); wrapper.setStyle(manifest.wrapperStyle); return wrapper; }
Example 3
Source File: PickerRepository.java From HubTurbo with GNU Lesser General Public License v3.0 | 5 votes |
public Node getNode() { Label repoLabel = new Label(); repoLabel.setPrefWidth(REPO_LABEL_PREFERRED_WIDTH); repoLabel.setPadding(DEFAULT_REPO_LABEL_PADDING); if (isSelected) { repoLabel.setText(repositoryId); repoLabel.setStyle(COMMON_REPO_LABEL_STYLE + SELECTED_REPO_LABEL_STYLE); } else { repoLabel.setText(repositoryId); repoLabel.setStyle(COMMON_REPO_LABEL_STYLE + DEFAULT_REPO_LABEL_STYLE); } return repoLabel; }
Example 4
Source File: Carousel.java From DashboardFx with GNU General Public License v3.0 | 5 votes |
private ObservableList<Node> createItems(){ Label lb1 = new Label("First"); Label lb2 = new Label("Second"); Label lb3 = new Label("Third"); Label lb4 = new Label("Fourth"); Label lb5 = new Label("Fifth"); lb1.setStyle("-fx-text-fill : white;"); lb2.setStyle("-fx-text-fill : white;"); lb3.setStyle("-fx-text-fill : white;"); lb4.setStyle("-fx-text-fill : white;"); lb5.setStyle("-fx-text-fill : white;"); VBox v1 = new VBox(lb1); VBox v2 = new VBox(lb2); VBox v3 = new VBox(lb3); VBox v4 = new VBox(lb4); VBox v5 = new VBox(lb5); v1.setAlignment(Pos.CENTER); v2.setAlignment(Pos.CENTER); v3.setAlignment(Pos.CENTER); v4.setAlignment(Pos.CENTER); v5.setAlignment(Pos.CENTER); v1.setStyle("-fx-background-color : #FF3547;"); v2.setStyle("-fx-background-color : #512DA8;"); v3.setStyle("-fx-background-color : #48CFAD;"); v4.setStyle("-fx-background-color : #02C852;"); v5.setStyle("-fx-background-color : #EC407A;"); return FXCollections.observableArrayList(v1, v2, v3, v4, v5); }
Example 5
Source File: PickerAssignee.java From HubTurbo with GNU Lesser General Public License v3.0 | 5 votes |
private Label getAssigneeLabelWithAvatar() { Label assignee = new Label(getLoginName()); assignee.setGraphic(getAvatarImageView()); FontLoader fontLoader = Toolkit.getToolkit().getFontLoader(); double width = fontLoader.computeStringWidth(assignee.getText(), assignee.getFont()); assignee.setPrefWidth(width + 35 + AVATAR_SIZE); assignee.setPrefHeight(LABEL_HEIGHT); assignee.getStyleClass().add("labels"); assignee.setStyle("-fx-background-color: lightgreen;"); return assignee; }
Example 6
Source File: ReportVisualisation.java From constellation with Apache License 2.0 | 5 votes |
public ReportVisualisation() { final HBox pluginsReportBox = new HBox(); final Label pluginsRunLabel = new Label("Plugins Run: "); pluginsRunLabel.setStyle(JavafxStyleManager.CSS_FONT_WEIGHT_BOLD); this.pluginsRunValue = new Label(); pluginsRunValue.setWrapText(true); pluginsReportBox.getChildren().addAll(pluginsRunLabel, pluginsRunValue); final HBox numberOfResultsReportBox = new HBox(); final Label numberOfResultsLabel = new Label("Number of Results: "); numberOfResultsLabel.setStyle(JavafxStyleManager.CSS_FONT_WEIGHT_BOLD); this.numberOfResultsValue = new Label(); numberOfResultsValue.setWrapText(true); numberOfResultsReportBox.getChildren().addAll(numberOfResultsLabel, numberOfResultsValue); final HBox aggregationMethodReportBox = new HBox(); final Label aggregationMethodLabel = new Label("Aggregation Method: "); aggregationMethodLabel.setStyle(JavafxStyleManager.CSS_FONT_WEIGHT_BOLD); this.aggregationMethodValue = new Label(); aggregationMethodValue.setWrapText(true); aggregationMethodReportBox.getChildren().addAll(aggregationMethodLabel, aggregationMethodValue); final HBox exceptionsReportBox = new HBox(); final Label exceptionsLabel = new Label("Exceptions: "); exceptionsLabel.setStyle(JavafxStyleManager.CSS_FONT_WEIGHT_BOLD); this.exceptionsValue = new Label(); exceptionsValue.setWrapText(true); exceptionsReportBox.getChildren().addAll(exceptionsLabel, exceptionsValue); this.report = new VBox(pluginsReportBox, numberOfResultsReportBox, aggregationMethodReportBox, exceptionsReportBox); }
Example 7
Source File: FxlDemo.java From fxldemo with Apache License 2.0 | 5 votes |
public void start(Stage stage) throws Exception { stage.setTitle("Hello World"); stage.initStyle(StageStyle.UNDECORATED); Label label = new Label(stage.getTitle()); label.setStyle("-fx-font-size: 25"); // Alibi for including ControlsFX Dependency :) SegmentedButton fxcontrol = new SegmentedButton(new ToggleButton("One"), new ToggleButton("Two"), new ToggleButton("Three")); // Did we get any arguments? getParameters().getNamed().forEach((name, value) -> System.out.println(String.format("%s=%s", name, value))); Button fxmlButton = new Button("Open FXML View"); fxmlButton.setOnAction(this::openFxmlView); Button exitButton = new Button("Exit"); exitButton.setStyle("-fx-font-weight: bold"); exitButton.setOnAction(event -> Platform.exit()); HBox buttons = new HBox(10, fxmlButton, exitButton); VBox root = new VBox(label, fxcontrol, buttons); root.setAlignment(Pos.CENTER); root.setSpacing(20); root.setPadding(new Insets(25)); root.setStyle("-fx-border-color: lightblue"); stage.setScene(new Scene(root)); stage.show(); }
Example 8
Source File: TabController.java From mars-sim with GNU General Public License v3.0 | 5 votes |
private void configureTab(Tab tab, String title, String iconPath, AnchorPane containerPane, URL resourceURL, EventHandler<Event> onSelectionChangedEvent) { double imageWidth = 40.0; ImageView imageView = new ImageView(new Image(iconPath)); imageView.setFitHeight(imageWidth); imageView.setFitWidth(imageWidth); Label label = new Label(title); label.setMaxWidth(tabWidth - 20); label.setPadding(new Insets(5, 0, 0, 0)); label.setStyle("-fx-text-fill: black; -fx-font-size: 10pt; -fx-font-weight: bold;"); label.setTextAlignment(TextAlignment.CENTER); BorderPane tabPane = new BorderPane(); tabPane.setRotate(90.0); tabPane.setMaxWidth(tabWidth); tabPane.setCenter(imageView); tabPane.setBottom(label); tab.setText(""); tab.setGraphic(tabPane); tab.setOnSelectionChanged(onSelectionChangedEvent); if (containerPane != null && resourceURL != null) { try { Parent contentView = FXMLLoader.load(resourceURL); containerPane.getChildren().add(contentView); AnchorPane.setTopAnchor(contentView, 0.0); AnchorPane.setBottomAnchor(contentView, 0.0); AnchorPane.setRightAnchor(contentView, 0.0); AnchorPane.setLeftAnchor(contentView, 0.0); } catch (IOException e) { e.printStackTrace(); } } }
Example 9
Source File: ToggleButtonSample.java From marathonv5 with Apache License 2.0 | 5 votes |
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 10
Source File: CircleProperties.java From UndoFX with BSD 2-Clause "Simplified" License | 5 votes |
private static HBox labeled(String labelText, Node node) { Label label = new Label(labelText); label.setStyle("-fx-font-weight: bold;"); HBox hbox = new HBox(15, label, node); hbox.setAlignment(Pos.CENTER); return hbox; }
Example 11
Source File: NaviSelectDemo.java From tornadofx-controls with Apache License 2.0 | 5 votes |
public void start(Stage stage) throws Exception { stage.setTitle("NaviSelect Demo"); HBox root = new HBox(10); root.setAlignment(Pos.CENTER_LEFT); root.setPadding(new Insets(50)); Label label = new Label("Choose customer:"); label.setStyle("-fx-font-weight: bold"); NaviSelect<Email> navi = new NaviSelect<>(); navi.setValue(new Email("[email protected]", "John Doe")); navi.setVisualConverter(Email::getName); navi.setOnEdit(event -> selectEmail(navi)); navi.setOnGoto(event -> { Alert alert = new Alert(INFORMATION); alert.setContentText(String.format("Action to navigate to %s should be placed here.", navi.getValue())); alert.setHeaderText("Goto action triggered"); alert.show(); }); root.getChildren().addAll(label, navi, new TextField()); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); }
Example 12
Source File: CursorSample.java From marathonv5 with Apache License 2.0 | 5 votes |
private Node createBox(Cursor cursor) { Label label = new Label(cursor.toString()); label.setAlignment(Pos.CENTER); label.setPrefSize(85, 85); label.setStyle("-fx-border-color: #aaaaaa; -fx-background-color: #dddddd;"); label.setCursor(cursor); return label; }
Example 13
Source File: IssuePickerDialog.java From HubTurbo with GNU Lesser General Public License v3.0 | 5 votes |
private Label createRepoTitle(String name) { Label repoName = new Label(name + ": "); repoName.setPadding(new Insets(0, 5, 5, 0)); repoName.setMaxWidth(ELEMENT_MAX_WIDTH - 10); repoName.setStyle("-fx-font-size: 110%; -fx-font-weight: bold; "); return repoName; }
Example 14
Source File: CustomNodeSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public MyNode(String name) { text = new Label(name); text.setStyle("-fx-border-color:black; -fx-padding:3px;"); text.setLayoutX(4); text.setLayoutY(2); getChildren().addAll(text); }
Example 15
Source File: QueryListPaneFrame.java From oim-fx with MIT License | 5 votes |
private void initComponent() { this.setTitle("设备列表"); this.setResizable(false); this.setWidth(960); this.setHeight(600); this.setTitlePaneStyle(2); this.setRadius(5); BorderPane rootPane = new BorderPane(); this.setCenter(rootPane); Label titleLabel = new Label(); titleLabel.setText("设备列表"); titleLabel.setFont(Font.font("微软雅黑", 30)); titleLabel.setStyle("-fx-text-fill:rgba(255, 255, 255, 1)"); HBox hBox = new HBox(); hBox.setMinHeight(35); hBox.setStyle("-fx-background-color:rgba(18, 98, 217, 1)"); hBox.getChildren().add(titleLabel); rootPane.setTop(hBox); rootPane.setCenter(queryListPane); this.showWaiting(false, WaitingPane.show_waiting); this.setPage(0, 1); }
Example 16
Source File: MarathonSplashScreen.java From marathonv5 with Apache License 2.0 | 4 votes |
private Label createLabel(String labelText) { Label label = new Label(labelText); label.setStyle("-fx-text-fill:white"); return label; }
Example 17
Source File: PickerMilestone.java From HubTurbo with GNU Lesser General Public License v3.0 | 4 votes |
private void setStatusColour(Label milestone) { String colour = isOpen() ? (isOverdue() ? OVERDUE_COLOUR : OPEN_COLOUR) : CLOSED_COLOUR; milestone.setStyle("-fx-background-color: " + colour + ";"); }
Example 18
Source File: AlertCell.java From DashboardFx with GNU General Public License v3.0 | 4 votes |
public void setTime(Label time) { time.setStyle("-fx-text-fill : -text-color;"); this.time = time; }
Example 19
Source File: GameElimniationController.java From MyBox with Apache License 2.0 | 4 votes |
protected void afterElimination(int imageIndex, int size) { try { if (isSettingValues || !countScore || !countedChesses.contains(imageIndex)) { return; } int add = scoreRulers.get(size); totalScore += add; long cost = new Date().getTime() - startTime.getTime(); scoreLabel.setText(message("Score") + ": " + totalScore + " " + message("Cost") + ": " + DateTools.showSeconds(cost / 1000)); if (add > 0) { if (scoreCheck.isSelected()) { Label popupLabel = new Label("+" + add); popupLabel.setStyle("-fx-background-color:black;" + " -fx-text-fill: gold;" + " -fx-font-size: 3em;" + " -fx-padding: 10px;" + " -fx-background-radius: 10;"); final Popup scorePopup = new Popup(); scorePopup.setAutoFix(true); scorePopup.setAutoHide(true); scorePopup.getContent().add(popupLabel); FxmlControl.locateUp(scoreLabel, scorePopup); Timer stimer = new Timer(); stimer.schedule(new TimerTask() { @Override public void run() { Platform.runLater(new Runnable() { @Override public void run() { scorePopup.hide(); } }); } }, 1000); } if (guaiRadio.isSelected()) { FxmlControl.GuaiAO(); } else if (benRadio.isSelected()) { FxmlControl.BenWu(); } else if (guaiBenRadio.isSelected()) { if (size == 3) { FxmlControl.BenWu(); } else { FxmlControl.GuaiAO(); } } else if (customizedSoundRadio.isSelected() && soundFile != null && soundFile.exists()) { FxmlControl.mp3(soundFile); } } } catch (Exception e) { } }
Example 20
Source File: BoardPresenter.java From Game2048FX with GNU General Public License v3.0 | 4 votes |
@Override protected void updateItem(Score item, boolean empty) { super.updateItem(item, empty); if (item != null && !empty) { int pos=Math.min(getIndex(),LIST_SIZE-1); Text text = new Text(""+(pos+1)); text.setStyle("-fx-font-weight: bold;" + "-fx-fill: derive(-primary-swatch-" + swatchs[pos] + ",-30%);"); Image img = Score.getImage(item.getUserPic()); ImageView imageView = new ImageView(img); Services.get(DisplayService.class) .ifPresent(d -> { if (d.isTablet()) { tam = 42; spacing = 15; } }); imageView.setFitHeight(tam); imageView.setFitWidth(tam); HBox hbox = new HBox(spacing, text,imageView); hbox.setAlignment(Pos.CENTER_RIGHT); listTile.setPrimaryGraphic(hbox); listTile.textProperty().setAll(item.getUserName(), sdf.format(new Date(item.getTimeStamp()))); Label text1 = new Label(""+item.getScore()); text1.setStyle("-fx-text-fill: derive(-primary-swatch-" + swatchs[pos] + ",-30%);"); listTile.setSecondaryGraphic(text1); setPadding(new Insets(0)); setText(null); setGraphic(listTile); } else { setText(null); setGraphic(null); } }