javafx.scene.control.Label Java Examples

The following examples show how to use javafx.scene.control.Label. 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: TableVisualisation.java    From constellation with Apache License 2.0 6 votes vote down vote up
public TableVisualisation(final AbstractTableTranslator<? extends AnalyticResult<?>, C> translator) {
    this.translator = translator;

    this.tableVisualisation = new VBox();

    this.tableFilter = new TextField();
    tableFilter.setPromptText("Type here to filter results");

    this.table = new TableView<>();
    table.setPlaceholder(new Label("No results"));
    table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    table.setId("table-visualisation");
    table.setPadding(new Insets(5));

    tableVisualisation.getChildren().addAll(tableFilter, table);
}
 
Example #2
Source File: DatasetTable.java    From xframium-java with GNU General Public License v3.0 6 votes vote down vote up
public DatasetTable ()
{
  addColumnString ("Dataset name", 300, Justification.LEFT, "datasetName");
  addColumnString ("Volume", 70, Justification.LEFT, "volume");
  addColumnNumber ("Tracks", 50, "tracks");
  addColumnNumber ("% used", 50, "percentUsed");
  addColumnNumber ("XT", 50, "extents");
  addColumnString ("Device", 50, Justification.CENTER, "device");
  addColumnString ("Dsorg", 50, Justification.LEFT, "dsorg");
  addColumnString ("Recfm", 50, Justification.LEFT, "recfm");
  addColumnNumber ("Lrecl", 50, "lrecl");
  addColumnNumber ("Blksize", 70, "blksize");
  addColumnString ("Created", 100, Justification.CENTER, "created");
  addColumnString ("Expires", 100, Justification.CENTER, "expires");
  addColumnString ("Referred", 100, Justification.CENTER, "referred");
  addColumnString ("Catalog", 150, Justification.LEFT, "catalog");

  setPlaceholder (new Label ("No datasets have been seen in this session"));

  setItems (datasets);
}
 
Example #3
Source File: Deck.java    From logbook-kai with MIT License 6 votes vote down vote up
@Override
protected void updateItem(DeckFleetPane item, boolean empty) {
    super.updateItem(item, empty);
    if (!empty) {
        if (item != null) {
            Label text = new Label();
            text.textProperty().bind(item.getFleetName().textProperty());
            Pane pane = new Pane();
            Button del = new Button("除去");
            del.getStyleClass().add("delete");
            del.setOnAction(e -> {
                Deck.this.fleetList.getItems().remove(item);
                Deck.this.fleets.getChildren().removeIf(node -> node == item);
            });
            HBox box = new HBox(text, pane, del);
            HBox.setHgrow(pane, Priority.ALWAYS);

            this.setGraphic(box);
        } else {
            this.setGraphic(null);
        }
    } else {
        this.setGraphic(null);
    }
}
 
Example #4
Source File: FontSpecsComponent.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public FontSpecsComponent() {

    fontLabel = new Label();

    fontSelectButton = new Button("Select font");
    fontSelectButton.setOnAction(e -> {
      var dialog = new FontSelectorDialog(currentFont);
      var result = dialog.showAndWait();
      if (result.isPresent())
        setFont(result.get());
    });

    colorPicker = new ColorPicker(Color.BLACK);

    getChildren().addAll(fontLabel, fontSelectButton, colorPicker);
  }
 
Example #5
Source File: AddPropertiesView.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public AddPropertiesView(TestPropertiesInfo issueInfo) {
    this.issueInfo = issueInfo;
    initComponents();
 // @formatter:off
    Label severityLabel = new Label("Severity: ");
    severityLabel.setMinWidth(Region.USE_PREF_SIZE);
    tmsLink.setOnAction((e) -> {
        try {
            Desktop.getDesktop().browse(new URI(tmsLink.getText()));
        } catch (Exception e1) {
            FXUIUtils._showMessageDialog(null, "Unable to open link: " + tmsLink.getText(), "Unable to open link",
                    AlertType.ERROR);
            e1.printStackTrace();
        }
    });
    formPane.addFormField("Name: ", nameField)
            .addFormField("Description: ", descriptionField)
            .addFormField("ID: ", idField, severityLabel, severities);
    String tmsPattern = System.getProperty(Constants.PROP_TMS_PATTERN);
    if (tmsPattern != null && tmsPattern.length() > 0) {
        tmsLink.textProperty().bind(Bindings.format(tmsPattern, idField.textProperty()));
        formPane.addFormField("", tmsLink);
    }
    // @formatter:on
    setCenter(content);
}
 
