本文整理汇总了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;
}
示例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();
}
示例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;
}
示例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;
}