當前位置: 首頁>>代碼示例>>Java>>正文


Java VBox.setOnKeyReleased方法代碼示例

本文整理匯總了Java中javafx.scene.layout.VBox.setOnKeyReleased方法的典型用法代碼示例。如果您正苦於以下問題:Java VBox.setOnKeyReleased方法的具體用法?Java VBox.setOnKeyReleased怎麽用?Java VBox.setOnKeyReleased使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.layout.VBox的用法示例。


在下文中一共展示了VBox.setOnKeyReleased方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: simpleString

import javafx.scene.layout.VBox; //導入方法依賴的package包/類
/**
 * Kleines Fenster, dass Input (String) vom User abfragt.
 * 
 * @param title
 *            Der Titel des Fensters
 * @param message
 *            Die Narchricht, die angezeigt wird. Text wird nicht von selbst
 *            gewrapt.
 * @param fieldWidth
 *            Setzt die Breite des Textfeldes
 * @return String mit dem Userinput
 */
public static String simpleString (String title, String message, String field, double fieldWidth)
{
	Stage window = buildWindow(title);

	Label l = new Label(message);

	TextField tf = new TextField(field);
	tf.setMaxWidth(fieldWidth);

	tf.setOnKeyReleased(e -> {
		if (e.getCode().equals(KeyCode.ENTER))
		{
			tempOutput = tf.getText();
			window.close();
		}
	});
	
	Button b = new Button("_OK");
	b.setOnAction(e ->
	{
		tempOutput = tf.getText();
		window.close();
	});

	VBox layout = new VBox(20);
	layout.getChildren().addAll(l, tf, b);
	layout.setAlignment(Pos.CENTER);
	layout.setPadding(new Insets(20));

	int width;
	int x = 6;
	int y = 150;

	width = message.length() * x + y;
	
	layout.setOnKeyReleased(e ->
	{
		if (e.getCode() == KeyCode.ESCAPE)
			window.close();
	});
	
	window.setScene(new Scene(layout, width, 150));
	window.showAndWait();
	output = tempOutput;
	tempOutput = null;
	return output;
}
 
開發者ID:CoffeeCodeSwitzerland,項目名稱:Lernkartei_2017,代碼行數:60,代碼來源:Alert.java

示例2: simpleInfoBox

import javafx.scene.layout.VBox; //導入方法依賴的package包/類
/**
 * Zeigt ein kleines Infofenster an. Der User muss das Fenster schliessen,
 * bevor er andere Fenster der Anwendung bedienen kann. Die Breite des
 * Fensters passt sich dem Text an.
 * 
 * @param title
 *            Der Titel des Fensters
 * @param message
 *            Die Narchricht, die angezeigt wird. Text wird nicht von selbst
 *            gewrapt.
 * @param button
 *            Text des Buttons
 */
public static void simpleInfoBox (String title, String message, String button)
{
	Stage window = buildWindow(title);
	Label l = new Label(message);
	Button b = new Button(button);

	b.setOnAction(e -> window.close());

	VBox layout = new VBox(20);
	layout.getChildren().addAll(l, b);
	layout.setAlignment(Pos.CENTER);

	// Passt Breite des Fensters an den Text an
	int width;
	int x = 6;
	int y = 150;
	width = message.length() * x + y;

	layout.setOnKeyReleased(e ->
	{
		if (e.getCode() == KeyCode.ESCAPE)
			window.close();
	});
	
	window.setScene(new Scene(layout, width, 150));
	window.show();
}
 
開發者ID:CoffeeCodeSwitzerland,項目名稱:Lernkartei_2017,代碼行數:41,代碼來源:Alert.java

示例3: ok

import javafx.scene.layout.VBox; //導入方法依賴的package包/類
/**
 * Fenster mit OK- und Abbrechen-Buttons
 * 
 * @param title
 *            Der Titel des Fensters
 * @param message
 *            Die Narchricht, die angezeigt wird. Text wird nicht von selbst
 *            gewrapt.
 * @return True, wenn der User akzeptiert, sonst false
 */
public static boolean ok (String title, String message)
{
	Stage window = buildWindow(title);
	Label l = new Label(message);

	Button bo = new Button("_OK");
	Button ba = new Button("_Abbrechen");

	bo.setOnAction(e ->
	{
		tempOkay = true;
		window.close();
	});

	ba.setOnAction(e ->
	{
		tempOkay = false;
		window.close();
	});

	HBox buttons = new HBox(20);
	buttons.setAlignment(Pos.CENTER);
	buttons.setPadding(new Insets(20));
	buttons.getChildren().addAll(bo, ba);

	VBox layout = new VBox(20);
	layout.getChildren().addAll(l, buttons);
	layout.setAlignment(Pos.CENTER);
	layout.setPadding(new Insets(40, 20, 20, 20));

	int width;
	int x = 6;
	int y = 150;

	width = message.length() * x + y;

	layout.setOnKeyReleased(e ->
	{
		if (e.getCode() == KeyCode.ESCAPE)
			window.close();
	});
	
	window.setScene(new Scene(layout, width, 150));
	window.showAndWait();

	okay = tempOkay;
	tempOkay = false;
	
	return okay;
}
 
開發者ID:CoffeeCodeSwitzerland,項目名稱:Lernkartei_2017,代碼行數:61,代碼來源:Alert.java

示例4: complexChoiceBox

import javafx.scene.layout.VBox; //導入方法依賴的package包/類
public static int complexChoiceBox (String title, String message, String... options)
{
	Stage window = buildWindow(title);

	Label l = new Label(message);

	AppButton[] buttons = new AppButton[options.length];

	for (int i = 0; i < options.length; i++)
	{
		final int j = i;
		buttons[j] = new AppButton(options[j]);
		buttons[j].setOnAction(e ->
		{
			tempChoise = j;
			window.close();
		});
	}
	
	VBox layout = new VBox(20);
	layout.getChildren().add(l);
	layout.getChildren().addAll(buttons);
	layout.setAlignment(Pos.CENTER);
	layout.setPadding(new Insets(20));

	int width;
	int x = 6;
	int y = 150;
	width = message.length() * x + y;

	int height;
	height = options.length * 25 + 150;

	layout.setOnKeyReleased(e ->
	{
		if (e.getCode() == KeyCode.ESCAPE)
			window.close();
	});
	
	window.setScene(new Scene(layout, width, height));
	window.showAndWait();

	choise = tempChoise;
	tempChoise = -1;
	return choise;
}
 
開發者ID:CoffeeCodeSwitzerland,項目名稱:Lernkartei_2017,代碼行數:47,代碼來源:Alert.java


注:本文中的javafx.scene.layout.VBox.setOnKeyReleased方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。