当前位置: 首页>>代码示例>>Java>>正文


Java DialogPane.setHeaderText方法代码示例

本文整理汇总了Java中javafx.scene.control.DialogPane.setHeaderText方法的典型用法代码示例。如果您正苦于以下问题:Java DialogPane.setHeaderText方法的具体用法?Java DialogPane.setHeaderText怎么用?Java DialogPane.setHeaderText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.control.DialogPane的用法示例。


在下文中一共展示了DialogPane.setHeaderText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import javafx.scene.control.DialogPane; //导入方法依赖的package包/类
/**
 * Create the dialog for entering a String.
 *
 * @param prompt the string message to prompt the user with
 * @return the controller of the dialog window, enabling to display the dialog and read the selected result
 */
public EnterStringController create(String prompt) {
    FXMLLoader fxmlLoader = this.fxmlLoader.get();
    DialogPane dialogPane = null;
    try (InputStream is = getClass().getResourceAsStream("EnterStringDialogPane.fxml")) {
        dialogPane = fxmlLoader.load(is);
    } catch (IOException e) {
        AlertCreator.handleLoadLayoutError(fxmlLoader.getResources(), e);
    }
    dialogPane.setHeaderText(prompt);
    EnterStringController enterStringController = fxmlLoader.getController();
    Dialog<ButtonType> dialog = new Dialog<>();
    dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.setDialogPane(dialogPane);
    enterStringController.setDialog(dialog);
    dialog.setTitle("StudyGuide");
    dialog.setOnShown(event -> enterStringController.getTextField().requestFocus());
    return enterStringController;
}
 
开发者ID:oskopek,项目名称:StudyGuide,代码行数:25,代码来源:EnterStringDialogPaneCreator.java

示例2: ProgressBarDialog

import javafx.scene.control.DialogPane; //导入方法依赖的package包/类
public ProgressBarDialog() {
	DialogPane pane = this.getDialogPane();
	
	this.bar = new ProgressBar();
	this.bar.setPrefWidth(300);
	
	this.words = new Label();
	this.words.setMinWidth(50);
	this.words.setAlignment(Pos.BASELINE_RIGHT);
	
	this.box = new HBox(5);
	
	this.setTitle("");	// set the words on it
	pane.setHeaderText("Please wait.");
	pane.getButtonTypes().addAll(new ButtonType[] { ButtonType.CLOSE });
	((Button) pane.lookupButton(ButtonType.CLOSE)).setText("Run in background");	// you can't close it
	((Button) pane.lookupButton(ButtonType.CLOSE)).setTooltip(new Tooltip("Oh, did you want a cancel button? Well, TOO BAD. Cancel buttons are hard."));
	this.resetBar();
	
	this.setResultConverter((btn) -> {	// set the return value
		return null;
	});
}
 
开发者ID:jkunimune15,项目名称:Map-Projections,代码行数:24,代码来源:ProgressBarDialog.java

示例3: ProjectionSelectionDialog

import javafx.scene.control.DialogPane; //导入方法依赖的package包/类
public ProjectionSelectionDialog() {
	projMap = new HashMap<TreeItem<String>, Projection>();
	
	final TreeItem<String> root = new TreeItem<String>();
	menu = new TreeView<String>(root);
	menu.setShowRoot(false); //create and configure the TreeView of options
	menu.setPrefWidth(MENU_WIDTH);
	
	flow = new TextFlow(); //create and configure the description area
	flow.setPrefWidth(TEXT_WIDTH);
	text = new GridPane();
	text.setHgap(10);
	
	menu.getSelectionModel().selectedItemProperty().addListener((observable, old, now) -> {
			if (projMap.containsKey(now)) //selection callback to describe each projection
				describe(projMap.get(now));
			else if (now != null) {
				describe(null);
			}
		});
	menu.setCellFactory((tView) -> { //factoring cells to detect double-clicks
			final TreeCell<String> cell = new TextFieldTreeCell<String>();
			cell.setOnMouseClicked((event) -> { //on double click, close dialog
					if (event.getClickCount() >= 2 && projMap.containsKey(cell.getTreeItem())) {
						this.setResult(projMap.get(cell.getTreeItem()));
					}
				});
			return cell;
		});
	
	String[] categories = MapApplication.PROJECTION_CATEGORIES;
	Projection[][] projections = MapApplication.ALL_PROJECTIONS;
	for (int i = 0; i < categories.length; i ++) { //finally, populate the TreeView
		final TreeItem<String> header = new TreeItem<String>(categories[i]);
		root.getChildren().add(header);
		for (int j = 0; j < projections[i].length; j ++) {
			final TreeItem<String> leaf = new TreeItem<String>(projections[i][j].getName());
			projMap.put(leaf, projections[i][j]);
			header.getChildren().add(leaf);
		}
	}
	
	this.setTitle("Projection selection"); //set general properties for the dialog
	final DialogPane pane = this.getDialogPane();
	pane.setHeaderText("Choose a projection from the list below.");
	pane.getButtonTypes().addAll(new ButtonType[] { ButtonType.OK, ButtonType.CANCEL }); //add buttons
	pane.setContent(new HBox(10, menu, new VBox(10, flow, text)));
	
	this.setResultConverter((btn) -> { //how to return a result:
			if (btn != null && btn.getButtonData() == ButtonData.OK_DONE) {
				final TreeItem<String> selection =  menu.getSelectionModel().getSelectedItem();
				return projMap.getOrDefault(selection, Projection.NULL_PROJECTION); //return the corresponding projection
			} //or NULL_PROJECTION if the user never chose anything
			else {
				return null;
			}
		});
}
 