Example #6
Source File: GlobalUI.java    From SONDY with GNU General Public License v3.0 6 votes vote down vote up
public void about(){
    final Stage stage = new Stage();
    stage.setResizable(false);
    stage.initModality(Modality.WINDOW_MODAL);
    stage.initStyle(StageStyle.UTILITY);
    stage.setTitle("About SONDY");
    WebView webView = new WebView();
    webView.getEngine().loadContent(getReferences());
    webView.setMaxWidth(Main.columnWidthLEFT);
    webView.setMinWidth(Main.columnWidthLEFT);
    webView.setMaxHeight(Main.columnWidthLEFT);
    webView.setMinHeight(Main.columnWidthLEFT);
    Scene scene = new Scene(VBoxBuilder.create().children(new Label("SONDY "+Main.version),new Label("Main developper: Adrien Guille <[email protected]>"),webView).alignment(Pos.CENTER).padding(new Insets(10)).spacing(3).build());
    scene.getStylesheets().add("resources/fr/ericlab/sondy/css/GlobalStyle.css");
    stage.setScene(scene);
    stage.show();
}
 
Example #7
Source File: RegisterController.java    From Sword_emulator with GNU General Public License v3.0 6 votes vote down vote up
private void initView() {
    ObservableList<String> options = FXCollections.observableArrayList();
    for (DisplayMode mode : DisplayMode.values()) {
        options.add(mode.name);
    }
    registerModeBox.setItems(options);
    registerModeBox.setOnAction(event ->
            setDisplayMode(DisplayMode.values()[registerModeBox.getSelectionModel().getSelectedIndex()]));
    registerModeBox.getSelectionModel().select(0);
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 4; j++) {
            int index = j * 8 + i;
            RegisterType registerType = getType(index);
            registerLable[index] = new Label("");
            registerLable[index].setFont(Font.font("Consolas", 16));
            registerLable[index].setTextFill(registerType.getColor());
            registerPane.add(registerLable[index], j, i);
        }
    }
    updateAllRegisters();
}
 
