javafx.scene.control.Label#setMinWidth ( )源码实例Demo

下面列出了javafx.scene.control.Label#setMinWidth ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jace   文件: Watch.java
public Watch(int address, final MetacheatUI outer) {
    super();
    this.outer = outer;
    this.address = address;
    cell = outer.cheatEngine.getMemoryCell(address);
    redraw = outer.animationTimer.scheduleAtFixedRate(this::redraw, MetacheatUI.FRAME_RATE, MetacheatUI.FRAME_RATE, TimeUnit.MILLISECONDS);
    setBackground(new Background(new BackgroundFill(Color.NAVY, CornerRadii.EMPTY, Insets.EMPTY)));
    Label addrLabel = new Label("$" + Integer.toHexString(address));
    addrLabel.setOnMouseClicked((evt)-> outer.inspectAddress(address));
    addrLabel.setTextAlignment(TextAlignment.CENTER);
    addrLabel.setMinWidth(GRAPH_WIDTH);
    addrLabel.setFont(new Font(Font.getDefault().getFamily(), 14));
    addrLabel.setTextFill(Color.WHITE);
    graph = new Canvas(GRAPH_WIDTH, GRAPH_HEIGHT);
    getChildren().add(addrLabel);
    getChildren().add(graph);
    CheckBox hold = new CheckBox("Hold");
    holding = hold.selectedProperty();
    holding.addListener((prop, oldVal, newVal) -> this.updateHold());
    getChildren().add(hold);
    hold.setTextFill(Color.WHITE);
}
 
源代码2 项目: constellation   文件: PluginParametersPane.java
@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;
}
 
源代码3 项目: jace   文件: ConfigurationUIController.java
private Node buildSettingRow(ConfigNode node, String settingName, Serializable value) {
    ConfigurableField fieldInfo = Configuration.getConfigurableFieldInfo(node.subject, settingName);
    if (fieldInfo == null) {
        return null;
    }
    HBox row = new HBox();
    row.getStyleClass().add("setting-row");
    Label label = new Label(fieldInfo.name());
    label.getStyleClass().add("setting-label");
    label.setMinWidth(150.0);
    Node widget = buildEditField(node, settingName, value);
    label.setLabelFor(widget);
    row.getChildren().add(label);
    row.getChildren().add(widget);
    return row;
}
 
源代码4 项目: marathonv5   文件: FileSelectionStage.java
private HBox createBrowserField() {
    HBox browseFieldBox = new HBox(5);
    dirField = new TextField();
    dirField.setId("DirectoryField");
    dirField.textProperty().addListener((observable, oldValue, newValue) -> updateOKButton());
    HBox.setHgrow(dirField, Priority.ALWAYS);
    Button browseButton = FXUIUtils.createButton("browse", "Browse directory", true, "Browse");
    FileSelectionHandler browserListener;
    String fileType = fileSelectionInfo.getFileType();
    if (fileType != null) {
        browserListener = new FileSelectionHandler(this,
                new ExtensionFilter(fileType, Arrays.asList(fileSelectionInfo.getExtensionFilters())), this, null,
                fileSelectionInfo.getTitle());
    } else {
        browserListener = new FileSelectionHandler(this, null, this, null, fileSelectionInfo.getTitle());
        browserListener.setMode(FileSelectionHandler.DIRECTORY_CHOOSER);
    }
    browserListener.setPreviousDir(new File(System.getProperty(Constants.PROP_PROJECT_DIR, ProjectLayout.projectDir)));
    browseButton.setOnAction(browserListener);
    Label label = createLabel("Name: ");
    label.setMinWidth(Region.USE_PREF_SIZE);
    label.setId("FileSelectedLabel");
    browseFieldBox.getChildren().addAll(label, dirField, browseButton);
    VBox.setMargin(browseFieldBox, new Insets(5, 5, 5, 5));
    return browseFieldBox;
}
 
