List of usage examples for javafx.scene.control Label setPrefWidth
public final void setPrefWidth(double value)
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Label Sample"); stage.setWidth(400);/* ww w .j a va 2s . c o m*/ stage.setHeight(180); HBox hbox = new HBox(); Label label1 = new Label("Search long long long long long long long long long "); label1.setPrefWidth(100); label1.setWrapText(true); hbox.setSpacing(10); hbox.getChildren().add((label1)); ((Group) scene.getRoot()).getChildren().add(hbox); stage.setScene(scene); stage.show(); }
From source file:com.gmail.frogocomics.schematic.gui.Main.java
@Override public void start(Stage primaryStage) throws Exception { this.primaryStage = primaryStage; this.root = new GridPane(); this.primaryScene = new Scene(this.root, 1000, 600, Color.AZURE); Label title = new Label("Schematic Utilities"); title.setId("schematic-utilities"); title.setPrefWidth(this.primaryScene.getWidth() + 500); this.root.add(title, 0, 0); filesSelected.setId("files-selected"); this.root.add(filesSelected, 0, 1); Region spacer1 = new Region(); spacer1.setPrefWidth(30);// w w w.j ava 2s .c om spacer1.setPrefHeight(30); Region spacer2 = new Region(); spacer2.setPrefWidth(30); spacer2.setPrefHeight(30); Region spacer3 = new Region(); spacer3.setPrefWidth(30); spacer3.setPrefHeight(250); Region spacer4 = new Region(); spacer4.setPrefWidth(1000); spacer4.setPrefHeight(10); Region spacer5 = new Region(); spacer5.setPrefWidth(30); spacer5.setPrefHeight(30); Region spacer6 = new Region(); spacer6.setPrefWidth(1000); spacer6.setPrefHeight(10); Region spacer7 = new Region(); spacer7.setPrefWidth(1000); spacer7.setPrefHeight(100); Region spacer8 = new Region(); spacer8.setPrefWidth(30); spacer8.setPrefHeight(30); this.root.add(spacer4, 0, 3); listView.setId("schematic-list"); listView.setEditable(false); listView.setPrefWidth(500); listView.setPrefHeight(250); this.root.add(new HBox(spacer3, listView), 0, 4); uploadFiles.setPadding(new Insets(5, 5, 5, 5)); uploadFiles.setPrefWidth(120); uploadFiles.setPrefHeight(30); uploadFiles.setOnAction((event) -> { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Select schematic(s)"); fileChooser.getExtensionFilters().addAll( new FileChooser.ExtensionFilter("MCEdit Schematic File", "*.schematic"), new FileChooser.ExtensionFilter("Biome World Object Version 2", "*.bo2")); List<File> selectedFiles = fileChooser.showOpenMultipleDialog(this.primaryStage); if (selectedFiles != null) { if (selectedFiles.size() == 1) { filesSelected.setText("There is currently 1 file selected"); } else { filesSelected.setText( "There are currently " + String.valueOf(selectedFiles.size()) + " files selected"); } ObservableList<SchematicLocation> selectedSchematicFiles = FXCollections.observableArrayList(); selectedSchematicFiles.addAll(selectedFiles.stream().map(f -> new SchematicLocation(f, f.getName())) .collect(Collectors.toList())); listView.setItems(selectedSchematicFiles); this.schematics = selectedSchematicFiles; } }); this.root.add(new HBox(spacer1, uploadFiles, spacer2, new Label("Only .schematic files are allowed at this point!")), 0, 2); editing.setPadding(new Insets(5, 5, 5, 5)); editing.setPrefWidth(240); editing.setPrefHeight(30); editing.setDisable(true); editing.setOnAction(event -> this.primaryStage.setScene(Editing.getScene())); this.root.add(new HBox(spacer8, editing), 0, 8); loadSchematics.setPadding(new Insets(5, 5, 5, 5)); loadSchematics.setPrefWidth(120); loadSchematics.setPrefHeight(30); loadSchematics.setOnAction(event -> { if (this.schematics != null) { ((Runnable) () -> { for (SchematicLocation location : this.schematics) { if (FilenameUtils.isExtension(location.getLocation().getName(), "schematic")) { try { Schematics.schematics.add(McEditSchematicObject.load(location.getLocation())); } catch (ParseException | ClassicNotSupportedException | IOException e) { e.printStackTrace(); } } else if (FilenameUtils.isExtension(location.getLocation().getName(), "bo2")) { try { Schematics.schematics.add(BiomeWorldV2Object.load(location.getLocation())); } catch (IOException e) { e.printStackTrace(); } } } }).run(); loadSchematics.setDisable(true); uploadFiles.setDisable(true); listView.setDisable(true); editing.setDisable(false); } }); this.root.add(spacer6, 0, 5); this.root.add(new HBox(spacer5, loadSchematics), 0, 6); this.root.add(spacer7, 0, 7); this.primaryScene.getStylesheets() .add("https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800"); this.primaryScene.getStylesheets().add(new File("style.css").toURI().toURL().toExternalForm()); this.primaryStage.setScene(this.primaryScene); this.primaryStage.setResizable(false); this.primaryStage.setTitle("Schematic Utilities - by frogocomics"); this.primaryStage.show(); }
From source file:com.jscriptive.moneyfx.ui.chart.ChartFrame.java
/** * This method is invoked when the monthly in/out button has been toggled * * @param actionEvent/*from ww w . ja va 2 s. c om*/ */ public void monthlyInOutToggled(ActionEvent actionEvent) { final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel("Month of Year"); yAxis.setLabel("In/Out in Euro"); final BarChart<String, Number> barChart = new BarChart<>(xAxis, yAxis); barChart.setTitle("Monthly in/out"); chartFrame.setCenter(barChart); ToggleButton toggle = (ToggleButton) actionEvent.getTarget(); if (toggle.isSelected()) { Account account = accountCombo.getValue(); String accountLabel = getAccountLabel(account); XYChart.Series<String, Number> inSeries = new XYChart.Series<>(); inSeries.setName("In" + accountLabel); barChart.getData().add(inSeries); XYChart.Series<String, Number> outSeries = new XYChart.Series<>(); outSeries.setName("Out" + accountLabel); barChart.getData().add(outSeries); ValueRange<LocalDate> period = getTransactionOpRange(account, yearCombo.getValue()); if (period.isEmpty()) { return; } ObservableList<String> monthLabels = FXCollections.observableArrayList(); for (LocalDate date = period.from().withDayOfMonth(1); !date.isAfter(period.to()); date = date .plusMonths(1)) { monthLabels.add(getMonthLabel(date.getYear(), date.getMonthValue())); } xAxis.setCategories(monthLabels); Service<Void> service = new Service<Void>() { @Override protected Task<Void> createTask() { return new Task<Void>() { @Override protected Void call() throws Exception { List<TransactionVolume> incomingVolumes = (account == ALL_ACCOUNTS) ? transactionRepository.getMonthlyIncomingVolumes(false) : transactionRepository.getMonthlyIncomingVolumesOfAccount(account, false); if (INTEGER_ZERO.compareTo(yearCombo.getValue()) < 0) { incomingVolumes = incomingVolumes.stream() .filter(v -> v.getYear().equals(yearCombo.getValue())) .sorted((v1, v2) -> v1.getDate().compareTo(v2.getDate())).collect(toList()); } for (TransactionVolume volume : incomingVolumes) { String monthLabel = getMonthLabel(volume.getYear(), volume.getMonth()); XYChart.Data<String, Number> data = new XYChart.Data<>(monthLabel, volume.getVolume()); Platform.runLater(() -> { inSeries.getData().add(data); StackPane barNode = (StackPane) data.getNode(); // TODO make that look nicer Label labelNode = new Label( CurrencyFormat.getInstance().format(volume.getVolume())); labelNode.setPrefWidth(100); labelNode.setAlignment(CENTER_RIGHT); labelNode.setRotate(270); barNode.getChildren().add(labelNode); barNode.addEventHandler(MOUSE_CLICKED, event -> handleMonthlyInOutChartMouseClickEvent( (account == ALL_ACCOUNTS) ? null : account, of(volume.getYear(), volume.getMonth(), 1), event)); }); } List<TransactionVolume> outgoingVolumes = (account == ALL_ACCOUNTS) ? transactionRepository.getMonthlyOutgoingVolumes(false) : transactionRepository.getMonthlyOutgoingVolumesOfAccount(account, false); if (INTEGER_ZERO.compareTo(yearCombo.getValue()) < 0) { outgoingVolumes = outgoingVolumes.stream() .filter(v -> v.getYear().equals(yearCombo.getValue())) .sorted((v1, v2) -> v1.getDate().compareTo(v2.getDate())).collect(toList()); } for (TransactionVolume volume : outgoingVolumes) { String monthLabel = getMonthLabel(volume.getYear(), volume.getMonth()); XYChart.Data<String, Number> data = new XYChart.Data<>(monthLabel, volume.getVolume().abs()); Platform.runLater(() -> { outSeries.getData().add(data); StackPane node = (StackPane) data.getNode(); // TODO make that look nicer Label labelNode = new Label( CurrencyFormat.getInstance().format(volume.getVolume())); labelNode.setPrefWidth(100); labelNode.setAlignment(CENTER_RIGHT); labelNode.setRotate(270); node.getChildren().add(labelNode); node.addEventHandler(MOUSE_CLICKED, event -> handleMonthlyInOutChartMouseClickEvent( (account == ALL_ACCOUNTS ? null : account), volume.getDate(), event)); }); } return null; } }; } }; service.start(); } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param iLargeur//from w w w . jav a 2 s . c om * @param iHauteur * @param bMasqueZones * @param strIdZone * @param mouseEvent */ private static void choixZone(int iLargeur, int iHauteur, boolean bMasqueZones, String strIdZone, MouseEvent mouseEvent) { ComboBox cbTouchesBarre = new ComboBox(); cbTouchesBarre.getItems().clear(); for (int i = 0; i < strTouchesBarre.length; i++) { cbTouchesBarre.getItems().add(i, strTouchesBarre[i]); } cbTouchesBarre.setLayoutX(200); cbTouchesBarre.setLayoutX(40); final int iNumeroZone = Integer.parseInt(strIdZone.split("-")[1]); if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getClickCount() == 2) { for (int ij = iNumeroZone; ij < iNombreZones - 1; ij++) { zones[ij] = zones[ij + 1]; } iNombreZones--; afficheBarrePersonnalisee(iLargeur, iHauteur, bMasqueZones); } else { afficheBarrePersonnalisee(iLargeur, iHauteur, bMasqueZones); apZoneBarrePersonnalisee.getChildren().clear(); apZoneBarrePersonnalisee.getChildren().add(cbTouchesBarre); ZoneTelecommande zone = zones[iNumeroZone]; int index = -1; for (int ij = 0; ij < strCodeBarre.length; ij++) { if (strCodeBarre[ij].equals(zone.getStrIdZone())) { index = ij; } } if (index != -1) { cbTouchesBarre.getSelectionModel().select(index); } cbTouchesBarre.valueProperty().addListener((ov, ancienneValeur, nouvelleValeur) -> { if (nouvelleValeur != null) { String strId = strCodeBarre[cbTouchesBarre.getSelectionModel().getSelectedIndex()]; zones[iNumeroZone].setStrIdZone(strId); } }); Label lblTypeBarre = new Label(zone.getStrTypeZone()); lblTypeBarre.setLayoutX(20); lblTypeBarre.setLayoutY(40); Label lblCoordsBarre = new Label(zone.getStrCoordonneesZone()); lblCoordsBarre.setLayoutX(20); lblCoordsBarre.setLayoutY(70); lblCoordsBarre.setPrefWidth(260); lblCoordsBarre.setMaxWidth(260); lblCoordsBarre.setWrapText(true); apZoneBarrePersonnalisee.getChildren().addAll(lblTypeBarre, lblCoordsBarre); switch (zone.getStrTypeZone()) { case "poly": Polygon poly = (Polygon) apImgBarrePersonnalisee.lookup("#" + strIdZone); poly.setFill(Color.rgb(255, 0, 0, 0.5)); poly.setStroke(Color.YELLOW); apImgBarrePersonnalisee.getChildren() .addAll(olCreeAncresPourPolygone(iNumeroZone, poly.getPoints())); break; case "rect": Rectangle rect = (Rectangle) apImgBarrePersonnalisee.lookup("#" + strIdZone); rect.setFill(Color.rgb(255, 0, 0, 0.5)); rect.setStroke(Color.YELLOW); apImgBarrePersonnalisee.getChildren().addAll(olCreeAncresPourRectangle(iNumeroZone, rect)); break; case "circle": Circle cercle = (Circle) apImgBarrePersonnalisee.lookup("#" + strIdZone); cercle.setFill(Color.rgb(255, 0, 0, 0.5)); cercle.setStroke(Color.YELLOW); apImgBarrePersonnalisee.getChildren().addAll(olCreeAncresPourCercle(iNumeroZone, cercle)); break; } } } }
From source file:org.pdfsam.ui.news.News.java
News(NewsData data) { this.getStyleClass().add("news-box"); TextFlow flow = new TextFlow(); if (data.isImportant()) { Text megaphone = GlyphsDude.createIcon(FontAwesomeIcon.BULLHORN, "1.2em"); megaphone.getStyleClass().clear(); megaphone.getStyleClass().add("news-box-title-important"); flow.getChildren().addAll(megaphone, new Text(" ")); }/*from www. j a va 2 s. co m*/ Text titleText = new Text(data.getTitle() + System.lineSeparator()); titleText.setOnMouseClicked(e -> eventStudio().broadcast(new OpenUrlRequest(data.getLink()))); titleText.getStyleClass().add("news-box-title"); Text contentText = new Text(data.getContent()); contentText.setTextAlignment(TextAlignment.JUSTIFY); contentText.getStyleClass().add("news-content"); flow.getChildren().addAll(titleText, contentText); flow.setTextAlignment(TextAlignment.JUSTIFY); Label labelDate = new Label(FORMATTER.format(data.getDate()), GlyphsDude.createIcon(MaterialDesignIcon.CLOCK)); labelDate.setPrefWidth(Integer.MAX_VALUE); HBox.setHgrow(labelDate, Priority.ALWAYS); HBox bottom = new HBox(labelDate); bottom.setAlignment(Pos.CENTER_LEFT); bottom.getStyleClass().add("news-box-footer"); if (isNotBlank(data.getLink())) { Button link = UrlButton.urlButton(null, data.getLink(), FontAwesomeIcon.EXTERNAL_LINK_SQUARE, "pdfsam-toolbar-button"); bottom.getChildren().add(link); } getChildren().addAll(flow, bottom); }
From source file:org.sleuthkit.autopsy.timeline.ui.AbstractTimelineChart.java
/** * Add a Label Node to the contextual label container for the decluttered * axis labels.//from w ww .j a va 2s .co m * * @param labelText The String to add. * @param labelWidth The width, in pixels, of the space to use for the label * @param labelX The horizontal position, in pixels, in the specificPane * of the text */ private synchronized void addContextLabel(String labelText, double labelWidth, double labelX) { Label label = new Label(labelText); label.setAlignment(Pos.CENTER); label.setTextAlignment(TextAlignment.CENTER); label.setFont(Font.font(10)); //use a leading ellipse since that is the lowest frequency part, //and can be infered more easily from other surrounding labels label.setTextOverrun(OverrunStyle.LEADING_ELLIPSIS); //force size label.setMinWidth(labelWidth); label.setPrefWidth(labelWidth); label.setMaxWidth(labelWidth); label.relocate(labelX, 0); if (labelX == 0) { // first label has no border label.setBorder(null); } else { // subsequent labels have border on left to create dividers label.setBorder(ONLY_LEFT_BORDER); } contextLabelPane.getChildren().add(label); }
From source file:org.sleuthkit.autopsy.timeline.ui.AbstractVisualization.java
/** add a {@link Label} node to the branch container for the decluttered * axis labels/* w w w.j a v a 2 s . co m*/ * * @param labelText the string to add * @param labelWidth the width of the space to use for the label * @param labelX the horizontal position in the partPane of the text */ private synchronized void assignBranchLabel(String labelText, double labelWidth, double labelX) { Label label = new Label(labelText); label.setAlignment(Pos.CENTER); label.setTextAlignment(TextAlignment.CENTER); label.setFont(Font.font(10)); //use a leading ellipse since that is the lowest frequency part, //and can be infered more easily from other surrounding labels label.setTextOverrun(OverrunStyle.LEADING_ELLIPSIS); //force size label.setMinWidth(labelWidth); label.setPrefWidth(labelWidth); label.setMaxWidth(labelWidth); label.relocate(labelX, 0); if (labelX == 0) { // first label has no border label.setStyle("-fx-border-width: 0 0 0 0 ; -fx-border-color:black;"); // NON-NLS } else { // subsequent labels have border on left to create dividers label.setStyle("-fx-border-width: 0 0 0 1; -fx-border-color:black;"); // NON-NLS } branchPane.getChildren().add(label); }
From source file:org.sleuthkit.autopsy.timeline.ui.AbstractVisualizationPane.java
/** * add a {@link Label} node to the branch container for the decluttered axis * labels/*w w w . j a v a 2 s . c o m*/ * * @param labelText the string to add * @param labelWidth the width of the space to use for the label * @param labelX the horizontal position in the partPane of the text */ private synchronized void assignBranchLabel(String labelText, double labelWidth, double labelX) { Label label = new Label(labelText); label.setAlignment(Pos.CENTER); label.setTextAlignment(TextAlignment.CENTER); label.setFont(Font.font(10)); //use a leading ellipse since that is the lowest frequency part, //and can be infered more easily from other surrounding labels label.setTextOverrun(OverrunStyle.LEADING_ELLIPSIS); //force size label.setMinWidth(labelWidth); label.setPrefWidth(labelWidth); label.setMaxWidth(labelWidth); label.relocate(labelX, 0); if (labelX == 0) { // first label has no border label.setStyle("-fx-border-width: 0 0 0 0 ; -fx-border-color:black;"); // NON-NLS //NOI18N } else { // subsequent labels have border on left to create dividers label.setStyle("-fx-border-width: 0 0 0 1; -fx-border-color:black;"); // NON-NLS //NOI18N } branchPane.getChildren().add(label); }