Example #8
Source File: Example1.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void buildAndShowMainWindow(Stage primaryStage) {
    primaryStage.setTitle("Hello World!!");
    GridPane gridPane = new GridPane();
    gridPane.setAlignment(Pos.CENTER);
    gridPane.setHgap(10);
    gridPane.setVgap(10);
    gridPane.setPadding(new Insets(25, 25, 25, 25));

    button = new Button("Click me!");
    gridPane.add(button,1,1);

    text = new TextField();
    gridPane.add(text, 2, 1);

    clockLabel = new Label();
    gridPane.add(clockLabel, 1,2, 2, 1);

    Scene scene = new Scene(gridPane);
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example #9
Source File: PmMap.java    From SmartCity-ParkingManagement with Apache License 2.0 6 votes vote down vote up
protected Marker createMarker(final LatLong lat, final String title) {
	final MarkerOptions options = new MarkerOptions();
	options.position(lat).title(title).visible(true);
	final Marker $ = new MyMarker(options, title, lat);
	markers.add($);
	fromLocation.getItems().add(title);
	toLocation.getItems().add(title);
	final HBox hbox = new HBox();
	hbox.setPadding(new Insets(8, 5, 8, 5));
	hbox.setSpacing(8);
	final Label l = new Label(title);
	final Button btn = new Button("remove");
	btn.setOnAction(λ -> {
		map.removeMarker($);
		markerVbox.getChildren().remove(hbox);
		fromLocation.getItems().remove(title);
		toLocation.getItems().remove(title);
	});
	btns.add(btn);
	hbox.getChildren().addAll(l, btn);
	VBox.setMargin(hbox, new Insets(0, 0, 0, 8));
	markerVbox.getChildren().add(hbox);
	return $;

}
 
Example #10
Source File: HttpHeadersTextField.java    From dev-tools with Apache License 2.0 6 votes vote down vote up
private void populatePopup(List<String> searchResult) {
    List<CustomMenuItem> menuItems = new LinkedList<>();
    int count = Math.min(searchResult.size(), maxEntries);
    for (int i = 0; i < count; i++) {
        final String result = searchResult.get(i);
        Label entryLabel = new Label(result);
        CustomMenuItem item = new CustomMenuItem(entryLabel, true);
        item.setOnAction(actionEvent -> {
            setText(result);
            entriesPopup.hide();
        });
        menuItems.add(item);
    }
    entriesPopup.getItems().clear();
    entriesPopup.getItems().addAll(menuItems);
}
 
Example #11
Source File: DataSetMeasurements.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
protected void addGraphBelowItems() {
    final String toolTip = "whether to draw the new DataSet below (checked) or above (un-checked) the existing DataSets";
    final Label label = new Label("draw below: ");
    label.setTooltip(new Tooltip(toolTip));
    GridPane.setConstraints(label, 0, lastLayoutRow);
    graphBelowOtherDataSets.setSelected(false);
    graphBelowOtherDataSets.setTooltip(new Tooltip(toolTip));
    GridPane.setConstraints(graphBelowOtherDataSets, 1, lastLayoutRow++);

    graphBelowOtherDataSets.selectedProperty().addListener((obs, o, n) -> {
        final Chart chart = localChart.get();
        if (chart == null) {
            return;
        }
        chart.getRenderers().remove(renderer);
        if (Boolean.TRUE.equals(n)) {
            chart.getRenderers().add(0, renderer);
        } else {
            chart.getRenderers().add(renderer);
        }
    });

    this.getDialogContentBox().getChildren().addAll(label, graphBelowOtherDataSets);
}
 
Example #12
Source File: SocketGroupListCell.java    From Path-of-Leveling with MIT License 6 votes vote down vote up
@Override
protected void updateItem(SocketGroup sg, boolean empty) {
    super.updateItem(sg, empty) ;
    if (empty) {
        setText(null);
    } else {
        Label l = new Label();
        if(sg.getActiveGem()!=null){
            if(!sg.getActiveGem().getGemName().equals("<empty group>")){
                l.setGraphic(new ImageView(sg.getActiveGem().getSmallIcon()));
                l.setText(sg.getActiveGem().getGemName());
            }
        }
        else{
            setText(null);
        }
        setGraphic(l);

    }
}
 
Example #13
Source File: SetUnitTestController.java    From Vert.X-generator with MIT License 6 votes vote down vote up
@Override
public void initialize(URL location, ResourceBundle resources) {
	tblProperty.setEditable(true);
	tblProperty.setStyle("-fx-font-size:14px");
	StringProperty property = Main.LANGUAGE.get(LanguageKey.SET_TBL_TIPS);
	String title = property == null ? "可以在右边自定义添加属性..." : property.get();
	tblProperty.setPlaceholder(new Label(title));
	tblPropertyValues = FXCollections.observableArrayList();
	// 设置列的大小自适应
	tblProperty.setColumnResizePolicy(resize -> {
		double width = resize.getTable().getWidth();
		tdKey.setPrefWidth(width / 3);
		tdValue.setPrefWidth(width / 3);
		tdDescribe.setPrefWidth(width / 3);
		return true;
	});
	btnConfirm.widthProperty().addListener(w -> {
		double x = btnConfirm.getLayoutX() + btnConfirm.getWidth() + 10;
		btnCancel.setLayoutX(x);
	});
}
 
Example #14
Source File: ASTTreeCell.java    From pmd-designer with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private ContextMenu buildContextMenu(Node item) {
    ContextMenu contextMenu = new ContextMenuWithNoArrows();
    CustomMenuItem menuItem = new CustomMenuItem(new Label("Export subtree...",
                                                           new FontIcon("fas-external-link-alt")));

    Tooltip tooltip = new Tooltip("Export subtree to a text format");
    Tooltip.install(menuItem.getContent(), tooltip);

    menuItem.setOnAction(
        e -> getService(DesignerRoot.TREE_EXPORT_WIZARD).apply(x -> x.showYourself(x.bindToNode(item)))
    );

    contextMenu.getItems().add(menuItem);

    return contextMenu;
}
 
Example #15
Source File: UpdateWindow.java    From Recaf with MIT License 6 votes vote down vote up
/**
 * @param window
 * 		Window reference to handle UI access.
 *
 * @return Update popup.
 */
public static UpdateWindow create(MainWindow window) {
	Label lblTitle = new Label(translate("update.outdated"));
	Label lblVersion = new Label(Recaf.VERSION + " → " + SelfUpdater.getLatestVersion());
	Label lblDate = new Label(SelfUpdater.getLatestVersionDate().toString());
	lblTitle.getStyleClass().add("h1");
	lblDate.getStyleClass().add("faint");
	GridPane grid = new GridPane();
	GridPane.setHalignment(lblVersion, HPos.CENTER);
	GridPane.setHalignment(lblDate, HPos.CENTER);
	grid.setPadding(new Insets(15));
	grid.setHgap(10);
	grid.setVgap(10);
	grid.setAlignment(Pos.CENTER);
	grid.add(new Label(translate("update.available")), 0, 0);
	grid.add(new ActionButton(translate("misc.open"), () -> window.getMenubar().showUpdatePrompt()), 1, 0);
	grid.add(lblVersion, 0, 1, 2, 1);
	grid.add(lblDate, 0, 2, 2, 1);
	return new UpdateWindow(grid, lblTitle);
}
 
Example #16
Source File: TextUpdateRepresentation.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Control createJFXNode() throws Exception
{   // Start out 'disconnected' until first value arrives
    value_text = computeText(null);

    if (model_widget.propInteractive().getValue()  &&  !toolkit.isEditMode())
    {
        final TextArea area = new TextArea();
        area.setMinSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
        area.setEditable(false);
        area.getStyleClass().add("text_entry");
        area.setWrapText(true);
        // 'Interactive' widget needs to react to selection,
        // and as remarked in TextEntry this works best 'managed'
        area.setManaged(true);
        return area;
    }
    else
    {
        final Label label = new Label();
        label.getStyleClass().add("text_update");

        // This code manages layout,
        // because otherwise for example border changes would trigger
        // expensive Node.notifyParentOfBoundsChange() recursing up the scene graph
        label.setManaged(false);

        return label;
    }
}
 
Example #17
Source File: ConfigurationBase.java    From AsciidocFX with Apache License 2.0 5 votes vote down vote up
protected void fadeOut(Label label, String text) {
    threadService.runActionLater(() -> {
        label.setText(text);
        FadeTransition fadeTransition = new FadeTransition(Duration.millis(2000), label);
        fadeTransition.setFromValue(1);
        fadeTransition.setToValue(0);
        fadeTransition.playFromStart();
    });
}
 
Example #18
Source File: ExceptionDialog.java    From milkman with MIT License 5 votes vote down vote up
public ExceptionDialog(Throwable ex) {
	super(AlertType.ERROR);
	setTitle("Exception");
	setHeaderText("Exception during startup of application");
	setContentText(ex.getClass().getName() + ": " + ex.getMessage());


	// Create expandable Exception.
	StringWriter sw = new StringWriter();
	PrintWriter pw = new PrintWriter(sw);
	ex.printStackTrace(pw);
	String exceptionText = sw.toString();

	Label label = new Label("The exception stacktrace was:");

	TextArea textArea = new TextArea(exceptionText);
	textArea.setEditable(false);
	textArea.setWrapText(true);

	textArea.setMaxWidth(Double.MAX_VALUE);
	textArea.setMaxHeight(Double.MAX_VALUE);
	GridPane.setVgrow(textArea, Priority.ALWAYS);
	GridPane.setHgrow(textArea, Priority.ALWAYS);

	GridPane expContent = new GridPane();
	expContent.setMaxWidth(Double.MAX_VALUE);
	expContent.add(label, 0, 0);
	expContent.add(textArea, 0, 1);

	// Set expandable Exception into the dialog pane.
	getDialogPane().setExpandableContent(expContent);
}
 
Example #19
Source File: BaseController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public void popText(String text, int delay, String color, String size,
        Region attach) {
    try {
        if (popup != null) {
            popup.hide();
        }
        popup = getPopup();
        Label popupLabel = new Label(text);
        popupLabel.setStyle("-fx-background-color:black;"
                + " -fx-text-fill: " + color + ";"
                + " -fx-font-size: " + size + ";"
                + " -fx-padding: 10px;"
                + " -fx-background-radius: 6;");
        popup.setAutoFix(true);
        popup.getContent().add(popupLabel);

        if (delay > 0) {
            if (popupTimer != null) {
                popupTimer.cancel();
            }
            popupTimer = getPopupTimer();
            popupTimer.schedule(new TimerTask() {
                @Override
                public void run() {
                    Platform.runLater(() -> {
                        hidePopup();
                    });
                }
            }, delay);
        }

        if (attach != null) {
            FxmlControl.locateUp(attach, popup);
        } else {
            popup.show(getMyStage());
        }
    } catch (Exception e) {

    }
}
 
Example #20
Source File: QueryListPaneFrameTest.java    From oim-fx with MIT License 5 votes vote down vote up
private void initc() {
	deviceListFrame.setPage(0, 10);
	deviceListFrame.setPageFactory(new Callback<Integer, Node>() {

		@Override
		public Node call(Integer index) {
			System.out.println(index);
			getList(index + 1);
			return new Label("第" + (index + 1) + "页");
		}
	});
}
 
Example #21
Source File: ResourceView.java    From sis with Apache License 2.0 5 votes vote down vote up
private void setOnClick(Label lab) {
    addContextMenu(lab);
    lab.setOnMouseClicked(click -> {
        if (click.getButton() == MouseButton.PRIMARY) {
            if (sauvLabel != null) {
                sauvLabel.setTextFill(Color.BLACK);
            }
            addMetadatPanel(null, lab.getId());
            sauvLabel = lab;
            lab.setTextFill(Color.RED);
        }
    });
}
 
Example #22
Source File: ElementPropertyControl.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected void createComponents(@NotNull HBox container) {
    super.createComponents(container);

    elementLabel = new Label(NO_ELEMENT);
    elementLabel.prefWidthProperty()
        .bind(container.widthProperty());

    var changeButton = new Button();
    changeButton.setGraphic(new ImageView(Icons.ADD_16));
    changeButton.setOnAction(event -> addElement());

    var editButton = new Button();
    editButton.setGraphic(new ImageView(Icons.REMOVE_12));
    editButton.setOnAction(event -> removeElement());
    editButton.disableProperty()
        .bind(elementLabel.textProperty().isEqualTo(NO_ELEMENT));

    FxUtils.addClass(container,
                CssClasses.TEXT_INPUT_CONTAINER,
                CssClasses.ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER)
        .addClass(elementLabel,
                CssClasses.ABSTRACT_PARAM_CONTROL_ELEMENT_LABEL)
        .addClass(changeButton, editButton,
                CssClasses.FLAT_BUTTON,
                CssClasses.INPUT_CONTROL_TOOLBAR_BUTTON);

    FxUtils.addChild(container, elementLabel, changeButton, editButton);

    DynamicIconSupport.addSupport(changeButton, editButton);
}
 
Example #23
Source File: CheckListFormNode.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private void buildVBox() {
    ObservableList<Node> children = getChildren();
    if (mode.isSelectable()) {
        children.addAll(createNameField(), createDescriptionField());
    } else {
        if (checkList.getName().equals("")) {
            children.add(addSeparator("<No Name>"));
        } else {
            children.add(addSeparator(checkList.getName()));
        }
        GridPane gridPane = new GridPane();
        String text = checkList.getDescription();
        if (text.equals("")) {
            text = "<No Description>";
        }
        StringTokenizer tok = new StringTokenizer(text, "\n");
        int rowIndex = 0;
        while (tok.hasMoreTokens()) {
            Label label = new Label(tok.nextToken());
            gridPane.add(label, 0, rowIndex++);
        }
        children.add(gridPane);
    }
    Iterator<CheckList.CheckListItem> items = checkList.getItems();
    List<CheckListItemVBoxer> vboxers = new ArrayList<CheckListItemVBoxer>();
    while (items.hasNext()) {
        vboxers.add(getVBoxer(items.next()));
    }
    vboxers.forEach(vboxer -> {
        VBox vbox = vboxer.getVbox(mode.isSelectable(), mode.isEditable());
        HBox.setHgrow(vbox, Priority.ALWAYS);
        children.add(vbox);
        if (mode.isSelectable()) {
            VBox.setMargin(vbox, new Insets(5, 10, 0, 5));
        }
    });
}
 
Example #24
Source File: PainteraAlerts.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public static Alert versionDialog() {
	final TextField versionField = new TextField(Version.VERSION_STRING);
	versionField.setEditable(false);
	versionField.setTooltip(new Tooltip(versionField.getText()));
	final HBox versionBox = new HBox(new Label("Paintera Version"), versionField);
	HBox.setHgrow(versionField, Priority.ALWAYS);
	versionBox.setAlignment(Pos.CENTER);
	final Alert alert = PainteraAlerts.alert(Alert.AlertType.INFORMATION, true);
	alert.getDialogPane().setContent(versionBox);
	alert.setHeaderText("Paintera Version");
	alert.initModality(Modality.NONE);
	return alert;
}
 
Example #25
Source File: AwesomeService.java    From AsciidocFX with Apache License 2.0 5 votes vote down vote up
public Node getIcon(final Path path) {

        FontIcon fontIcon = new FontIcon(FontAwesome.FILE_O);

        if (Files.isDirectory(path)) {
            fontIcon.setIconCode(FontAwesome.FOLDER_O);
        } else {
            if (pathResolver.isAsciidoc(path) || pathResolver.isMarkdown(path))
                fontIcon.setIconCode(FontAwesome.FILE_TEXT_O);
            if (pathResolver.isXML(path) || pathResolver.isCode(path))
                fontIcon.setIconCode(FontAwesome.FILE_CODE_O);
            if (pathResolver.isImage(path))
                fontIcon.setIconCode(FontAwesome.FILE_PICTURE_O);
            if (pathResolver.isPDF(path))
                fontIcon.setIconCode(FontAwesome.FILE_PDF_O);
            if (pathResolver.isHTML(path))
                fontIcon.setIconCode(FontAwesome.HTML5);
            if (pathResolver.isArchive(path))
                fontIcon.setIconCode(FontAwesome.FILE_ZIP_O);
            if (pathResolver.isExcel(path))
                fontIcon.setIconCode(FontAwesome.FILE_EXCEL_O);
            if (pathResolver.isVideo(path))
                fontIcon.setIconCode(FontAwesome.FILE_VIDEO_O);
            if (pathResolver.isWord(path))
                fontIcon.setIconCode(FontAwesome.FILE_WORD_O);
            if (pathResolver.isPPT(path))
                fontIcon.setIconCode(FontAwesome.FILE_POWERPOINT_O);
            if (pathResolver.isBash(path))
                fontIcon.setIconCode(FontAwesome.TERMINAL);
        }

        return new Label(null, fontIcon);
    }
 
Example #26
Source File: BasicUI.java    From cssfx with Apache License 2.0 5 votes vote down vote up
private Parent buildUI() {
    container = new VBox();
    container.getStyleClass().add("container");

    Label lblWelcome = new Label("Welcome");
    Label lblCSSFX = new Label("CSSFX");
    lblCSSFX.setId("cssfx");

    container.getChildren().addAll(lblWelcome, lblCSSFX);

    String defaultURI = BasicUI.class.getResource("default.css").toExternalForm();
    String basicURI = BasicUI.class.getResource("basic.css").toExternalForm();
    container.getStylesheets().addAll(defaultURI, basicURI);
    return container;
}
 
Example #27
Source File: MaterialPropertyControl.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected void createComponents(@NotNull HBox container) {
    super.createComponents(container);

    materialLabel = new Label(NO_MATERIAL);

    var changeButton = new Button();
    changeButton.setGraphic(new ImageView(Icons.ADD_16));
    changeButton.setOnAction(this::change);

    var editButton = new Button();
    editButton.setGraphic(new ImageView(Icons.EDIT_16));
    editButton.disableProperty().bind(materialLabel.textProperty().isEqualTo(NO_MATERIAL));
    editButton.setOnAction(this::openToEdit);

    materialLabel.prefWidthProperty().bind(widthProperty()
            .subtract(changeButton.widthProperty())
            .subtract(editButton.widthProperty()));

    FxUtils.addClass(container,
                    CssClasses.TEXT_INPUT_CONTAINER,
                    CssClasses.ABSTRACT_PARAM_CONTROL_INPUT_CONTAINER)
            .addClass(materialLabel,
                    CssClasses.ABSTRACT_PARAM_CONTROL_ELEMENT_LABEL)
            .addClass(changeButton, editButton,
                    CssClasses.FLAT_BUTTON,
                    CssClasses.INPUT_CONTROL_TOOLBAR_BUTTON);

    FxUtils.addChild(container,
            materialLabel, changeButton, editButton);

    DynamicIconSupport.addSupport(changeButton, editButton);
}
 
Example #28
Source File: CalendarTileSkin.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    final ZonedDateTime TIME = tile.getTime();

    titleText = new Text(MONTH_YEAR_FORMATTER.format(TIME));
    titleText.setFill(tile.getTitleColor());

    clickHandler = e -> checkClick(e);

    labels = new ArrayList<>(56);
    for (int i = 0 ; i < 56 ; i++) {
        Label label = new Label();
        label.setManaged(false);
        label.setVisible(false);
        label.setAlignment(Pos.CENTER);
        label.addEventHandler(MouseEvent.MOUSE_PRESSED, clickHandler);
        labels.add(label);
    }

    weekBorder = new Border(new BorderStroke(Color.TRANSPARENT,
                                             Tile.GRAY,
                                             Color.TRANSPARENT,
                                             Color.TRANSPARENT,
                                             BorderStrokeStyle.NONE,
                                             BorderStrokeStyle.SOLID,
                                             BorderStrokeStyle.NONE,
                                             BorderStrokeStyle.NONE,
                                             CornerRadii.EMPTY, BorderWidths.DEFAULT,
                                             Insets.EMPTY));

    text = new Text(DAY_FORMATTER.format(TIME));
    text.setFill(tile.getTextColor());

    getPane().getChildren().addAll(titleText, text);
    getPane().getChildren().addAll(labels);
}
 
