本文整理匯總了Java中javafx.scene.layout.GridPane.setId方法的典型用法代碼示例。如果您正苦於以下問題:Java GridPane.setId方法的具體用法?Java GridPane.setId怎麽用?Java GridPane.setId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.layout.GridPane
的用法示例。
在下文中一共展示了GridPane.setId方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: show
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
private void show() {
BorderPane bp = new BorderPane();
bp.setPadding(new Insets(10,50,50,50));
HBox hb = new HBox();
hb.setPadding(new Insets(20,20,20,30));
//Implementing Nodes for GridPane
Label lblUserName = new Label("Username");
Label lblPassword = new Label("Password");
Label lblLanguage = new Label("Language");
Button btnReset = createButton("Reset", "btnLogin");
Button btnRegister = createButton("Register", "btnReset");
Button btnLogin = createButton("Login", "btnReset");
//Adding GridPane
GridPane gridPane = createGridPane(lblUserName, lblPassword, lblLanguage, btnLogin, btnReset, btnRegister);
gridPane.setId("root");
Text text = createText("Game Login");
text.setId("text");
//Adding text to HBox
hb.getChildren().add(text);
//Add ID's to Nodes
bp.setId("bp");
//Add HBox and GridPane layout to BorderPane Layout
bp.setTop(hb);
bp.setCenter(gridPane);
//Adding BorderPane to the scene and loading CSS
scene = new Scene(bp);
scene.getStylesheets().setAll(CSS_LOCATION);
//Action for btnLogin
btnLogin.setOnAction(e -> buttonLoginAction());
//Action for btnReset
btnReset.setOnAction(e -> buttonResetAction());
//Action for btnRegister
btnRegister.setOnAction(p -> {
tempCheckUser = txtUserName.getText().toString();
tempCheckPw = pf.getText().toString();
if(tempCheckUser.length() < LENGTH_OF_USER || tempCheckPw.length() < LENGTH_OF_PASSWORD ){
MessageShowing unsuccess = new MessageShowing();
unsuccess.show("failure");
tempCheckUser="";
tempCheckPw = "";
buttonResetAction();
return;
}
usersModel.addUser(tempCheckUser, tempCheckPw);
writer.write(tempCheckUser, tempCheckPw);
((PopUpMessage) p).show("success");
buttonResetAction();});
scene.setOnKeyPressed(e -> handleKeyInput(e.getCode()));
}