Java Code Examples for javafx.scene.control.Label#setMaxWidth()
The following examples show how to use
javafx.scene.control.Label#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: IssueCard.java From HubTurbo with GNU Lesser General Public License v3.0 | 6 votes |
private void setup() { TurboIssue issue = guiElement.getIssue(); Label issueTitle = new Label("#" + issue.getId() + " " + issue.getTitle()); issueTitle.setMaxWidth(CARD_WIDTH); issueTitle.setWrapText(true); issueTitle.getStyleClass().add("issue-panel-name"); if (issue.isCurrentlyRead()) { issueTitle.getStyleClass().add("issue-panel-name-read"); } if (!issue.isOpen()) { issueTitle.getStyleClass().add("issue-panel-closed"); } updateDetails(); setPadding(new Insets(0, 0, 0, 0)); setSpacing(1); getChildren().addAll(issueTitle, issueDetails); }
Example 2
Source File: ServerController.java From ChatFX with MIT License | 6 votes |
private void addMsg(String msg, boolean senderIsServer) { Label lbl = new Label(msg); lbl.setStyle("-fx-font-size: 16px;" + "-fx-background-color: #" + (senderIsServer ? "B00020" : "2196f3") + ";" + "-fx-text-fill: #FFF;" + "-fx-background-radius:25;" + "-fx-padding: 10px;"); lbl.setWrapText(true); lbl.setMaxWidth(400); HBox container = new HBox(); if(!senderIsServer) { container.getChildren().add(new ImageView(new Image("/images/client-48px.png"))); container.setAlignment(Pos.CENTER_LEFT); container.setSpacing(10); container.setPadding(new Insets(0, 10, 0, 0)); } else { container.setAlignment(Pos.CENTER_RIGHT); container.setPadding(new Insets(0, 10, 0, 10)); } container.getChildren().add(lbl); container.setPrefHeight(40); msgNodes.getItems().add(container); }
Example 3
Source File: PluginParametersPane.java From constellation with Apache License 2.0 | 6 votes |
@Override public final LabelDescriptionBox buildParameterLabel(final PluginParameter<?> parameter) { final Label label = new Label(parameter.getName() + ":"); final Label description = new Label(parameter.getDescription()); label.setMinWidth(120); label.setPrefWidth(200); label.setMaxWidth(400); label.setWrapText(true); description.setStyle("-fx-font-size: 80%;"); description.getStyleClass().add("description-label"); description.setMinWidth(120); description.setPrefWidth(200); description.setMaxWidth(400); description.setWrapText(true); final LabelDescriptionBox labels = new LabelDescriptionBox(label, description); labels.setStyle("-fx-padding: " + PADDING); labels.setVisible(parameter.isVisible()); labels.setManaged(parameter.isVisible()); parameter.setVisible(parameter.isVisible()); linkParameterLabelToTop(parameter, labels); return labels; }
Example 4
Source File: ChatController.java From ChatFX with MIT License | 6 votes |
private void addMsg(String msg, boolean senderIsRobot) { Label lbl = new Label(msg); lbl.setStyle("-fx-font-size: 16px;" + "-fx-background-color: #" + ((senderIsRobot) ? "B00020" : "2196f3") + ";" + "-fx-text-fill: #FFF;" + "-fx-background-radius:25;" + "-fx-padding: 10px;"); lbl.setWrapText(true); lbl.setMaxWidth(400); HBox container = new HBox(); container.setPrefHeight(40); container.setAlignment(Pos.CENTER_LEFT); container.setPadding(new Insets(0, 10, 0, 10)); container.setSpacing(10); container.getChildren().add(lbl); msgNodes.getItems().add(container); }
Example 5
Source File: JFXDefaultChip.java From JFoenix with Apache License 2.0 | 6 votes |
public JFXDefaultChip(JFXChipView<T> view, T item) { super(view, item); JFXButton closeButton = new JFXButton(null, new SVGGlyph()); closeButton.getStyleClass().add("close-button"); closeButton.setOnAction((event) -> view.getChips().remove(item)); String tagString = null; if (getItem() instanceof String) { tagString = (String) getItem(); } else { tagString = view.getConverter().toString(getItem()); } Label label = new Label(tagString); label.setWrapText(true); root = new HBox(label, closeButton); getChildren().setAll(root); label.setMaxWidth(100); }
Example 6
Source File: CFileChooser.java From Open-Lowcode with Eclipse Public License 2.0 | 6 votes |
@Override public Node getNode( PageActionManager actionmanager, CPageData inputdata, Window parentwindow, TabPane[] parenttabpanes, CollapsibleNode nodetocollapsewhenactiontriggered) { FlowPane thispane = new FlowPane(); Label thislabel = new Label(title); thislabel.setFont(Font.font(thislabel.getFont().getName(), FontPosture.ITALIC, thislabel.getFont().getSize())); thislabel.setMinWidth(120); thislabel.setWrapText(true); thislabel.setMaxWidth(120); thispane.setRowValignment(VPos.TOP); thispane.getChildren().add(thislabel); filepathfield = new TextField(); Button loadfromfile = new Button("Select"); loadfromfile.setStyle("-fx-base: #ffffff; -fx-hover-base: #ddeeff;"); thispane.getChildren().add(filepathfield); thispane.getChildren().add(loadfromfile); loadfromfile.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { FileChooser fileChooser = new FileChooser(); selectedfile = fileChooser.showOpenDialog(null); if (selectedfile != null) filepathfield.setText(selectedfile.getAbsolutePath()); } }); return thispane; }
Example 7
Source File: WaitMessageDialog.java From marathonv5 with Apache License 2.0 | 6 votes |
private void initComponents() { messageLabel = new Label(message); messageLabel.setAlignment(Pos.CENTER); messageLabel.setStyle("-fx-background-color:#000000"); messageLabel.setTextFill(javafx.scene.paint.Color.WHITE); messageLabel.setMaxWidth(Double.MAX_VALUE); // Bind the timerLabel text property to the timeSeconds property timerLabel.setStyle("-fx-font-size: 2em"); timerLabel.textProperty().bind(timeSeconds.asString()); timerLabel.setTextFill(Color.RED); VBox vbox = new VBox(FXUIUtils.getImage("wait"), messageLabel); StackPane.setMargin(timerLabel, new Insets(90, 0, 0, 0)); StackPane root = new StackPane(vbox, timerLabel); setScene(new Scene(root)); }
Example 8
Source File: ResourceView.java From sis with Apache License 2.0 | 6 votes |
private void addFeaturePanel(String filePath) { try { DataStore ds = DataStores.open(filePath); setContent(new FeatureTable(ds, 18)); root.getChildren().addAll(temp); temp.clear(); } catch (DataStoreException e) { final Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("An error has occurred"); Label lab = new Label(e.getMessage()); lab.setWrapText(true); lab.setMaxWidth(650); VBox vb = new VBox(); vb.getChildren().add(lab); alert.getDialogPane().setContent(vb); alert.show(); } }
Example 9
Source File: SiriusCompound.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
public SimpleObjectProperty<Node>getDBSNode(){ String dbs[] = this.getDBS(); VBox vBox = new VBox(); String dbsWords=""; Label label = new Label(); label.setMaxWidth(180); label.setWrapText(true); for(String S:dbs) { dbsWords+=S+" \n"; } label.setText(dbsWords); vBox.getChildren().add(label); return new SimpleObjectProperty<>(label); }
Example 10
Source File: ScriptingAspectEditor.java From milkman with MIT License | 6 votes |
private Tab getTab(Supplier<String> getter, Consumer<String> setter, String title) { ContentEditor postEditor = new ContentEditor(); postEditor.setEditable(true); postEditor.setContent(getter, setter); postEditor.setContentTypePlugins(Collections.singletonList(new JavascriptContentType())); postEditor.setContentType("application/javascript"); postEditor.setHeaderVisibility(false); Tab postTab = new Tab("", postEditor); Label label = new Label(title); label.setRotate(90); label.setMinWidth(150); label.setMaxWidth(150); label.setMinHeight(40); label.setMaxHeight(40); label.setPadding(new Insets(0)); postTab.setGraphic(label); return postTab; }
Example 11
Source File: OptionsDialog.java From milkman with MIT License | 6 votes |
public void showAndWait(List<OptionPageProvider> optionPageProviders) { JFXDialogLayout content = new OptionsDialogFxml(this); content.setPrefWidth(600); for(OptionPageProvider<?> p : optionPageProviders) { OptionDialogPane pane = p.getOptionsDialog(new OptionDialogBuilder()); Tab tab = new Tab("", pane); Label label = new Label(pane.getName()); label.setRotate(90); label.setMinWidth(100); label.setMaxWidth(100); label.setMinHeight(40); label.setMaxHeight(40); tab.setGraphic(label); tabs.getTabs().add(tab); } dialog = FxmlUtil.createDialog(content); dialog.showAndWait(); }
Example 12
Source File: InfoAutoTooltipLabel.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
private PopOver createInfoPopOver(String info, double width) { Label helpLabel = new Label(info); helpLabel.setMaxWidth(width); helpLabel.setWrapText(true); helpLabel.setPadding(new Insets(10)); return createInfoPopOver(helpLabel); }
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: 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 15
Source File: TransactionTypeNodeProvider.java From constellation with Apache License 2.0 | 5 votes |
/** * A Label containing bold text. * * @param text * @return */ private static Node boldLabel(final String text) { final Label label = new Label(text); label.setStyle("-fx-font-weight: bold;"); label.setMinWidth(Region.USE_PREF_SIZE); label.setMaxWidth(Region.USE_PREF_SIZE); return label; }
Example 16
Source File: MarsNode.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public Label createPerson(Person person) { //Button b = new Button(person.getName()); Label l = new Label(person.getName()); l.setPadding(new Insets(20)); l.setMaxWidth(Double.MAX_VALUE); l.setId("settlement-node"); l.getStylesheets().add("/fxui/css/personnode.css"); l.setOnMouseClicked(new EventHandler<MouseEvent>() { PopOver popOver = null; @Override public void handle(MouseEvent evt) { if (popOver == null ) { popOver = createPopOver(l, person); } else if (evt.getClickCount() >= 1) { popOver.hide(Duration.seconds(.5)); } else if (popOver.isShowing()) { popOver.hide(Duration.seconds(.5)); } else if (!popOver.isShowing()) { popOver = createPopOver(l, person); } } }); return l; }
Example 17
Source File: AutoTooltipTableColumn.java From bisq with GNU Affero General Public License v3.0 | 4 votes |
private PopOver createInfoPopOver(String help) { Label helpLabel = new Label(help); helpLabel.setMaxWidth(300); helpLabel.setWrapText(true); return createInfoPopOver(helpLabel); }
Example 18
Source File: FX.java From FxDock with Apache License 2.0 | 4 votes |
/** creates a label. accepts: CssStyle, CssID, FxCtl, Insets, OverrunStyle, Pos, TextAlignment, Color, Node, Background */ public static Label label(Object ... attrs) { Label n = new Label(); for(Object a: attrs) { if(a == null) { // ignore } else if(a instanceof CssStyle) { n.getStyleClass().add(((CssStyle)a).getName()); } else if(a instanceof CssID) { n.setId(((CssID)a).getID()); } else if(a instanceof FxCtl) { switch((FxCtl)a) { case BOLD: n.getStyleClass().add(CssTools.BOLD.getName()); break; case FOCUSABLE: n.setFocusTraversable(true); break; case FORCE_MAX_WIDTH: n.setMaxWidth(Double.MAX_VALUE); break; case FORCE_MIN_HEIGHT: n.setMinHeight(Control.USE_PREF_SIZE); break; case FORCE_MIN_WIDTH: n.setMinWidth(Control.USE_PREF_SIZE); break; case NON_FOCUSABLE: n.setFocusTraversable(false); break; case WRAP_TEXT: n.setWrapText(true); break; default: throw new Error("?" + a); } } else if(a instanceof Insets) { n.setPadding((Insets)a); } else if(a instanceof OverrunStyle) { n.setTextOverrun((OverrunStyle)a); } else if(a instanceof Pos) { n.setAlignment((Pos)a); } else if(a instanceof String) { n.setText((String)a); } else if(a instanceof TextAlignment) { n.setTextAlignment((TextAlignment)a); } else if(a instanceof Color) { n.setTextFill((Color)a); } else if(a instanceof StringProperty) { n.textProperty().bind((StringProperty)a); } else if(a instanceof Node) { n.setGraphic((Node)a); } else if(a instanceof Background) { n.setBackground((Background)a); } else { throw new Error("?" + a); } } return n; }
Example 19
Source File: MessageItem.java From helloiot with GNU General Public License v3.0 | 4 votes |
public MessageItem(EventMessage message) { getStyleClass().add("message"); setMaxSize(Double.MAX_VALUE, 60.0); setMinSize(Control.USE_COMPUTED_SIZE, 60.0); setPrefSize(Control.USE_COMPUTED_SIZE, 60.0); HBox.setHgrow(this, Priority.SOMETIMES); StringFormat format = StringFormatIdentity.INSTANCE; String txt = format.format(format.value(message.getMessage())); Label messageview = new Label(txt); messageview.setTextOverrun(OverrunStyle.ELLIPSIS); messageview.getStyleClass().add("unitinputview"); BorderPane.setAlignment(messageview, Pos.CENTER_LEFT); setCenter(messageview); HBox footer = new HBox(); Label topictext = new Label(message.getTopic()); topictext.setTextOverrun(OverrunStyle.ELLIPSIS); topictext.getStyleClass().add("messagefooter"); topictext.setMaxWidth(Double.MAX_VALUE); HBox.setHgrow(topictext, Priority.ALWAYS); footer.getChildren().add(topictext); DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM); Label datetext = new Label(LocalDateTime.now().format(dtf)); datetext.getStyleClass().add("messagefooter"); footer.getChildren().add(datetext); MiniVar v2 = message.getProperty("mqtt.retained"); if (v2 != null && v2.asBoolean()) { Label retainedtext = new Label(resources.getString("badge.retained")); retainedtext.getStyleClass().addAll("badge", "badgeretained"); footer.getChildren().add(retainedtext); } MiniVar v = message.getProperty("mqtt.qos"); if (v != null) { Label qostext = new Label(String.format(resources.getString("badge.qos"), v.asInt())); qostext.getStyleClass().addAll("badge", "badgeqos"); footer.getChildren().add(qostext); } setBottom(footer); }
Example 20
Source File: HTMLEditorSample.java From marathonv5 with Apache License 2.0 | 4 votes |
public HTMLEditorSample() { VBox vRoot = new VBox(); vRoot.setPadding(new Insets(8, 8, 8, 8)); vRoot.setSpacing(5); htmlEditor = new HTMLEditor(); htmlEditor.setPrefSize(500, 245); htmlEditor.setHtmlText(INITIAL_TEXT); vRoot.getChildren().add(htmlEditor); final Label htmlLabel = new Label(); htmlLabel.setMaxWidth(500); htmlLabel.setWrapText(true); ScrollPane scrollPane = new ScrollPane(); scrollPane.getStyleClass().add("noborder-scroll-pane"); scrollPane.setContent(htmlLabel); scrollPane.setFitToWidth(true); scrollPane.setPrefHeight(180); Button showHTMLButton = new Button("Show the HTML below"); vRoot.setAlignment(Pos.CENTER); showHTMLButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { htmlLabel.setText(htmlEditor.getHtmlText()); } }); vRoot.getChildren().addAll(showHTMLButton, scrollPane); getChildren().addAll(vRoot); // REMOVE ME // Workaround for RT-16781 - HTML editor in full screen has wrong border javafx.scene.layout.GridPane grid = (javafx.scene.layout.GridPane)htmlEditor.lookup(".html-editor"); for(javafx.scene.Node child: grid.getChildren()) { javafx.scene.layout.GridPane.setHgrow(child, javafx.scene.layout.Priority.ALWAYS); } // END REMOVE ME }