源代码5 项目: marathonv5   文件: ProgressIndicatorBar.java
private void initProgressBarUI() {
    Label runLabel = new Label("Runs: ");
    runLabel.setMinWidth(Region.USE_PREF_SIZE);
    nRuns = new Text((int) progress + "/" + maxTestCount);

    Label errorLabel = new Label("Errors: ");
    errorLabel.setMinWidth(Region.USE_PREF_SIZE);
    errorLabel.setGraphic(FXUIUtils.getIcon("error"));
    errorLabel.setPadding(new Insets(0, 0, 0, 80));
    errorText = new Text(errors + "");

    Label failureLabel = new Label("Failures: ");
    failureLabel.setMinWidth(Region.USE_PREF_SIZE);
    failureLabel.setGraphic(FXUIUtils.getIcon("failure"));
    failureLabel.setPadding(new Insets(0, 0, 0, 80));
    failureText = new Text(failures + "");

    progressBarString.setAlignment(Pos.CENTER);
    progressBarString.setPadding(new Insets(5, 0, 5, 0));
    progressBarString.getChildren().addAll(runLabel, nRuns, errorLabel, errorText, failureLabel, failureText);
}
 
源代码6 项目: constellation   文件: VertexTypeNodeProvider.java
/**
 * 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;
}
 
源代码7 项目: constellation   文件: PluginsNodeProvider.java
/**
 * A Label containing bold text.
 *
 * @param text
 * @return
 */
static Label 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;
}
 
源代码8 项目: bisq   文件: HyperlinkWithIcon.java
public HyperlinkWithIcon(String text, AwesomeIcon awesomeIcon) {
    super(text);

    Label icon = new Label();
    AwesomeDude.setIcon(icon, awesomeIcon);
    icon.setMinWidth(20);
    icon.setOpacity(0.7);
    icon.getStyleClass().addAll("hyperlink", "no-underline");
    setPadding(new Insets(0));
    icon.setPadding(new Insets(0));

    setIcon(icon);
}
 
源代码9 项目: bisq   文件: TxIdTextField.java
public TxIdTextField() {
    txConfidenceIndicator = new TxConfidenceIndicator();
    txConfidenceIndicator.setFocusTraversable(false);
    txConfidenceIndicator.setMaxSize(20, 20);
    txConfidenceIndicator.setId("funds-confidence");
    txConfidenceIndicator.setLayoutY(1);
    txConfidenceIndicator.setProgress(0);
    txConfidenceIndicator.setVisible(false);
    AnchorPane.setRightAnchor(txConfidenceIndicator, 0.0);
    AnchorPane.setTopAnchor(txConfidenceIndicator, 3.0);
    progressIndicatorTooltip = new Tooltip("-");
    txConfidenceIndicator.setTooltip(progressIndicatorTooltip);

    copyIcon = new Label();
    copyIcon.setLayoutY(3);
    copyIcon.getStyleClass().addAll("icon", "highlight");
    copyIcon.setTooltip(new Tooltip(Res.get("txIdTextField.copyIcon.tooltip")));
    AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
    AnchorPane.setRightAnchor(copyIcon, 30.0);

    Tooltip tooltip = new Tooltip(Res.get("txIdTextField.blockExplorerIcon.tooltip"));

    blockExplorerIcon = new Label();
    blockExplorerIcon.getStyleClass().addAll("icon", "highlight");
    blockExplorerIcon.setTooltip(tooltip);
    AwesomeDude.setIcon(blockExplorerIcon, AwesomeIcon.EXTERNAL_LINK);
    blockExplorerIcon.setMinWidth(20);
    AnchorPane.setRightAnchor(blockExplorerIcon, 52.0);
    AnchorPane.setTopAnchor(blockExplorerIcon, 4.0);

    textField = new JFXTextField();
    textField.setId("address-text-field");
    textField.setEditable(false);
    textField.setTooltip(tooltip);
    AnchorPane.setRightAnchor(textField, 80.0);
    AnchorPane.setLeftAnchor(textField, 0.0);
    textField.focusTraversableProperty().set(focusTraversableProperty().get());
    getChildren().addAll(textField, copyIcon, blockExplorerIcon, txConfidenceIndicator);
}
 
