本文整理了Java中javafx.scene.control.Button.getScene()
方法的一些代码示例,展示了Button.getScene()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.getScene()
方法的具体详情如下:
包路径:javafx.scene.control.Button
类名称:Button
方法名:getScene
暂无
代码示例来源:origin: pmd/pmd
private Stage getStage() {
return (Stage) commitButton.getScene().getWindow();
}
代码示例来源:origin: speedment/speedment
private void closeWindow() {
issueComponent.clear();
final Stage stage = (Stage) btnClose.getScene().getWindow();
stage.close();
}
}
代码示例来源:origin: stackoverflow.com
@FXML
Button b;
...
@FXML
public void flip() {
Stage s = (Stage)b.getScene().getWindow();
}
代码示例来源:origin: stackoverflow.com
public class LoginDialogController {
@FXML
private Button button ;
@FXML
private void handleButtonPress() {
button.getScene().getWindow().hide();
}
// ...
}
代码示例来源:origin: stackoverflow.com
@FXML
private Button closeBtn;
Stage currentStage = (Stage)closeBtn.getScene().getWindow();
currentStage.close();
代码示例来源:origin: stackoverflow.com
public class LoginController {
private OpenScene openScene ;
@FXML
private Button connectButton ; // needs fx:id in fxml file...
public void initialize() throws Exception {
PrintWriter writer = ... ;
openScene = new OpenScene(writer);
}
@FXML // handler for connect button:
private void btnConnect() throws Exception {
Stage stage = (Stage) connectButton.getScene().getWindow();
openScene.start(stage);
}
}
代码示例来源:origin: stackoverflow.com
public class PopupController {
@FXML
private Button confirmPop ;
private boolean confirmed = false ;
public void isConfirmed() {
return confirmed ;
}
@FXML
private void confirmPop() {
confirmed = true ;
confirmPop.getScene().getWindow().hide();
}
@FXML
private void cancelPop() {
confirmed = false ;
confirmPop.getScene().getWindow().hide();
}
}
代码示例来源:origin: stackoverflow.com
public class WindowMainController implements Initializable {
@FXML
private Button button;
@FXML
private void handleButtonAction(ActionEvent event) {
System.out.println(button.getScene());// Gives you the scene
}
@Override
public void initialize(URL url, ResourceBundle rb) {
System.out.println(button.getScene()); //Prints null
}
}
代码示例来源:origin: stackoverflow.com
public class MyController {
@FXML
private Button fullScreenButton ;
@FXML
private void fullScreen(ActionEvent event) {
Stage stage = (Stage) fullScreenButton.getScene().getWindow();
stage.setFullScreen(true);
}
}
代码示例来源:origin: stackoverflow.com
@FXML
private Button myObject;
private Scene scene;
private Label lblDataLeft;
@FXML
private void handleButtonAction(ActionEvent event) {
System.out.println("You clicked me!");
setLeftSt("this works!");
}
public void setLeftSt(String st){
if(this.scene == null)
this.scene = myObject.getScene();
if(this.lblDataLeft==null)
this.lblDataLeft = (Label) scene.lookup("#LeftSt");
if (this.lblDataLeft!=null)
this.lblDataLeft.setText(st);
}
代码示例来源:origin: stackoverflow.com
stage.setOnCloseRequest(
event -> closeMyApp()
);
private void closeMyApp()
{
try
{
Stage stage = (Stage) closeButton.getScene().getWindow();
stage.close();
}
catch(Exception ee)
{
ex.printStackTrace();
}
}
// where closeButton is button having similar controller class initialization.
@FXML
private Button closeButton;
代码示例来源:origin: stackoverflow.com
@FXML
private Button someButton ;
// ...
public void someButtonController{
Window window = someButton.getScene().getWindow();
if (window instanceof Stage) {
Parent root = FXMLLoader.load(getClass().getResource("/View/ShowWidget.fxml"));
Scene scene = new Scene(root,300,300);
Stage stage = (Stage) window ;
stage.setScene(scene);
stage.show(); // isn't it necessarily showing already?
}
}
代码示例来源:origin: stackoverflow.com
@FXML
private Button goBtn;
Stage stage = (Stage) goBtn.getScene().getWindow();
Scene scene = goBtn.getScene();
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("Activity.fxml"));
scene.setRoot(loader.load());
stage.setScene(scene);
stage.show();
} catch (IOException e) {
e.printStackTrace();
}
代码示例来源:origin: stackoverflow.com
public class WelcomeController {
@FXML
private TextField textField ;
@FXML
private Button okButton ;
@FXML
public void okClicked() throws IOException {
FXMLLoader loader = new FXMLLoader(getClass().getResource("Person.fxml"));
Parent root = loader.load();
PersonController personController = loader.getController();
personController.setName(textField.getText());
okButton.getScene().setRoot(root);
}
}
代码示例来源:origin: stackoverflow.com
public void englishQuestions1(Button btn) throws Exception{
Stage window;
window =(Stage) btn.getScene().getWindow();
FXMLLoader loader = new FXMLLoader(getClass().getResource("Question.fxml"));
Parent root = loader.load();
EnglishQuestions controller = (EnglishQuestions) loader.getController();
Scene scene = new Scene(root,900,600);
window.setScene(scene);
controller.questionText.setText("What is your name? ");
window.show();
}
代码示例来源:origin: stackoverflow.com
@FXML private Button closeButton ;
public void handleCloseButton() {
Scene scene = closeButton.getScene();
if (scene != null) {
Window window = scene.getWindow();
if (window != null) {
window.hide();
}
}
}
代码示例来源:origin: stackoverflow.com
Button bt;
Bounds localBounds = bt.localToScene(bt.getBoundsInLocal());
double popupX = bt.getScene().getWindow().getX() + localBounds.getMaxX();
double popupY = bt.getScene().getWindow().getY() + localBounds.getMaxY();
代码示例来源:origin: org.controlsfx/controlsfx
private void validateButton( ButtonType buttonType, BooleanSupplier condition) {
Button btn = (Button)dialog.getDialogPane().lookupButton(buttonType);
if ( btn != null ) {
Node focusOwner = (btn.getScene() != null) ? btn.getScene().getFocusOwner() : null;
btn.setDisable(condition.getAsBoolean());
if(focusOwner != null) {
focusOwner.requestFocus();
}
}
}
代码示例来源:origin: stackoverflow.com
public void open(String scene, String title, Class className, Object controller, Button btn) {
// Add a controller param
try {
Stage stage;
Parent root;
stage = new Stage();
FXMLLoader loader = new FXMLLoader();
loader.setLocation(className.getResource(scene));
loader.setController(controller); // Set default controller
root = loader.load();
stage.setScene(new Scene(root));
stage.setTitle(title);
stage.initModality(Modality.WINDOW_MODAL);
stage.initOwner(btn.getScene().getWindow());
stage.showAndWait();
} catch (IOException ex) {
Logger.getLogger(luggageController.class.getName()).log(Level.SEVERE, null, ex);
}
代码示例来源:origin: com.powsybl/powsybl-gse-util
private NewScriptButton(ProjectFolder folder, Project project, ObjectProperty<ModificationScript> nodeProperty, GseContext context) {
Node newGlyph = Glyph.createAwesomeFont('\uf0f6').size("1.3em")
.stack(Glyph.createAwesomeFont('\uf055').color("limegreen").size("0.8em"));
scriptProperty = nodeProperty;
button = new Button(null, newGlyph);
button.setOnAction(event -> showAndWaitDialog(folder, project, button.getScene().getWindow(), context));
}
内容来源于网络,如有侵权,请联系作者删除!