0
최소화 버튼이있는 JavaFX 패널 인이 코드를 작성 중입니다. 그런 다음 버튼을 눌러 패널의 크기를 축소하고 단추를 눌러 원래 크기로 복원하려고합니다.크기 변경 버튼
public class MainApp extends Application
{
private static BorderPane bp;
@Override
public void start(Stage stage) throws Exception
{
FlowPane flow = new FlowPane();
flow.setPadding(new Insets(50, 5, 5, 5));
flow.setVgap(15);
flow.setHgap(15);
flow.setAlignment(Pos.CENTER);
Button button = new Button("Minimize");
HBox thb = new HBox();
thb.getChildren().add(button);
thb.setAlignment(Pos.CENTER_RIGHT);
boolean flag = true;
button.setOnAction(new EventHandler<ActionEvent>()
{
@Override
public void handle(ActionEvent t)
{
if (flag == true)
{
flag = false;
bp.setPrefSize(600, 40);
bp.setMaxSize(600, 40);
}
else
{
bp.setPrefSize(600, 500);
bp.setMaxSize(600, 500);
}
}
});
thb.setPadding(new Insets(13, 13, 13, 13));
thb.setStyle("-fx-background-color: gray");
DropShadow ds = new DropShadow();
ds.setOffsetY(3.0);
ds.setOffsetX(3.0);
ds.setColor(Color.GRAY);
bp = new BorderPane();
bp.setEffect(ds);
bp.setPrefSize(600, 500);
bp.setMaxSize(600, 500);
bp.setStyle("-fx-background-color: white;");
bp.setTop(thb);
flow.getChildren().add(bp);
Scene scene = new Scene(flow, 1200, 800);
scene.getStylesheets().add("/styles/Styles.css");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args)
{
launch(args);
}
}
코드의 논리가 잘못된 이유로 인해 부울 플래그 비트가 사용되었습니다. 이 문제를 해결하도록 도와 줄 수 있습니까? 다른 부분에서