javafx.stage.Stage方法

setResizable

public final void setResizable(boolean value)

Sets the value of the property resizable(可调整大小).

Property description:

Defines whether the Stage is resizable or not by the user. Programatically you may still change the size of the Stage. This is a hint which allows the implementation to optionally make the Stage resizable by the user.

Default value:

true


isResizable

public final boolean isResizable()
Gets the value of the property resizable.

Property description:

Defines whether the Stage is resizable or not by the user. Programatically you may still change the size of the Stage. This is a hint which allows the implementation to optionally make the Stage resizable by the user.

Default value:

true

resizableProperty

public final BooleanProperty resizableProperty()
Defines whether the Stage is resizable or not by the user. Programatically you may still change the size of the Stage. This is a hint which allows the implementation to optionally make the Stage resizable by the user.

Default value:

true

See Also:

isResizable(), setResizable(boolean)


resizableProperty isResizable setResizable例子

package stage;
 
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
 
public class TestStageOfResizable extends Application {
    public static void main(String[] args) {
        launch(args);
    }
    
    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("Hello World!");
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        btn.setOnAction(new EventHandler() {
 
            @Override
            public void handle(ActionEvent event) {
                System.out.println("Hello World!");
            }
        });
        
        StackPane root = new StackPane();
        root.getChildren().add(btn);
        primaryStage.setScene(new Scene(root, 300, 250));
        primaryStage.setResizable(false);//stage不能调整大小
//        primaryStage.setResizable(true);//可调整大小
        System.out.println(primaryStage.isResizable());
        System.out.println(primaryStage.resizableProperty().getValue());
        primaryStage.show();
    }
}


你可能感兴趣的:(javafx.stage.Stage方法)