Example #29
Source File: Exercise_16_08.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
/** Return a table */
protected VBox getTable(
	TextField centerX, TextField centerY, TextField r, int n) {
	VBox vBox = new VBox(2);
	vBox.setStyle("-fx-border-color: Black");
	vBox.getChildren().addAll(new Label("Enter circle " + 
		n + " info:"), getGrid(centerX, centerY, r));
	return vBox;
}
 
Example #30
Source File: NumberSpinnerDemo.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("JavaFX Spinner Demo");
    GridPane root = new GridPane();
    root.setHgap(10);
    root.setVgap(10);
    root.setPadding(new Insets(10, 10, 10, 10));
    final NumberSpinner defaultSpinner = new NumberSpinner();
    final NumberSpinner decimalFormat = new NumberSpinner(BigDecimal.ZERO, new BigDecimal("0.05"), new DecimalFormat("#,##0.00"));
    final NumberSpinner percent = new NumberSpinner(BigDecimal.ZERO, new BigDecimal("0.01"), NumberFormat.getPercentInstance());
    final NumberSpinner localizedCurrency = new NumberSpinner(BigDecimal.ZERO, new BigDecimal("0.01"), NumberFormat.getCurrencyInstance(Locale.UK));
    root.addRow(1, new Label("default"), defaultSpinner);
    root.addRow(2, new Label("custom decimal format"), decimalFormat);
    root.addRow(3, new Label("percent"), percent);
    root.addRow(4, new Label("localized currency"), localizedCurrency);
    Button button = new Button("Dump layout bounds");
    button.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent arg0) {
            defaultSpinner.dumpSizes();
        }
    });
    root.addRow(5, new Label(), button);

    Scene scene = new Scene(root);
    //String path = NumberSpinnerDemo.class.getResource("/fxui/css/spinner/number_spinner.css").toExternalForm();
    String path = "/fxui/css/spinner/number_spinner.css";
    System.out.println("path = " + path);
    //scene.getStylesheets().add(path);
    scene.getStylesheets().add(getClass().getResource(path).toExternalForm());
    primaryStage.setScene(scene);
    primaryStage.show();
}