开发者ID:jkunimune15,项目名称:Map-Projections,代码行数:59,代码来源:ProjectionSelectionDialog.java

示例4: MapConfigurationDialog

import javafx.scene.control.DialogPane; //导入方法依赖的package包/类
public MapConfigurationDialog(double defAsp) {
	this.defaultRatio = defAsp;
	DialogPane pane = this.getDialogPane();
	
	this.maintainRatio = new CheckBox("Maintain aspect ratio");	// instantiate the components
	this.maintainRatio.setSelected(true);
	
	this.widthBox = new Spinner<Integer>(5,10000,
			10*(int)Math.round(DEF_SIZE*Math.sqrt(defaultRatio)/10));
	this.widthBox.setEditable(true);
	this.widthBox.setMaxWidth(Double.MAX_VALUE);
	
	this.heightBox = new Spinner<Integer>(5,10000,
			10*(int)Math.round(this.widthBox.getValue()/defaultRatio/10));
	this.heightBox.setEditable(true);
	this.widthBox.setMaxWidth(Double.MAX_VALUE);
	
	this.widthBox.valueProperty().addListener((observable, prev, now) -> {	// link the Spinners
			if (realEdit && maintainRatio.isSelected()) {
				realEdit = false;
				int prefHeight = (int)Math.round(widthBox.getValue()/defaultRatio);
				heightBox.getValueFactory().setValue(prefHeight);
				realEdit = true;
			}
		});
	this.heightBox.valueProperty().addListener((observable, prev, now) -> {
			if (realEdit && maintainRatio.isSelected()) {
				realEdit = false;
				int prefWidth = (int)Math.round(heightBox.getValue()*defaultRatio);
				widthBox.getValueFactory().setValue(prefWidth);
				realEdit = true;
			}
		});
	
	this.widthBox.focusedProperty().addListener((observable, prev, now) -> { //make the spinners commit their
			if (!now) 	widthBox.increment(0);
		});
	this.heightBox.focusedProperty().addListener((observable, prev,now) -> { //values when focus is lost
			if (!now) 	heightBox.increment(0);
		});
	
	ObservableList<String> items = FXCollections.observableArrayList("None","Low","High");
	this.smoothBox = new ComboBox<String>(items);
	this.smoothBox.setValue("Low");
	this.smoothBox.setMaxWidth(Double.MAX_VALUE);
	
	this.gui = new VBox(20);
	
	pane.contentTextProperty().addListener((arg0) -> this.updateGUI());	// set it to refresh the gui when... the content texts?
	this.setTitle("Save options");	// set the words on it
	pane.setHeaderText("Please configure the final image");
	pane.getButtonTypes().addAll(new ButtonType[] { ButtonType.OK, ButtonType.CANCEL });	// add buttons
	this.updateGUI();
	
	this.setResultConverter(
			(btn) -> (btn != null && btn.getButtonData() == ButtonData.OK_DONE));
	
	realEdit = true;
}
 
开发者ID:jkunimune15,项目名称:Map-Projections,代码行数:60,代码来源:MapConfigurationDialog.java


注:本文中的javafx.scene.control.DialogPane.setHeaderText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。