源代码10 项目: marathonv5   文件: RubyPathLayout.java
private HBox createRubyHomeField() {
    HBox rubyHomeBox = new HBox(5);
    rubyHomeField = new TextField();
    rubyHomeField.setId("RubyHomeField");
    rubyHomeField.setPromptText("(Bundled JRuby)");
    Label label = createLabel("Ruby Home: ");
    label.setId("RubyLabel");
    label.setMinWidth(Region.USE_PREF_SIZE);
    rubyHomeBox.getChildren().addAll(label, rubyHomeField);
    HBox.setHgrow(rubyHomeField, Priority.ALWAYS);
    return rubyHomeBox;
}
 
源代码11 项目: marathonv5   文件: StatusBar.java
private Label createLabel(String text) {
    Label label = new Label(text);
    label.setMinWidth(Region.USE_PREF_SIZE);
    label.setPadding(new Insets(3, 15, 3, 3));
    label.setAlignment(Pos.CENTER);
    return label;
}
 
源代码12 项目: bisq   文件: SendPrivateNotificationWindow.java
private void addContent() {
    InputTextField keyInputTextField = addInputTextField(gridPane, ++rowIndex, Res.get("shared.unlock"), 10);
    if (useDevPrivilegeKeys)
        keyInputTextField.setText(DevEnv.DEV_PRIVILEGE_PRIV_KEY);

    Tuple2<Label, TextArea> labelTextAreaTuple2 = addTopLabelTextArea(gridPane, ++rowIndex,
            Res.get("sendPrivateNotificationWindow.privateNotification"),
            Res.get("sendPrivateNotificationWindow.enterNotification"));
    TextArea alertMessageTextArea = labelTextAreaTuple2.second;
    Label first = labelTextAreaTuple2.first;
    first.setMinWidth(200);

    Button sendButton = new AutoTooltipButton(Res.get("sendPrivateNotificationWindow.send"));
    sendButton.setOnAction(e -> {
        if (alertMessageTextArea.getText().length() > 0 && keyInputTextField.getText().length() > 0) {
            PrivateNotificationPayload privateNotification = new PrivateNotificationPayload(alertMessageTextArea.getText());
            if (!privateNotificationManager.sendPrivateNotificationMessageIfKeyIsValid(
                    privateNotification,
                    pubKeyRing,
                    nodeAddress,
                    keyInputTextField.getText(),
                    new SendMailboxMessageListener() {
                        @Override
                        public void onArrived() {
                            log.info("PrivateNotificationPayload arrived at peer {}.", nodeAddress);
                            new Popup().feedback(Res.get("shared.messageArrived"))
                                    .onClose(SendPrivateNotificationWindow.this::hide).show();
                        }

                        @Override
                        public void onStoredInMailbox() {
                            log.info("PrivateNotificationPayload stored in mailbox for peer {}.", nodeAddress);
                            new Popup().feedback(Res.get("shared.messageStoredInMailbox"))
                                    .onClose(SendPrivateNotificationWindow.this::hide).show();
                        }

                        @Override
                        public void onFault(String errorMessage) {
                            log.error("PrivateNotificationPayload failed: Peer {}, errorMessage={}", nodeAddress,
                                    errorMessage);
                            new Popup().feedback(Res.get("shared.messageSendingFailed", errorMessage))
                                    .onClose(SendPrivateNotificationWindow.this::hide).show();
                        }
                    }))
                new Popup().warning(Res.get("shared.invalidKey")).width(300).onClose(this::blurAgain).show();
        }
    });

    closeButton = new AutoTooltipButton(Res.get("shared.close"));
    closeButton.setOnAction(e -> {
        hide();
        closeHandlerOptional.ifPresent(Runnable::run);
    });

    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.setAlignment(Pos.CENTER_RIGHT);
    GridPane.setRowIndex(hBox, ++rowIndex);
    GridPane.setColumnSpan(hBox, 2);
    GridPane.setColumnIndex(hBox, 0);
    hBox.getChildren().addAll(sendButton, closeButton);
    gridPane.getChildren().add(hBox);
    GridPane.setMargin(hBox, new Insets(10, 0, 0, 0));
}
 
源代码13 项目: Open-Lowcode   文件: CImageDisplay.java
@Override
public Node getNode(
		PageActionManager actionmanager,
		CPageData inputdata,
		Window parentwindow,
		TabPane[] parenttabpanes,
		CollapsibleNode nodetocollapsewhenactiontriggered) {
	inputdata.addInlineActionDataRef(this.inlineactiondataref);
	this.actionmanager = actionmanager;
	SFile thumbnail = getThumbnail(inputdata, datareference);
	if (!thumbnail.isEmpty()) {
		ByteArrayInputStream imagedata = new ByteArrayInputStream(thumbnail.getContent());
		Image image = new Image(imagedata);
		double imagewidth = image.getWidth();
		double imageheight = image.getHeight();
		thumbnailview = new ImageView(image);
		thumbnailview.setFitWidth(imagewidth);
		thumbnailview.setFitHeight(imageheight);
		thumbnailview.setOnMousePressed(actionmanager.getMouseHandler());
		actionmanager.registerInlineAction(thumbnailview, fullimageaction);
		BorderPane border = new BorderPane();
		border.setBorder(new Border(
				new BorderStroke(Color.web("#ddeeff"), BorderStrokeStyle.SOLID, CornerRadii.EMPTY,
						new BorderWidths(3)),
				new BorderStroke(Color.web("#bbccdd"), BorderStrokeStyle.SOLID, CornerRadii.EMPTY,
						new BorderWidths(1))));
		border.setCenter(thumbnailview);
		border.setMaxHeight(imageheight + 6);
		border.setMaxWidth(imagewidth + 6);
		DropShadow ds = new DropShadow();
		ds.setRadius(3.0);
		ds.setOffsetX(1.5);
		ds.setOffsetY(1.5);
		ds.setColor(Color.color(0.2, 0.2, 0.2));
		border.setEffect(ds);
		if (this.islabel) {
			FlowPane thispane = new FlowPane();
			Label thislabel = new Label(label);
			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);
			thispane.getChildren().add(border);
			return thispane;
		} else {
			return border;
		}

	}

	return null;
}
 
源代码14 项目: JFoenix   文件: JFXSnackbarLayout.java
public JFXSnackbarLayout(String message, String actionText, EventHandler<ActionEvent> actionHandler) {
    initialize();

    toast = new Label();
    toast.setMinWidth(Control.USE_PREF_SIZE);
    toast.getStyleClass().add("jfx-snackbar-toast");
    toast.setWrapText(true);
    toast.setText(message);
    StackPane toastContainer = new StackPane(toast);
    toastContainer.setPadding(new Insets(20));
    actionContainer = new StackPane();
    actionContainer.setPadding(new Insets(0, 10, 0, 0));

    toast.prefWidthProperty().bind(Bindings.createDoubleBinding(() -> {
        if (getPrefWidth() == -1) {
            return getPrefWidth();
        }
        double actionWidth = actionContainer.isVisible() ? actionContainer.getWidth() : 0.0;
        return prefWidthProperty().get() - actionWidth;
    }, prefWidthProperty(), actionContainer.widthProperty(), actionContainer.visibleProperty()));

    setLeft(toastContainer);
    setRight(actionContainer);

    if (actionText != null) {
        action = new JFXButton();
        action.setText(actionText);
        action.setOnAction(actionHandler);
        action.setMinWidth(Control.USE_PREF_SIZE);
        action.setButtonType(JFXButton.ButtonType.FLAT);
        action.getStyleClass().add("jfx-snackbar-action");
        // actions will be added upon showing the snackbar if needed
        actionContainer.getChildren().add(action);

        if (actionText != null && !actionText.isEmpty()) {
            action.setVisible(true);
            actionContainer.setVisible(true);
            actionContainer.setManaged(true);
            // to force updating the layout bounds
            action.setText("");
            action.setText(actionText);
            action.setOnAction(actionHandler);
        } else {
            actionContainer.setVisible(false);
            actionContainer.setManaged(false);
            action.setVisible(false);
        }
    }
}
 
源代码15 项目: Open-Lowcode   文件: CIntegerField.java
@Override
public Node getNode(
		PageActionManager actionmanager,
		CPageData inputdata,
		Window parentwindow,
		TabPane[] parenttabpanes,
		CollapsibleNode nodetocollapsewhenactiontriggered) {
	if (this.datareference != null) {
		this.inputvalue = getExternalContent(inputdata, datareference);
	}

	FlowPane thispane = new FlowPane();
	Label thislabel = new Label(label);
	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);
	boolean readonly = false;
	if (!this.isactive)
		readonly = true;
	if (!this.iseditable)
		readonly = true;

	// ---------------------------- ACTIVE FIELD
	// ------------------------------------
	if (!readonly) {
		integerfield = new TextField();
		integerfield.textProperty().addListener(new ChangeListener<String>() {

			@Override
			public void changed(ObservableValue<? extends String> observable, String oldvalue, String newvalue) {
				if (newvalue.length() > 0) {
					try {
						new Integer(newvalue);
					} catch (NumberFormatException e) {
						integerfield.setText(oldvalue);
					}
				} else {
					integerfield.setText("0");
				}
			}

		});
		if (this.inputvalue != null)
			integerfield.setText(inputvalue.toString());
		thispane.getChildren().add(this.integerfield);
	} else {
		// ---------------------------- INACTIVE FIELD
		// ------------------------------------

		thispane.getChildren()
				.add(CTextField
						.getReadOnlyTextArea(actionmanager, (inputvalue != null ? inputvalue.toString() : ""), 15)
						.getNode());
	}

	return thispane;
}
 
源代码16 项目: Open-Lowcode   文件: CObjectArrayField.java
@Override
public Node getNode(
		PageActionManager actionmanager,
		CPageData inputdata,
		Window parentwindow,
		TabPane[] parenttabpanes,
		CollapsibleNode nodetocollapsewhenactiontriggered) {
	logger.fine("built node CObjectArrayField " + this.name);
	this.actionmanager = actionmanager;
	if (this.inlinefeeding) {
		inputdata.addInlineActionDataRef(this.feedinginlineactionoutputdata);

	}
	this.tooltip = new Tooltip("click to open object\nShift+click to unlink object.");
	HBox thispane = new HBox();

	if (label != null)
		if (label.length() > 0) {
			Label thislabel = new Label(label);
			if (helper != null)
				if (helper.length() > 0)
					thislabel.setTooltip(new Tooltip(helper));
			thislabel.setFont(
					Font.font(thislabel.getFont().getName(), FontPosture.ITALIC, thislabel.getFont().getSize()));
			thislabel.setMinWidth(120);
			thislabel.setWrapText(true);
			thislabel.setMaxWidth(120);
			thispane.getChildren().add(thislabel);
		}

	datapane = new FlowPane();
	boolean nolabel = true;
	if (label != null)
		if (label.length() > 0) {
			FlowPane flowdatapane = new FlowPane();
			thispane.setAlignment(Pos.TOP_LEFT);
			flowdatapane.setPrefWrapLength(400);
			// for object workflow tasks.
			flowdatapane.setVgap(4);
			flowdatapane.setHgap(8);
			this.datapane = flowdatapane;
			nolabel = false;
		}

	if (nolabel) {
		HBox boxdatapane = new HBox();
		thispane.setAlignment(Pos.CENTER_LEFT);
		boxdatapane.setAlignment(Pos.CENTER_LEFT);
		this.datapane = boxdatapane;
	}

	// this is to keep the widget tiny when used as right of title

	thiselementarray = getExternalContent(inputdata, datareference);
	if (objectatendoffielddata != null)
		dataatendoffielddata = objectatendoffielddata.getNode(actionmanager, inputdata, parentwindow,
				parenttabpanes,nodetocollapsewhenactiontriggered);
	refreshDisplay();

	thispane.getChildren().add(datapane);

	return thispane;
}
 
源代码17 项目: mzmine3   文件: DoubleRangeComponent.java
public DoubleRangeComponent(NumberFormat format) {

    setSpacing(8.0);

    minTxtField = new TextField();
    minTxtField.setPrefColumnCount(8);
    // minTxtField.setMinWidth(100.0);

    maxTxtField = new TextField();
    maxTxtField.setPrefColumnCount(8);
    // maxTxtField.setMinWidth(100.0);

    minusLabel = new Label(" - ");
    minusLabel.setMinWidth(15.0);

    getChildren().addAll(minTxtField, minusLabel, maxTxtField);

    setMinWidth(600.0);
    // setStyle("-fx-border-color: red");

    setNumberFormat(format);
  }
 
源代码18 项目: pikatimer   文件: PikaRFIDDirectReader.java
private void setClockDialog(){
    Integer localTZ = TimeZone.getDefault().getOffset(System.currentTimeMillis())/3600000;
    Integer ultraTZ = Integer.parseInt(ultraSettings.get("23"));

    // open a dialog box 
    Dialog<Boolean> dialog = new Dialog();
    dialog.setTitle("Set Ultra Clock");
    dialog.setHeaderText("Set the clock for " + ultraIP);
    ButtonType setButtonType = new ButtonType("Set", ButtonBar.ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().addAll(setButtonType, ButtonType.CANCEL);
    
    VBox clockVBox = new VBox();
    clockVBox.setStyle("-fx-font-size: 16px;");
    
    CheckBox useComputer = new CheckBox("Sync with the local computer");
    VBox manualVBox = new VBox();
    manualVBox.setSpacing(5.0);
    manualVBox.disableProperty().bind(useComputer.selectedProperty());
    
    HBox dateHBox = new HBox();
    dateHBox.setSpacing(5.0);
    Label dateLabel = new Label("Date:");
    dateLabel.setMinWidth(40);
    DatePicker ultraDate = new DatePicker();
    dateHBox.getChildren().addAll(dateLabel,ultraDate);
    
    HBox timeHBox = new HBox();
    timeHBox.setSpacing(5.0);
    Label timeLabel = new Label("Time:");
    timeLabel.setMinWidth(40);
    TextField ultraTime = new TextField();
    timeHBox.getChildren().addAll(timeLabel,ultraTime);
    
    HBox tzHBox = new HBox();
    tzHBox.setSpacing(5.0);
    Label tzLabel = new Label("TimeZone:");
    tzLabel.setMinWidth(40);
    Spinner<Integer> tzSpinner = new Spinner<>(-23, 23, localTZ);    
    tzHBox.getChildren().addAll(tzLabel,tzSpinner);

    manualVBox.getChildren().addAll(dateHBox,timeHBox,tzHBox);
    
    CheckBox autoGPS = new CheckBox("Use GPS to auto-set the clock");
    autoGPS.setSelected(true);

    
    clockVBox.getChildren().addAll(useComputer,manualVBox,autoGPS);
    dialog.getDialogPane().setContent(clockVBox);
    
    BooleanProperty timeOK = new SimpleBooleanProperty(false);

    ultraTime.textProperty().addListener((observable, oldValue, newValue) -> {
        timeOK.setValue(false);
        if (DurationParser.parsable(newValue)) timeOK.setValue(Boolean.TRUE);
        if ( newValue.isEmpty() || newValue.matches("^[0-9]*(:?([0-5]?([0-9]?(:([0-5]?([0-9]?)?)?)?)?)?)?") ){
            System.out.println("Possiblely good start Time (newValue: " + newValue + ")");
        } else {
            Platform.runLater(() -> {
                int c = ultraTime.getCaretPosition();
                if (oldValue.length() > newValue.length()) c++;
                else c--;
                ultraTime.setText(oldValue);
                ultraTime.positionCaret(c);
            });
            System.out.println("Bad clock time (newValue: " + newValue + ")");
        }
    });
    
    
    ultraDate.setValue(LocalDate.now());
    ultraTime.setText(LocalTime.ofSecondOfDay(LocalTime.now().toSecondOfDay()).toString());

    Node createButton = dialog.getDialogPane().lookupButton(setButtonType);
    createButton.disableProperty().bind(timeOK.not());
    
    dialog.setResultConverter(dialogButton -> {
        if (dialogButton == setButtonType) {
            return Boolean.TRUE;
        }
        return null;
    });

    Optional<Boolean> result = dialog.showAndWait();

    if (result.isPresent()) {
        if (useComputer.selectedProperty().get()) {
            System.out.println("Timezone check: Local :" + localTZ + " ultra: " + ultraTZ);
            if (localTZ.equals(ultraTZ)) setClock(LocalDateTime.now(),null,autoGPS.selectedProperty().get());
            else setClock(LocalDateTime.now(),localTZ,autoGPS.selectedProperty().get());
        } else {
            LocalTime time = LocalTime.MIDNIGHT.plusSeconds(DurationParser.parse(ultraTime.getText()).getSeconds());
            Integer newTZ = tzSpinner.getValue();
            if (newTZ.equals(ultraTZ)) setClock(LocalDateTime.of(ultraDate.getValue(), time),null,autoGPS.selectedProperty().get());
            else {
                setClock(LocalDateTime.of(ultraDate.getValue(), time),newTZ,autoGPS.selectedProperty().get());
            }
        }
        
    }
}
 
源代码19 项目: redtorch   文件: CombinationLayout.java
private void createLayout() {
	hBox.getChildren().clear();

	VBox leftVbox = new VBox();

	Label allTodayProfitLabel = new Label("今日盈亏(率):");
	allTodayProfitLabel.setMinWidth(labelWidth);
	allTodayProfitLabel.setAlignment(Pos.CENTER_RIGHT);
	allTodayProfitLabel.getStyleClass().add("trade-label");

	HBox allTodayProfitHBox = new HBox();
	allTodayProfitHBox.getChildren().add(allTodayProfitLabel);
	allTodayProfitHBox.getChildren().add(allTodayProfitText);
	leftVbox.getChildren().add(allTodayProfitHBox);

	Label allBalanceLabel = new Label("资金:");
	allBalanceLabel.setMinWidth(labelWidth);
	allBalanceLabel.setAlignment(Pos.CENTER_RIGHT);
	allBalanceLabel.getStyleClass().add("trade-label");
	HBox allBalanceHBox = new HBox();
	allBalanceHBox.getChildren().add(allBalanceLabel);
	allBalanceHBox.getChildren().add(allBalanceText);
	leftVbox.getChildren().add(allBalanceHBox);

	Label allOpenPositionProfitLabel = new Label("持仓盈亏:");
	allOpenPositionProfitLabel.setMinWidth(labelWidth);
	allOpenPositionProfitLabel.setAlignment(Pos.CENTER_RIGHT);
	allOpenPositionProfitLabel.getStyleClass().add("trade-label");
	HBox allOpenPositionProfitHBox = new HBox();
	allOpenPositionProfitHBox.getChildren().add(allOpenPositionProfitLabel);
	allOpenPositionProfitHBox.getChildren().add(allOpenPositionProfitText);
	leftVbox.getChildren().add(allOpenPositionProfitHBox);

	hBox.getChildren().add(leftVbox);
	HBox.setHgrow(leftVbox, Priority.ALWAYS);

	VBox centerVbox = new VBox();

	Label allPositionProfitLabel = new Label("盯市持仓盈亏:");
	allPositionProfitLabel.setMinWidth(labelWidth);
	allPositionProfitLabel.setAlignment(Pos.CENTER_RIGHT);
	allPositionProfitLabel.getStyleClass().add("trade-label");
	HBox allPositionProfitHBox = new HBox();
	allPositionProfitHBox.getChildren().add(allPositionProfitLabel);
	allPositionProfitHBox.getChildren().add(allPositionProfitText);
	centerVbox.getChildren().add(allPositionProfitHBox);

	Label allMarginLabel = new Label("保证金(率):");
	allMarginLabel.setMinWidth(labelWidth);
	allMarginLabel.setAlignment(Pos.CENTER_RIGHT);
	allMarginLabel.getStyleClass().add("trade-label");
	HBox allMarginHBox = new HBox();
	allMarginHBox.getChildren().add(allMarginLabel);
	allMarginHBox.getChildren().add(allMarginText);
	centerVbox.getChildren().add(allMarginHBox);

	Label allCommissionLabel = new Label("佣金:");
	allCommissionLabel.setMinWidth(labelWidth);
	allCommissionLabel.setAlignment(Pos.CENTER_RIGHT);
	allCommissionLabel.getStyleClass().add("trade-label");
	HBox allCommissionHBox = new HBox();
	allCommissionHBox.getChildren().add(allCommissionLabel);
	allCommissionHBox.getChildren().add(allCommissionText);
	centerVbox.getChildren().add(allCommissionHBox);

	hBox.getChildren().add(centerVbox);
	HBox.setHgrow(centerVbox, Priority.ALWAYS);

	VBox rightVbox = new VBox();

	Label allCloseProfitLabel = new Label("盯市平仓盈亏:");
	allCloseProfitLabel.setMinWidth(labelWidth);
	allCloseProfitLabel.setAlignment(Pos.CENTER_RIGHT);
	allCloseProfitLabel.getStyleClass().add("trade-label");
	HBox allCloseProfitHBox = new HBox();
	allCloseProfitHBox.getChildren().add(allCloseProfitLabel);
	allCloseProfitHBox.getChildren().add(allCloseProfitText);
	rightVbox.getChildren().add(allCloseProfitHBox);

	Label allContractValueLabel = new Label("合约价值:");
	allContractValueLabel.setMinWidth(labelWidth);
	allContractValueLabel.setAlignment(Pos.CENTER_RIGHT);
	allContractValueLabel.getStyleClass().add("trade-label");
	HBox allContractValueHBox = new HBox();
	allContractValueHBox.getChildren().add(allContractValueLabel);
	allContractValueHBox.getChildren().add(allContractValueText);
	rightVbox.getChildren().add(allContractValueHBox);

	Label allDepositAndWithdrawLabel = new Label("出入金:");
	allDepositAndWithdrawLabel.setMinWidth(labelWidth);
	allDepositAndWithdrawLabel.setAlignment(Pos.CENTER_RIGHT);
	allDepositAndWithdrawLabel.getStyleClass().add("trade-label");
	HBox allDepositAndWithdrawHBox = new HBox();
	allDepositAndWithdrawHBox.getChildren().add(allDepositAndWithdrawLabel);
	allDepositAndWithdrawHBox.getChildren().add(allDepositAndWithdrawText);
	rightVbox.getChildren().add(allDepositAndWithdrawHBox);

	hBox.getChildren().add(rightVbox);
	HBox.setHgrow(rightVbox, Priority.ALWAYS);

}
 
源代码20 项目: FxDock   文件: FX.java
/** 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;
}